Skip to content

Instantly share code, notes, and snippets.

@nalsi
Created November 26, 2012 19:26
Show Gist options
  • Save nalsi/4150093 to your computer and use it in GitHub Desktop.
Save nalsi/4150093 to your computer and use it in GitHub Desktop.
Fetching Wikipedia article using Python's "urllib2" module
## Creator: Kai Li
## Time: 11/26/2012
## Task: Fetching Wikipedia article using Python's "urllib2" module
import urllib2
opener = urllib2.build_opener()
opener.addheaders = [('User-agent', 'Mozilla/5.0')]
req = opener.open("http://en.wikipedia.org/wiki/Betelgeuse")
f = open("3.html", 'w')
f.write(req.read())
f.close
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment