httplib.InvalidURL: nonnumeric port: For characters in the proxy password in URL

Phoe6 orsenthil at gmail.com
Mon Nov 13 03:56:51 EST 2006


Hi,
     The following piece of code works properly when my proxy password
contains characters[a-zA-Z0-9] etc. But when my proxy password
contained something like '|\/|' , the httplib incorrectly indentified
it as separator. How do I resolve this issue.

<code>
# Proxy Address
PROXY_IP = "1.1.9.8:80"

# Trying with linear way

proxy_user = 'user_name'
proxy_password='|\/|something'

# Setup the Proxy with urllib2

proxy_url = 'http://' + proxy_user + ':' + proxy_password + '@' +
PROXY_IP
proxy_support = urllib2.ProxyHandler({"http":proxy_url})
opener = urllib2.build_opener(proxy_support,urllib2.HTTPHandler)
urllib2.install_opener(opener)

</code>

I get the Error:

Traceback (most recent call last):
  File "C:\Python24\forge\ngwallp\ngwall.py", line 35, in ?
    data = urllib2.urlopen(site)
  File "C:\Python24\lib\urllib2.py", line 130, in urlopen
    return _opener.open(url, data)
  File "C:\Python24\lib\urllib2.py", line 358, in open
    response = self._open(req, data)
  File "C:\Python24\lib\urllib2.py", line 376, in _open
    '_open', req)
  File "C:\Python24\lib\urllib2.py", line 337, in _call_chain
    result = func(*args)
  File "C:\Python24\lib\urllib2.py", line 1021, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "C:\Python24\lib\urllib2.py", line 980, in do_open
    h = http_class(host) # will parse host:port
  File "C:\Python24\lib\httplib.py", line 586, in __init__
    self._set_hostport(host, port)
  File "C:\Python24\lib\httplib.py", line 598, in _set_hostport
    raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: '|\'


Thanks,
Senthil




More information about the Python-list mailing list