开发者

GET request with headers using keep-alive connection under python

开发者 https://www.devze.com 2023-03-26 09:35 出处:网络
I want to make a connection to http://mysite.org using GET method keeping connection alive and sending an user-agent heade开发者_运维问答r to the server. I know I should use urlgrabber or smth like th

I want to make a connection to http://mysite.org using GET method keeping connection alive and sending an user-agent heade开发者_运维问答r to the server. I know I should use urlgrabber or smth like that but I need the actual code actually. Please help me friends.. THANK YOU

conn = httplib.HTTPConnection(urlparse(url)[1])
conn.request("GET", urlparse(url)[2])
conn.putheader("Referer", referer)
conn.endheaders()
r1 = conn.getresponse()

whats wrong with that??


Use httplib

The Python docs page has examples there. http://docs.python.org/library/httplib.html

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号