Use existing IE cookie

KB keith at nekotaku.com
Thu Jul 30 11:58:56 EDT 2009


> What does you full example look like, including the
> cookie-acquisition-stuff?
>
> Diez

I ran them seperately, hoping for a clue as to what my "cookiejar"
was.

The cookie-acquisition stuff returns "screener.ashx?v=151" when I
search with my domain I am interested in. I have tried
urllib2.HTTPCookieProcessor('screener.ashx?v=151') but that failed
with attr has no cookie header.

>From the HTTPCookieProcessor doco, it appears that non-IE browsers
have a cookie file (and example code) but from what I can tell IE uses
a hidden folder. (you can set your location in IE but it appends a
folder "\Temporary Internet Files"  -

From: http://docs.python.org/dev/library/cookielib.html

***
This example illustrates how to open a URL using your Netscape,
Mozilla, or Lynx cookies (assumes Unix/Netscape convention for
location of the cookies file):

import os, cookielib, urllib2
cj = cookielib.MozillaCookieJar()
cj.load(os.path.join(os.environ["HOME"], ".netscape/cookies.txt"))
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor(cj))
r = opener.open("http://example.com/")
***

Not sure how to adapt this for IE.



More information about the Python-list mailing list