py3.x urllib.request - HTTPCookieProcessor and header adding
gervaz
gervaz at gmail.com
Wed Dec 16 08:23:10 EST 2009
Hi all, I need to fetch some html pages and it is required to have
cookies enabled. So, I'm using
opener = urllib.request.build_opener(urllib.request.HTTPCookieProcessor
())
urllib.request.install_opener(opener)
as a global instance. Is there a way to always use a default header
like:
{"User-Agent": "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:
1.9.1.5) Gecko/20091102 Firefox/3.5.5"}
instead of always creating urllib.request.Request(my_url, None,
headers) and call different urls with the same
cookies?
Thanks, Mattia
More information about the Python-list
mailing list