473,602 Members | 2,751 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

urllib.urlopen

Hello,
I'm trying to use the urllib module, but when i try urllib.urlopen, it
gives me a socket error:
import urllib
print urllib.urlopen( 'http://www.google.com/').read()

Traceback (most recent call last):
File "<input>", line 1, in ?
File "C:\Python24\li b\urllib.py", line 77, in urlopen
return opener.open(url )
File "C:\Python24\li b\urllib.py", line 180, in open
return getattr(self, name)(url)
File "C:\Python24\li b\urllib.py", line 296, in open_http
h.endheaders()
File "C:\Python24\li b\httplib.py", line 794, in endheaders
self._send_outp ut()
File "C:\Python24\li b\httplib.py", line 675, in _send_output
self.send(msg)
File "C:\Python24\li b\httplib.py", line 642, in send
self.connect()
File "C:\Python24\li b\httplib.py", line 610, in connect
socket.SOCK_STR EAM):
IOError: [Errno socket error] (11001, 'getaddrinfo failed')

Any ideas on what i did wrong?

Dec 17 '05 #1
6 14516
JabaPyth wrote:
Hello,
I'm trying to use the urllib module, but when i try urllib.urlopen, it
gives me a socket error:
>>import urllib
>>print urllib.urlopen( 'http://www.google.com/').read()

Traceback (most recent call last):
File "<input>", line 1, in ?
File "C:\Python24\li b\urllib.py", line 77, in urlopen
return opener.open(url )
File "C:\Python24\li b\urllib.py", line 180, in open
return getattr(self, name)(url)
File "C:\Python24\li b\urllib.py", line 296, in open_http
h.endheaders()
File "C:\Python24\li b\httplib.py", line 794, in endheaders
self._send_outp ut()
File "C:\Python24\li b\httplib.py", line 675, in _send_output
self.send(msg)
File "C:\Python24\li b\httplib.py", line 642, in send
self.connect()
File "C:\Python24\li b\httplib.py", line 610, in connect
socket.SOCK_STR EAM):
IOError: [Errno socket error] (11001, 'getaddrinfo failed')

Any ideas on what i did wrong?

Works for me, do you have a proxy or some strange setup for accessing to
the web?

Try using the urllib2 module, too.
Dec 17 '05 #2
I tried using urllib2 and this is what i got:
import urllib2
the_url = 'http://www.google.com'
req = urllib2.Request (the_url)
handle = urllib2.urlopen (req)

Traceback (most recent call last):
File "<input>", line 1, in ?
File "C:\Python24\li b\urllib2.py", line 130, in urlopen
return _opener.open(ur l, data)
File "C:\Python24\li b\urllib2.py", line 358, in open
response = self._open(req, data)
File "C:\Python24\li b\urllib2.py", line 376, in _open
'_open', req)
File "C:\Python24\li b\urllib2.py", line 337, in _call_chain
result = func(*args)
File "C:\Python24\li b\urllib2.py", line 1021, in http_open
return self.do_open(ht tplib.HTTPConne ction, req)
File "C:\Python24\li b\urllib2.py", line 996, in do_open
raise URLError(err)
URLError: <urlopen error (11001, 'getaddrinfo failed')>

Dec 18 '05 #3
Jay
Easy Fix...

import urllib
the_url = "http://www.google.com"
req = urllib.urlopen( the_url)

Does this work for you??

Dec 18 '05 #4

Jay wrote:
Easy Fix...

import urllib
the_url = "http://www.google.com"
req = urllib.urlopen( the_url)

Does this work for you??


This does look like proxie /firewall issue, try it from an internet
cafe. Also depending on the site, you may have to set User-Agnet
and/or referer headers. And definitely respect robots.txt, throttle
back requests to seom finite (human-scale) volume and save them to your
hard drive (mistakes i've made)

Dec 18 '05 #5
Thanks, guys.
I tried on a different computer, and it worked fine.I then found out
that my computer thyought i had a proxy server, and after i cleaned
that up, it worked.
Thanks again

Dec 18 '05 #6
On Sat, 17 Dec 2005, Dennis Lee Bieber wrote:
(Now there is an interesting technical term:
#define ERROR_ARENA_TRA SHED 7)


FreeBSD at one point had an EDOOFUS; Apple kvetched about this being
offensive, so it was changed to EDONTPANIC.

I shitteth thee not.

tom

--
information distribution, vox humana, deviation, handle, feed, l.g. **
Dec 19 '05 #7

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

Similar topics

4
3982
by: Richard Shea | last post by:
Hi - I'm new to Python. I've been trying to use URLLIB and the 'tidy' function (part of the mx.tidy package). There's one thing I'm having real difficulties understanding. When I did this ... finA= urllib.urlopen('http://www.python.org/') foutA=open('C:\\testout.html','w') tidy(finA,foutA,None) I get ...
11
5037
by: Pater Maximus | last post by:
I am trying to implement the recipe listed at http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/211886 However, I can not get to first base. When I try to run import urllib fo=urllib.urlopen("http://www.dictionary.com/") page = fo.read() I get:
0
3577
by: Pieter Edelman | last post by:
Hi all, I'm trying to submit some data using a POST request to a HTTP server with BASIC authentication with python, but I can't get it to work. Since it's driving me completely nuts, so here's my cry for help. The server is an elog logbook server (http://midas.psi.ch/elog/). It is protected with a password and an empty username. I can login both using urllib and urllib2 (suppose the password is "foobar", the logbook is running on port...
1
2063
by: Timothy Wu | last post by:
Hi, I'm trying to fill the form on page http://www.cbs.dtu.dk/services/TMHMM/ using urllib. There are two peculiarities. First of all, I am filling in incorrect key/value pairs in the parameters on purpose because that's the only way I can get it to work.. For "version" I am suppose to leave it unchecked, having value of empty string. And for name "outform" I am suppose to assign it a value of "-short". Instead, I left out
4
3583
by: william | last post by:
I've got a strange problem on windows (not very familiar with that OS). I can ping a host, but cannot get it via urllib (see here under). I can even telnet the host on port 80. Thus network seems good, but not for python ;-(. Does any windows specialist can guide me (a poor linux user) to get Network functionalitiies with python on windows ?
0
2440
by: Ali.Sabil | last post by:
hello all, I just maybe hit a bug in both urllib and urllib2, actually urllib doesn't support proxy authentication, and if you setup the http_proxy env var to http_proxy=http://user:passwd@host:port/ and https_proxy=$http_proxy i get a traceback : Traceback (most recent call last): File "test_urllib.py", line 2, in ? urllib.urlopen("https://sf.net/")
4
9337
by: kgrafals | last post by:
Hi, I'm just trying to read from a webpage with urllib but I'm getting IOErrors. This is my code: import urllib sock = urllib.urlopen("http://www.google.com/") and this is the error:
1
2083
by: John Nagle | last post by:
If you try to open a password protected page with "urllib.urlopen()", you get "Enter username for EnterPassword at example.com:" on standard output, followed by a read for input! This seems to be an undocumented feature, if not a bug. Definitely the documentation for "urllib" should mention this. The effects of this in a CGI program are not good. A workaround is described here: "http://cis.poly.edu/cs912/urlopen.txt"
0
1338
by: gmguyx | last post by:
I tried using urllib.urlopen to open a personalized webpage (my.yahoo.com) but it doesn't work: print urllib.urlopen(http://my.yahoo.com).read() Instead of returning my.yahoo.com, it returns a page asking me to log in. So then I tried urllib.urlencode:
0
7993
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
8054
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
6730
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5867
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5440
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3900
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1510
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1254
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.