Python Max retries exceeded with

2020-12-29  本文已影响0人  王国的荣耀

使用requests爬取报错“Max retries exceeded with url“的解决方法

爬虫在使用代理的过程中,出现了以下的连接错误。

requests.exceptions.ProxyError:
HTTPSConnectionPool(host=‘xxx.xxx.xxx’, port=443):
Max retries exceeded with url: xxxxxxx (Caused by ProxyError
(‘Cannot connect to proxy.’,

解决方法

  1. 使用session实现会话的保持: session = requests.session()
  2. 增加重试连接次数: requests.DEFAULT_RETRIES = 5
  3. 关闭多余的连接: session.keep_alive = False

pip 安装,更新模块

moudle_name:是对应的模块名;请自行更换为自己需要更新的模块名

查看所有可更新的模块:  pip list --outdated
更新某一个模块:     pip install --upgrade module_name
指定更新源更新模块    pip install --upgrade -i https://pypi.douban.com/simple

moudle_name
安装对应的模块:     pip install pip-review
更新所有的模块:      pip-review --local --interactive

上一篇 下一篇

猜你喜欢

热点阅读