Urllib2: Difference between revisions

From XPUB & Lens-Based wiki
(New page: * http://docs.python.org/lib/module-urllib2.html * http://www.voidspace.org.uk/python/articles/urllib2.shtml)
 
No edit summary
Line 1: Line 1:
== Making a Request (pretending to be Firefox) ==
<source lang="python">
request = urllib2.Request(url)
user_agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.14) Gecko/20080418 Ubuntu/7.10 (gutsy) Firefox/2.0.0.14"
request.add_header("User-Agent", user_agent)
pagefile=urllib2.urlopen(request)
</source>
== Checking a Domain ==
* http://docs.python.org/lib/module-urllib2.html
* http://docs.python.org/lib/module-urllib2.html
* http://www.voidspace.org.uk/python/articles/urllib2.shtml
* http://www.voidspace.org.uk/python/articles/urllib2.shtml

Revision as of 18:51, 24 March 2009

Making a Request (pretending to be Firefox)

request = urllib2.Request(url)
user_agent = "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.14) Gecko/20080418 Ubuntu/7.10 (gutsy) Firefox/2.0.0.14"
request.add_header("User-Agent", user_agent)
pagefile=urllib2.urlopen(request)


Checking a Domain