# coding=UTF-8
from urllib import request,error
try:
response = request.urlopen('http://cuiqingcai.com/index.html')
except error.URLError as e:
print(e.reason)
print(e.reason)
try:
response = request.urlopen('http://cuiqingcai.com/index.html')
except error.HTTPError as e:
print(e.reason,e.code,e.headers,sep='\n')
except error.URLError as e:
print(e.reason)
else :
print('Request Successfully')
try:
urllib.request.urlopen('http://httpbin.org/get', timeout=0.1)
except urllib.error.URLError as e:
if isinstance(e.reason, socket.timeout):
print('TIME OUT!!!')
python爬虫异常的处理方式
最新推荐文章于 2021-12-30 18:46:50 发布