URLLIB2 problems

Anthony_Barker anthony_barker at hotmail.com
Wed Feb 13 10:42:41 EST 2002


I am still having problems getting through the proxy, I tried another method

 
import urllib2
 
# set up authentication info
authinfo = urllib2.HTTPBasicAuthHandler()
authinfo.add_password('realm', 'host', 'username', 'password')
#wasn't quite sure which realm it was so I just selected the server name
 
proxy_support = urllib2.ProxyHandler({"http" : "http://spamandeggs:8080"})
 
# build a new opener that adds authentication 
opener = urllib2.build_opener(proxy_support, authinfo)
 
# install it
urllib2.install_opener(opener)
 
f = urllib2.urlopen('http://www.python.org/')

...........fails with same network 101 error



anthony_barker at hotmail.com (Anthony_Barker) wrote in message news:<899f842.0202121213.603e6617 at posting.google.com>...
> I am having problems with python and our company's proxy server, which
> requires  authentication.
> 
> here is the code I am using:
> 
> import urllib2 
> proxy = urllib2.ProxyHandler({"http":"http://myname:mypass@proxyserver.company.com:8080/"})
> opener = urllib2.build_opener(proxy) 
> f = urllib2.urlopen('http://www.python.org') 
> 
> results
> Traceback (most recent call last):
>   File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.2/urllib2.py", line 138, in urlopen
>     return _opener.open(url, data)
>   File "/usr/lib/python2.2/urllib2.py", line 322, in open
>     '_open', req)
>   File "/usr/lib/python2.2/urllib2.py", line 301, in _call_chain
>     result = func(*args)
>   Fil

e "/usr/lib/python2.2/urllib2.py", line 785, in http_open
>     return self.do_open(httplib.HTTP, req)
>   File "/usr/lib/python2.2/urllib2.py", line 763, in do_open
>     raise URLError(err)
> urllib2.URLError: <urlopen error (101, 'Network is unreachable')>
> 
> Under windows error is the same except for the last line (and line
> numbers)
> URLError: <urlopen error (10051, 'Network is unreachable')>
> 
> Both perl and wget work. wget only supports Basic Authentication, so I
> assume it is the same. Thinking it might be a network type issue I
> changed the domain names to IP addresses. (results follow)
> 
> Any help would be appreciated................
> 
> File "<stdin>", line 1, in ?
>   File "/usr/lib/python2.2/urllib2.py", line 138, in urlopen
>     return _opener.open(url, data)
>   File "/usr/lib/python2.2/urllib2.py", line 322, in open
>     '_open', req)
>   File "/usr/lib/python2.2/urllib2.py", line 301, in _call_chain
>     result = func(*args)
>   File "/usr/lib/python2.2/urllib2.py", line 785, in http_open
>     return self.do_open(httplib.HTTP, req)
>   File "/usr/lib/python2.2/urllib2.py", line 763, in do_open
>     raise URLError(err)
> urllib2.URLError: <urlopen error (111, 'Connection refused')>



More information about the Python-list mailing list