Created
November 26, 2012 19:26
-
-
Save nalsi/4150093 to your computer and use it in GitHub Desktop.
Fetching Wikipedia article using Python's "urllib2" module
This file contains hidden or 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
## 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