问题描述:
python爬虫异常报错:requests.exceptions.ConnectionError
解决方法:
对于这个错误,stackoverflow给出的解释是
In the event of a network problem (e.g. DNS failure, refused connection, etc), Requests will raise a ConnectionError exception.
翻译过来就是说这是网络问题出现的异常事件(如DNS错误,拒绝连接,等等),这是Requests库中自带的异常
一种解决办法是捕捉基类异常,这种方法可以处理所有的异常情况:
try:
r = requests.get(url, params={’s’: thing})
except requests.exceptions.RequestException as e: # This is the correct syntax
print e
sys.exit(1)
另外一种解决办法是分别处理各种异常,这里面有三种异常:
try:
r = requests.get(url, params={’s’: thing})
except requests.exceptions.Timeout:
except requests.exceptions.TooManyRedirects:
except requests.exceptions.RequestException as e:
print e
sys.exit(1)
三个资料Q群下载不了也转发不了,先放这里Fine_tuning.zipLangChain.zipdata_clear.rar