Use existing IE cookie
KB
keith at nekotaku.com
Thu Jul 30 11:09:20 EDT 2009
Hi there,
Relevant versions: Python 2.5, Vista Home, IE7
I am trying to scrape a website I have browsed manually in the past,
and also manually selected my options, and now want python to use my
existing cookie from the manual browse when downloading data.
Using: http://code.activestate.com/recipes/80443/ I have found the
"name" of the relevant cookie, just after reading urllib2 docs, I
can't see how to "send" or have my python instance use "MY" existing
cookie.
Using the following:
***
import re
import urllib2, cookielib
# set things up for cookies
opener = urllib2.build_opener(urllib2.HTTPCookieProcessor())
urllib2.install_opener(opener)
reply = urllib2.urlopen('foo.html').read()
print reply
***
This does return data, just default data, not the data from the
options I set up when manually browsing.
My sense is that I need "something" in the () part of
HTTPCookieProcessor() but I have no idea as to what... the docs say
"cookiejar" but the only code examples I have found are to create a
cookiejar for the existing Python session, not to use the cookies from
my prior manual meanderings.
Any help greatly appreciated.
More information about the Python-list
mailing list