httplib.InvalidURL: nonnumeric port: For characters intheproxypassword in URL

Phoe6 orsenthil at gmail.com
Mon Nov 13 10:25:57 EST 2006


Fredrik Lundh wrote:
>
> can you post the code you're using to build the URI ?
>
Okay. This piece of code fetches a page from a particular site. As I am
behind a firewall, I have to communicate through a proxy.

# Set the Proxy Address
PROXY_IP = "10.1.9.4:80"

# Trying with linear way

proxy_user = 'user_name'
proxy_password_orig='|\/|pc'
proxy_password = urllib.quote(proxy_password_orig)

#proxy_password = r'|\/|pr0c'

# 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)

# Read the ngsite
tdate = str(datetime.date.today())
sepdate = re.compile('\d\d(\d\d)-(\d+)-(\d+)')

year = sepdate.match(tdate).group(1)
month = sepdate.match(tdate).group(2)
day = sepdate.match(tdate).group(3)

site =
r"http://lava.nationalgeographic.com/cgi-bin/pod/wallpaper.cgi?day=" +
day + "&month=" + month + "&year=" + year
print site
data = urllib2.urlopen(site)

-- 
Senthil




More information about the Python-list mailing list