urllib accept-language doesn't have any effect
Martin Bachwerk
martin.bachwerk at rwth-aachen.de
Wed Oct 15 09:50:40 EDT 2008
Hello,
I'm trying to load a couple of pages using the urllib2 module. The
problem is that I live in Germany and some sites seem to look at the IP
of the client and forward him to a localized page.. Here's an example of
the code, how I want to access google.com main english page, but get
German instead. (For those of you who live in US, you will probably get
correct results.. try emulating with 'fr' in accepted languages or
something)
opener = urllib2.build_opener()
opener.addheaders = [('Host', 'www.google.com'),
('Accept-Language','en-gb,en;q=0.5'), ('User-agent', 'Mozilla/5.0
(Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.1) Gecko/2008070208
Firefox/3.0.1')]
webfile = opener.open(url)
Any help would be greatly appreciated!
Thank you!
Martin
More information about the Python-list
mailing list