python爬虫异常处理

import urllib2


try:
    response = urllib2.urlopen('http://www.baidu.com')
except urllib2.URLError, e:
    print e.reason

print response.read()
原文地址:https://www.cnblogs.com/norm/p/7421813.html