Friday, February 16, 2007

How to grab a page using urllib2

I got this from It's easy. The next step is to learn basic authentication so I can get to my bank site and download my bank statements automatically.
import urllib2

response = urllib2.urlopen('')
html =

print html

1 comment:

sofeng said...

Anonymous said...

Nice, thanks.
But what if I want the web site this "visits" to recognize that I have a certain cookie on my system so that it knows I was there?
2/09/2007 5:11 AM
So Feng said...

You should use Mechanize which has cookie handling. See my later post for more information about Mechanize.
2/15/2007 7:45 PM