472,960 Members | 1,807 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,960 software developers and data experts.

urllib2.URLError: <urlopen error (7, 'getaddrinfo failed')> when trying to connect through a proxy

I'm trying to get the HTML data off of a webpage. Let's say for the
sake of argument it's the python homepage. I've googled around and
found some examples that people said worked. Here's what I've cobbled

import urllib
import urllib2
proxy_info = {'user':'us3r',
os.environ['HTTP_PROXY'] =
'http://%(user)s:%(password)s@%(host)s:%(port)s' % proxy_info
test_url = "http://www.python.org/index.html"
handle = urllib2.urlopen(test_url)
#handle = urllib.urlopen(test_url)
txt = handle.read().lower()
print "Text: "
print txt
#end getHTML.py

When I run this with urllib2 I get (with or without a dummy password):
Traceback (most recent call last):
File "P:\My Documents\Projects\Python\validate_zipcodes.py", line
103, in ?
handle = urllib2.urlopen(test_url)
File "C:\Python23\lib\urllib2.py", line 129, in urlopen
return _opener.open(url, data)
File "C:\Python23\lib\urllib2.py", line 326, in open
'_open', req)
File "C:\Python23\lib\urllib2.py", line 306, in _call_chain
result = func(*args)
File "C:\Python23\lib\urllib2.py", line 901, in http_open
return self.do_open(httplib.HTTP, req)
File "C:\Python23\lib\urllib2.py", line 886, in do_open
raise URLError(err)
urllib2.URLError: <urlopen error (7, 'getaddrinfo failed')>

When I run it with urllib.urlopen, I get:
Traceback (most recent call last):
File "P:\My Documents\Projects\Python\validate_zipcodes.py", line
104, in ?
handle = urllib.urlopen(test_url)
File "C:\Python23\lib\urllib.py", line 76, in urlopen
return opener.open(url)
File "C:\Python23\lib\urllib.py", line 181, in open
return getattr(self, name)(url)
File "C:\Python23\lib\urllib.py", line 287, in open_http
h = httplib.HTTP(host)
File "C:\Python23\lib\httplib.py", line 1009, in __init__
self._setup(self._connection_class(host, port, strict))
File "C:\Python23\lib\httplib.py", line 507, in __init__
self._set_hostport(host, port)
File "C:\Python23\lib\httplib.py", line 518, in _set_hostport
raise InvalidURL("nonnumeric port: '%s'" % host[i+1:])
httplib.InvalidURL: nonnumeric port: 'p@ssword@MY_PROXY:80'

Obviously, going through Internet Explorer works.

Has anyone else had a similar issue? I don't know the proxy situation
we have here, so is it possible that the proxy is causing this?

Any help is much appreciated.

Thanks for at least reading this far!

Jul 18 '05 #1
0 4852

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

by: John F Dutcher | last post by:
Can anyone comment on why the code shown in the Python error is in some way incorrect...or is there a problem with Python on my hoster's site ?? The highlites don't seem to show here...but line...
by: MLH | last post by:
In Access 97, I run the following command... DBEngine.CompactDatabase FullPathNfilename, "c:\MyDir\tocodata.sys", DB_LANG_GENERAL Error 3356 "You attempted to open a dtaabase that is already...
by: יוני גולדברג | last post by:
Hi, While trying to create new directory i recieve the following error message: "System.IO.DirectoryNotFoundException: Could not find a part of the path "\\premfs16\sites". The path exists, even...
by: Ju Hui | last post by:
I wanna use urllib2 to get a page with a socks 5 proxy,who can give me a sample code ? example, the proxy server is : and the port is :1080 and the username/password is :...
by: chris | last post by:
Hi, I am trying to upload files on FTP and used the code below: Dim request As FtpWebRequest request = WebRequest.Create("ftp://ftp...../test.txt") request.Method =...
by: =?Utf-8?B?VGVycmFuY2U=?= | last post by:
I have an application that runs fine on my machine(of course) that access the local Sql Server. However, when trying to run this application from another machine I receive a Sql timeout error. I...
by: Arif Mohammed | last post by:
Hi, iam using MySql 4.0.1 and jboss-4.0.4.GA Iam getting the following exception when there are more concurrent requests more than 50 in a second Caused by: org.xyz.MyClass: SQL...
by: Jinshi | last post by:
Hello, everyone, I am quite new to python and I don't know how to solve this problem. I hope someone can help me. I just did a test in python shell: Traceback (most recent call last): File...
by: silk.odyssey | last post by:
I am getting the following error trying to download an html page using urllib2. urllib2.HTTPError: HTTP Error 204: NoContent The url is of this type: ...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: giovanniandrean | last post by:
The energy model is structured as follows and uses excel sheets to give input data: 1-Utility.py contains all the functions needed to calculate the variables and other minor things (mentions...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.