MozillaCookieJar doesn't work as expect
davihigh at gmail.com
davihigh at gmail.com
Sat Feb 3 23:03:14 EST 2007
OS: WinXP, Python 2.4 latest version
I found it doesn't actually load cookies from the exist cookies.txt.
Instead, it generate a new one when visit that url. Who can help me
check what's problem in following code?
Many thanks in advance!
cj = cookielib.MozillaCookieJar()
cj.load("d:\\temp\\cookies.txt") # I want to use existing cookie
value, not new generated
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
urllib2.install_opener(opener)
# then, user page
r = urllib2.urlopen("http://xxxxx_page_that_need_loaded_cookie")
results = r.read()
open('user.html', 'w').write(results)
# save cookies to file
cj.save("./cookies") # with saved cookies, it is NOT the load one
More information about the Python-list
mailing list