October 6th, 2005, 01:53 PM
Read website: HTTPBasicAuthHandle
I found this on the internet. But how do i read te website witch i opened. In other words: How to print the source of this protected page?
password_mgr = urllib2.HTTPPasswordMgrWithDefaultRealm()
# create a password manager
# add the username and password
# if we knew the realm, we could
# use it instead of ``None``
handler = urllib2.HTTPBasicAuthHandler(password_mgr)
# create the handler
opener = urllib2.build_opener(handler)
# from handler to opener
# use the opener to fetch a URL
# install the opener
# now all calls to urllib2.urlopen use our opener
October 6th, 2005, 03:00 PM
foo = urllib2.urlopen('http://url.to.open/')
data = foo.read()
# Do something here with data.
Up the Irons
What Would Jimi Do? Smash amps. Burn guitar. Take the groupies home.
"Death Before Dishonour, my Friends!!" - Bruce D ickinson, Iron Maiden Aug 20, 2005 @ OzzFest
Down with Sharon Osbourne
"I wouldn't hire a butcher to fix my car. I also wouldn't hire a marketing firm to build my website." - Nilpo