import urllib2
import urllib
#POST data you might want to send. If you don't want to send post data, just set this as None or blank, e.g. data = {}
data = urllib.urlencode({"username":uname, "passwd":yourpass, "submit":"Submit"})
#add as many header fields as you like
headers = {"Cookie":"<<your cookies go here>>", "Referer":"blahblah"}
request = urllib2.Request("yourwebserver.com", data, headers)
#here you get your response back
response = urllib2.urlopen(request).read()
如果它符合您的需要,您可以查看}库。它们是更高级别的库,让你可以很容易地完成这类工作。例如,发送带有某些标头字段的请求如下所示:
urllib
和{希望这对你有所帮助!干杯!:)
您可以使用请求库:文档.python-请求.org在
AutobahnPython支持在WebSocket打开握手期间检查和设置HTTP头。请参见here和here。在
相关问题 更多 >
编程相关推荐