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

Phoe6 orsenthil at gmail.com
Mon Nov 13 07:00:32 EST 2006


Fredrik Lundh wrote:
> Phoe6 wrote:
> > 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.
>
> if you want to prevent the URI parser from treating something as part of
> the URI, you need to quote it:
>
>     pwd = urllib.quote(pwd, "")

Tried this and did not work out. It ended up confusing urllib and
urllib2 objects.
I dont want to import urllib, with the urllib2 itself wanted to work
around this piece of code.

<code>
proxy_user = r'senthil_or'
proxy_password='|\/|pr0c'
#proxy_password = r'|\/|pr0c'

# Setup the Proxy with urllib2

proxy_url = r'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>

Thanks,
Senthil




More information about the Python-list mailing list