urllib2, proxy, basic authentication

Albert Chin-A-Young china at usenet.com
Wed Dec 6 21:41:36 EST 2000


matthewrussell at my-deja.com wrote:
> A way to pass authentication details would be to specify them in the
> url as follows

> import urllib2

> urllib2.urlopen("http://username:password@www.mydomain.com")

Tried that and it does not work. I get:
ValueError: invalid literal for int(): [password]@[domain]

> In article <90k859$adl$1 at bob.news.rcn.net>,
>   Albert Chin-A-Young <china at the.web.com> wrote:
>> Jeremy Lamplough <jeremy.lamplough at motorola.com> wrote:
>> > try setting the proxy host prior to importing the other modules.
>>
>> > import os, sys
>> > os.environ['http_proxy'] = 'http://[PROXY_HOST]:5865'
>> > import urllib2
>> > from urllib2 import urlopen
>>
>> > The way i'm doing basic stuff, with NO authentication is (to
> download a
>> > stock quote)
>>
>> We don't have a problem with http_proxy and the remote host not
>> requiring authentication. However, if the remote host does require
>> authentication, then we have our problem.
>>
>> --
>> albert chin (china @at@ thewrittenword .dot. com)

-- 
albert chin (china @at@ thewrittenword .dot. com)



More information about the Python-list mailing list