urllib2.urlopen('ur') 给出错误 [英] urllib2.urlopen('ur') gives error

查看:46
本文介绍了urllib2.urlopen('ur') 给出错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Python 新手,正在尝试提取页面的内容.当我执行 urlopen('http://www.google.com') 时,出现以下错误:

I am new to python and trying to extract the contents of a page. When I do urlopen('http://www.google.com'), I get the following error :

File "<stdin>", line 1, in <module>    
  File "/usr/lib/python2.7/urllib2.py", line 126, in urlopen
    return _opener.open(url, data, timeout)
  File "/usr/lib/python2.7/urllib2.py", line 391, in open
    response = self._open(req, data)
  File "/usr/lib/python2.7/urllib2.py", line 409, in _open
    '_open', req)
  File "/usr/lib/python2.7/urllib2.py", line 369, in _call_chain
    result = func(*args)
  File "/usr/lib/python2.7/urllib2.py", line 1185, in http_open
    return self.do_open(httplib.HTTPConnection, req)
  File "/usr/lib/python2.7/urllib2.py", line 1160, in do_open
    raise URLError(err)

有什么解决办法吗?

推荐答案

如果您的网络处于脱机状态,则会出现该错误消息

that error message occurs if your net is offline

这篇关于urllib2.urlopen('ur') 给出错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆