开发者

Access to the cookies of the default browser

I want to write a program that opens the browser and open a url with a given cookie. I dont know how to do this.开发者_如何学JAVA Maybe I could modify the cookies in the default place.


import urllib2
opener = urllib2.build_opener()
opener.addheaders.append(('Cookie', 'cookiename=cookievalue'))
f = opener.open("http://example.com/")

Modules to look into:

urllib2
cookielib
Cookie


In python, you can emulate a browser with the mechanize library. Also, there is good documentation about mechanize and cookies.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜