htaccess & urllib
John J. Lee
jjl at pobox.com
Wed Jul 23 12:28:14 EDT 2003
"Max Khesin" <max at cNOvSisiPonAtecMh.com> writes:
> Is there a way to access an htaccess-protected directory with urllib,
> password being known?
urllib2 is better than urllib.
>From the urllib2 module docstring, cut down a bit (and assuming you
mean basic HTTP authentication -- HTTPDigestAuthHandler might also be
of use to you):
import urllib2
authinfo = urllib2.HTTPBasicAuthHandler()
authinfo.add_password('realm', 'host', 'username', 'password')
opener = urllib2.build_opener(authinfo)
f = opener.open('http://www.python.org/')
print f.info() # response headers
print f.read() # response body
John
More information about the Python-list
mailing list