错误:
Max retries exceeded with url
Failed to establish a new connection
原因:请求过多;访问次数频繁,被禁止访问。
connection默认是keep-alive的。
解决方法:
一、
s = requests.session()
s.keep_alive = False
二、
增加重试连接次数
requests.adapters.DEFAULT_RETRIES = 5
三、
headers={'Connection':'close'}
四、
sleep一下
五、
添加代理
proxies={'http': '1.1.1.1'}
选择一种适合自己场景的
https://stackoverflow.com/questions/23013220/max-retries-exceeded-with-url
https://blog.youkuaiyun.com/weixin_40539892/article/details/79391201
https://www.jianshu.com/p/442cb3efe347