开发者

Access to the cookies of the default browser

开发者 https://www.devze.com 2023-04-11 15:05 出处:网络
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

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

精彩评论

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

关注公众号