我正在玩Python库httplib2.以下是我的代码.
import urllib.parse
import httplib2
httplib2.debuglevel = 1
http = httplib2.Http()
url = "http://login.sina.com.cn/hd/signin.php"
body = {"act": "1",
"entry": "vblog",
"password": "P@$sW0rd",
"reference": "http://vupload.you.video.sina.com.cn/u.php?m=1&cate=0",
"reg_entry": "vblog",
"remLoginName": "on",
"username": "this_is_user_name",
"x": "",
"y": ""}
headers = {"Accept", "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
"Accept-Charset", "ISO-8859-1,utf-8;q=0.7,*;q=0.7",
"Accept-Encoding", "gzip,deflate",
"Accept-Language", "en-us,en;q=0.5",
"Connection", "keep-alive",
"Content-Length", "181",
"Content-Type", "application/x-www-form-urlencoded",
"Host", "login.sina.com.cn",
"Keep-Alive", "115",
"Referer", "http://login.sina.com.cn/hd/signin.php?entry=vblog&r=http%3A%2F%2Fvupload.you.video.sina.com.cn%2Fu.php%3Fm%3D1%26cate%3D0",
"User-Agent", "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.16) Gecko/20110319 Firefox/3.6.16"}
response, content = http.request(url, 'POST', headers=headers, body=urllib.parse.urlencode(body))
Run Code Online (Sandbox Code Playgroud)
当我执行它时,我收到错误:
Microsoft Windows XP …Run Code Online (Sandbox Code Playgroud)