读书人

请教怎么Request文件头headers

发布时间: 2012-09-11 10:49:03 作者: rapoo

请问如何Request文件头headers?

Python code
an_url="http://www.test.com"headers={"Content-Type":"application/x-www-form-urlencoded","Cookies":"cookie"}post_data=urllib.urlencode({'id':'xxx','pwd':'xxx'})re_checkin=urllib2.Request(an_url,post_data)

这样只能Request那个post_data,请问如何一同POST文件头headers?

[解决办法]
Python code
urllib2.Request(an_url,post_data,headers)
[解决办法]
class urllib2.Request(url[, data][, headers][, origin_req_host][, unverifiable])
========================================================
an_url="http://www.test.com"
headers={"Content-Type":"application/x-www-form-urlencoded","Cookies":"cookie"}
post_data=urllib.urlencode({'id':'xxx','pwd':'xxx'})
re_checkin=urllib2.Request(url=an_url,data=post_data,headers=headers)

读书人网 >perl python

热点推荐