Created
August 22, 2008 03:58
-
-
Save grahamg/6739 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
import urllib, urllib2 | |
def getsource(pagereq): | |
user_agent = 'Mozilla/4.0 (compatible; MSIE 5.5; Windows NT)' | |
header = {'User-Agent': user_agent} | |
req = urllib2.Request(pagereq, None, header) | |
response = urllib2.urlopen(req) | |
page = response.read() | |
return page | |
def main(): | |
html = getsource("www.google.com") | |
print html | |
if __name__ == '__main__': | |
main() | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment