Problem with urllib2 and authentification
Rob Wolfe
rw at smsnet.pl
Tue Apr 22 14:24:12 EDT 2008
"Miguel Beltran R." <yourpadre at gmail.com> writes:
> Using this script for connect to Zope I have this error
You forgot to add the authentication handler to the list of handlers.
See below.
>
> ---script:
> import urllib2
>
> protocolo='http://'
> servidor='10.28.1.239/'
> pagina='manage'
> fullurl=protocolo+servidor+pagina
>
> aut=urllib2.HTTPBasicAuthHandler()
> aut.add_password(realm=None,
> uri=servidor,
> user='myadmin',
> passwd='mypass')
> opener=urllib2.build_opener(aut, urllib2.HTTPHandler(debuglevel=1))
Add here:
opener.add_handler(aut))
> print opener.open(fullurl).read()
HTH,
Rob
More information about the Python-list
mailing list