user-agent

Parsing HTTP User-Agent string

Parsing HTTP User-Agent string Question: What is the best method to parse a User-Agent string in Python to reliably detect Browser Browser version OS Or perhaps any helper library that does it Asked By: Shekhar || Source Answers: However if you wish to parse all this on the Python side you can use the XML/INI …

Total answers: 8

Changing user agent on urllib2.urlopen

Changing user agent on urllib2.urlopen Question: How can I download a webpage with a user agent other than the default one on urllib2.urlopen? urllib2.urlopen is not available in Python 3.x; the 3.x equivalent is urllib.request.urlopen. See Changing User Agent in Python 3 for urrlib.request.urlopen to set the user agent in 3.x with the standard library …

Total answers: 9

Fetch a Wikipedia article with Python

Fetch a Wikipedia article with Python Question: I try to fetch a Wikipedia article with Python’s urllib: f = urllib.urlopen(“http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes”) s = f.read() f.close() However instead of the html page I get the following response: Error – Wikimedia Foundation: Request: GET http://en.wikipedia.org/w/index.php?title=Albert_Einstein&printable=yes, from 192.35.17.11 via knsq1.knams.wikimedia.org (squid/2.6.STABLE21) to () Error: ERR_ACCESS_DENIED, errno [No Error] at …

Total answers: 10