美文网首页
Python Max retries exceeded with

Python Max retries exceeded with

作者: 王国的荣耀 | 来源:发表于2020-12-29 19:57 被阅读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

相关文章

网友评论

      本文标题:Python Max retries exceeded with

      本文链接:https://www.haomeiwen.com/subject/moeqoktx.html