Web authentication
Luigi
luigipaioro at libero.it
Fri Dec 5 09:59:54 EST 2003
Thak you...
I've tried to follow yours suggestions, but I cannot solve my trouble
yet!
These are my attempts:
def open_site1():
import urllib2
auth_handler = urllib2.HTTPBasicAuthHandler()
auth_handler.add_password('My realm', 'http://mysite.com/',
'user', 'password')
opener = urllib2.build_opener(auth_handler)
urllib2.install_opener(opener)
site = urllib2.urlopen('http://mysite.com/')
print site.read()
def open_site2():
import urllib
class Open_with_auth(urllib.FancyURLopener):
def prompt_user_passwd(self, host, realm):
return ('user', 'password')
urllib._urlopener = Open_with_auth()
conn = urllib.urlopen('http://mysite.com')
print conn.read()
Both don't work!
Where is my mistake??
Luigi
More information about the Python-list
mailing list