目录
3.IndexError: list index out of range
1.连接错误
ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
翻译为:
连接错误:(“连接已中止。”,RemoteDisconnected(“远程结束关闭的连接而无响应”))
原因(参考链接):
1.1在header中不使用持久连接:
有什么用?学习下别人网址:http://t.csdnimg.cn/Yeb5T HTTP 头 Connection:close 作用 - liluxiang - 博客园 (cnblogs.com)
'Connection': 'close'
1.2建代理池学习网址:http://t.csdnimg.cn/QbgKa
2.连接超时
读取超时是没有默认值的,如果不设置,程序将一直处于等待状态。我们的爬虫经常卡死又没有任何的报错信息,原因就在这里了。
参考解决网址:http://t.csdnimg.cn/L9piG
3.IndexError: list index out of range
出现 IndexError: list index out of range 原因:
将错误网址从爬一次找原因:
打印状态码
print('相应状态码为:',response.status_code)
结果: 相应状态码为: 200
print(response.text)
响应结果: {"ip":"240e:335:240d:2610:2df3:f613:d79c:ff90","addresses":[],"type_id":11}
原因是:返回结果list是空的,没有一个元素