本文介绍了无法让urllib.urlopen工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我正在尝试实施中列出的配方 http://aspn.activestate.com/ASPN/Coo.../Recipe/211886 但是,我无法进入一垒。当我试图运行时 import urllib fo = urllib.urlopen(" http://www.dictionary.com/") page = fo.read() 我得到: Traceback(最近一次调用最后一次): 文件" C:/ Program Files / Python / Lib / idlelib / testurl",第2行,在-toplevel- fo = urllib.urlopen(" http:/ /www.dictionary.com/") 文件" C:\ PROGRA~1 \ PYTHON \lib \ urllib.py",第76行,在urlopen中 返回opener.open(url) 文件" C:\ PROGRA~1 \ PYTHON \lib \urllib.py",第181行,打开 返回getattr(self,name)(url) 文件" C:\ PROGRA~1 \ PYTHON \lib \urllib.py",第297行,in open_http h.endheaders() 文件" C:\ PROGRA~1 \ PYTHON \lib \ httplib.py",第712行,在endheaders中 self._send_output() 文件" C:\ PROGRA~1 \ PYTHON \lib \\ _httplib.py",第597行,在_send_output中 self.send(msg) 文件" C:\ PROGRA~1 \ PYTHON \lib \\ httplib.py",第564行,发送 self.connect() 文件C:\ PROGRA~1 \ PYTHON \lib \ httplib.py",第548行,在连接中 引发socket.error,msg IOError:[Errno socket error](10061,''Connection refused'')I am trying to implement the recipe listed at http://aspn.activestate.com/ASPN/Coo.../Recipe/211886However, I can not get to first base. When I try to runimport urllibfo=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 urlopenreturn opener.open(url)File "C:\PROGRA~1\PYTHON\lib\urllib.py", line 181, in openreturn getattr(self, name)(url)File "C:\PROGRA~1\PYTHON\lib\urllib.py", line 297, in open_httph.endheaders()File "C:\PROGRA~1\PYTHON\lib\httplib.py", line 712, in endheadersself._send_output()File "C:\PROGRA~1\PYTHON\lib\httplib.py", line 597, in _send_outputself.send(msg)File "C:\PROGRA~1\PYTHON\lib\httplib.py", line 564, in sendself.connect()File "C:\PROGRA~1\PYTHON\lib\httplib.py", line 548, in connectraise socket.error, msgIOError: [Errno socket error] (10061, ''Connection refused'')推荐答案 你有没有理由认为这个网站目前是 托管网络服务器? 尝试在端口80上连接IE或Telnet结果 a类似的回复。 (在发布关于 服务器问题之前,Telnet始终是一件好事。 。) -PeterDo you have any reason to think that this site is currentlyhosting a web server?Attempting to connect with IE or Telnet on port 80 results ina similar response.(Telnet is always a good thing to try, before posting aboutserver problems...)-Peter 我的浏览器说同样的话。 ;-) Alan IsaacMy browser says the same thing. ;-)Alan Isaac 这篇关于无法让urllib.urlopen工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-01 16:15