Can not get urllib.urlopen to work

Steve Holden steve at holdenweb.com
Thu Oct 28 06:45:33 CEST 2004


Pater Maximus wrote:

> 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:
> 
> Traceback (most recent call last):
>   File "C:/Program Files/Python/Lib/idlelib/testurl", line 2, in -toplevel-
>     fo=urllib.urlopen("http://www.dictionary.com/")
>   File "C:\PROGRA~1\PYTHON\lib\urllib.py", line 76, in urlopen
>     return opener.open(url)
>   File "C:\PROGRA~1\PYTHON\lib\urllib.py", line 181, in open
>     return getattr(self, name)(url)
>   File "C:\PROGRA~1\PYTHON\lib\urllib.py", line 297, in open_http
>     h.endheaders()
>   File "C:\PROGRA~1\PYTHON\lib\httplib.py", line 712, in endheaders
>     self._send_output()
>   File "C:\PROGRA~1\PYTHON\lib\httplib.py", line 597, in _send_output
>     self.send(msg)
>   File "C:\PROGRA~1\PYTHON\lib\httplib.py", line 564, in send
>     self.connect()
>   File "C:\PROGRA~1\PYTHON\lib\httplib.py", line 548, in connect
>     raise socket.error, msg
> IOError: [Errno socket error] (10061, 'Connection refused')
> 
> 
Suspect the action of a firewall or just assume you were unlucky and the 
server was down when you hit it. I had no problem just now:

$ python
Python 2.3.4 (#1, Jun 13 2004, 11:21:03)
[GCC 3.3.1 (cygming special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
 >>> import urllib
 >>> fo=urllib.urlopen("http://www.dictionary.com/")
 >>> page = fo.read()
 >>>

regards
  Steve
-- 
http://www.holdenweb.com
http://pydish.holdenweb.com
Holden Web LLC +1 800 494 3119



More information about the Python-list mailing list