MozillaCookieJar doesn't work as expect

D

davihigh

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,432
Messages
2,571,682
Members
48,796
Latest member
Greg L.

Latest Threads

Top