urllib2.urlopen('ur') gives error

夙愿已清 提交于 2019-12-24 19:51:15

问题


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)

Any solutions to this ?


回答1:


that error message occurs if your net is offline



来源:https://stackoverflow.com/questions/6225746/urllib2-urlopenur-gives-error

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!