Using Python to implement the code _python of Baidu Hi automatic login

Source: Internet
Author: User
Copy Code code as follows:

# _*_ Coding:utf-8 _*_
# name login_baidu.py
Import Urllib,urllib2,httplib,cookielib
def auto_login_hi (URL,NAME,PWD):
Url_hi= "Http://passport.baidu.com/?login"
#设置cookie
Cookie=cookielib. Cookiejar ()
Cj=urllib2. Httpcookieprocessor (Cookie)
#设置登录参数
Postdata=urllib.urlencode ({' username ': name, ' Password ':p wd})
#生成请求
Request=urllib2. Request (Url_hi,postdata)
#登录百度
Opener=urllib2.build_opener (CJ)
F=opener.open (Request)
Print F
#打开百度HI空间页面
Hi_html=opener.open (URL)
Return hi_html
If __name__== ' __main__ ':
Name= ' Hjkll '
Password= ' 11111111 '
Url= ' Http://hi.baidu.com/ewayfly '
H=auto_login_hi (Url,name,password)
Print H.read ()
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.