urllib accept-language doesn't have any effect
martin.bachwerk at rwth-aachen.de
Wed Oct 15 16:41:17 CEST 2008
yes, well my browser settings are set to display sites in following
languages "en-gb" then "en".
As a matter of fact, Google does indeed show me the German site first,
before I click on "go to google.com" and it probably stores a cookie to
But a site like gizmodo.com forwards me directly to the English site
(even though they have a German version available). But the Python call
returns the German version. How does that make sense?
> Martin Bachwerk wrote:
>> 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
>> 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:18.104.22.168) Gecko/2008070208
>> webfile = opener.open(url)
>> Any help would be greatly appreciated!
> What is your actual problem - does it work with *other* requests you somehow
> produce (browser or some such)?
> In the end, it's up to the site you query to return you whatever they see
> fit. Nothing urllib or python in general can change.
More information about the Python-list