Skip to content

Instantly share code, notes, and snippets.

@svetlyak40wt
Created July 13, 2009 11:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svetlyak40wt/146052 to your computer and use it in GitHub Desktop.
Save svetlyak40wt/146052 to your computer and use it in GitHub Desktop.
#!/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