Skip to content
This repository was archived by the owner on Jul 1, 2022. It is now read-only.
This repository was archived by the owner on Jul 1, 2022. It is now read-only.

没有对 urllib2.urlopen 进行异常捕获 #2

Open

Description

@MyKings
$ python brodomain.py www.ly.com

[*] Init..
[*] Query Email..
[*] Query Beian Code..
Traceback (most recent call last):
  File "brodomain.py", line 204, in <module>
    query.GetDomainBybeian()
  File "brodomain.py", line 63, in GetDomainBybeian
    data = urllib2.urlopen(url).read()
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 154, in urlopen
    return opener.open(url, data, timeout)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 437, in open
    response = meth(req, response)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 550, in http_response
    'http', request, response, code, msg, hdrs)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 475, in error
    return self._call_chain(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 409, in _call_chain
    result = func(*args)
  File "/System/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/urllib2.py", line 558, in http_error_default
    raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
urllib2.HTTPError: HTTP Error 404: Not Found

可以考虑使用 requests 或者对 urllib2 更好的二次封装下 :)

Activity

  1. code-scan commented on Jan 2, 2016

    @code-scan
    Owner

    因为我之前把一个接口文章从webserver移除了,所以导致了这个异常,一会加上捕获异常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions