Search This Blog

Tuesday, June 30, 2009

Python Read Html with "urllib" module

Update: use urllib2. Very good design and comes with standard Python. Support header, data, etc...
more examples, here.

Read Google's home page with Python in 3 lines.

import urllib
html = urllib.urlopen("http://www.google.com")
print html.readlines() #read the pages

Read more on stackoverflow regarding httplib, urllib, urllib2
http://stackoverflow.com/questions/301924/python-urllib-urllib2-httplib-confusion

Bleeding edge httplib2 module (not standard)
http://code.google.com/p/httplib2/

No comments: