Created
July 13, 2009 11:29
-
-
Save svetlyak40wt/146052 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""Example of custom header and debugging for urllib2's request.""" | |
import urllib2 | |
request = urllib2.Request('http://aartemenko.com') | |
request.add_header('User-Agent', 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.11) Gecko/2009060308 Ubuntu/9.04 (jaunty) Firefox/3.0.11') | |
h=urllib2.HTTPHandler(debuglevel=1) | |
opener = urllib2.build_opener(h) | |
data = opener.open(request).read() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment