Retrieving cookies in Python using urllib2

时间:2016-02-03 03:03:41

标签: python cookies urllib2

I am trying to retrieve the cookie from a page that is running on localhost from my own python script, but I am having trouble understanding the urllib2 documentation. I tried looking around for some examples of retrieving cookies and couldn't really find an answer. Would it be something along the lines of:

url = "http://localhost:8080"
request = urllib2.Request(url)
sock=urllib2.urlopen(request)

after this I don't know how I would fetch the cookies, and I don't even fully understand what this code does.

Also, is there a way to use urllib2 to send a cookie back?

Thanks!

0 个答案:

没有答案