http authentication

Steve Holden sholden at holdenweb.com
Mon Jan 15 12:16:40 EST 2001


<huthut at my-deja.com> wrote in message news:93qsjl$c6o$1 at nnrp1.deja.com...
> Please forgive my, probably, very naive question.
> Im trying to hack togethe ra script that will download a number of
> files off a internet site. The only problem is that this site is
> password protected (in IE a box pops up for username and password). So
> first i tried the urllib.FancyURLopener.open(url) which prompted me for
> a username but then froze. Then i tried .open
> ('http://user:password@www.somewhere.com') but then i got:
>
> File "c:\python20\lib\urllib.py", line 513, in __init__
>     apply(URLopener.__init__, (self,) + args)
>   File "c:\python20\lib\urllib.py", line 91, in __init__
>     assert hasattr(proxies, 'has_key'), "proxies must be a mapping"
> AssertionError: proxies must be a mapping
>
> Does anyone have any suggestions?
>
> Thanks in advance

Best approach would probably be to include the Basic authentication headers
in the request you send to the server, using httplib.putheader().

regards
 Steve





More information about the Python-list mailing list