urllib with user/password

Steve Holden sholden at holdenweb.com
Sat Apr 7 17:52:29 EDT 2001


"Gilles Lenfant" <glenfant.nospam at bigfoot.com> wrote in message
news:9ao1v9$2tot$1 at news5.isdnet.net...
> Hi,
>
> I got a robot that fetches with urllib.urlopen() a user/password protected
> page.
> As some URLs reply with code 401 (basic authentication), I'm prompted for
> the user/password.
>
> Is there a workaround for storing the user/password in the script and go
> through the request without prompting ?
>
> Thanks in advance
>
One fairly simple way would be to use a URL of the form

    http://user:password@host/path/file.ext

which will, of course, send the password and username in clear over the net.
Since basic authentication doesn't do much better (simply encoding
user:password in base64) this may not be a problem.

Hope this helps.

regards
 Steve








More information about the Python-list mailing list