Fetch a Wikipedia article with Python

You need to use the urllib2 that superseedes urllib in the python std library in order to change the user agent. Straight from the examples import urllib2 opener = urllib2.build_opener() opener.addheaders = [(‘User-agent’, ‘Mozilla/5.0’)] infile = opener.open(‘http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes’) page = infile.read()

Operating System from User-Agent HTTP Header [closed]

Here’s a quick list… let me know if I missed one you are interested in. http://www.geekpedia.com/code47_Detect-operating-system-from-user-agent-string.html: // Match user agent string with operating systems Windows 3.11 => Win16, Windows 95 => (Windows 95)|(Win95)|(Windows_95), Windows 98 => (Windows 98)|(Win98), Windows 2000 => (Windows NT 5.0)|(Windows 2000), Windows XP => (Windows NT 5.1)|(Windows XP), Windows Server 2003 … Read more

How to recognize Facebook User-Agent

For list of user-agent strings, look up here. The most used, as of September 2015, are facebookexternalhit/* and Facebot. As you haven’t stated what language you’re trying to recognize the user-agent in, I can’t tell you more information. If you do want to recognize Facebook bot in PHP, use if ( strpos($_SERVER[“HTTP_USER_AGENT”], “facebookexternalhit/”) !== false … Read more

Why do Chrome and IE put “Mozilla 5.0” in the User-Agent they send to the server? [duplicate]

See: user-agent-string-history It all goes back to browser sniffing and making sure that the browsers are not blocked from getting content they can support. From the above article: And Internet Explorer supported frames, and yet was not Mozilla, and so was not given frames. And Microsoft grew impatient, and did not wish to wait for … Read more

JQuery Ajax Request: Change User-Agent

It is simply impossible, you are not allowed to change the user-agent for XMLHttpRequests. I’m not sure if this is valid for Internet-Explorer, but the w3c specifies here: The setRequestHeader() method […] When the setRequestHeader(header, value) method is invoked, the user agent must run these steps: […] Terminate these steps if header is a case-insensitive … Read more