Jonas Galvez <[EMAIL PROTECTED]> writes: > Christopher J. wrote: > > I tried this, but it didn't work: > > conn.request("GET", "/somepage.html", None, > > {"AUTHORIZATION": "Basic username:password"}) [...] > import re, base64, urllib2 > > userpass = ('user', 'pass') > url = 'http://somewhere' > > request = urllib2.Request(url) > authstring = base64.encodestring('%s:%s' % userpass) > authstring = authstring.replace('\n', '') > request.add_header("Authorization", "Basic %s" % authstring) > > content = urllib2.urlopen(request).read()
There are handlers in urllib2 to do this for you, you shouldn't need to do it by hand. I rarely do, so I won't risk an example... John -- http://mail.python.org/mailman/listinfo/python-list