工作问题--------爬虫遇到requests.exceptions.ConnectionError: HTTPSConnectionPool Max retries exceeded
问题描述:爬取京东的网站,爬取一段时间后报错。

经过一番查询,发现该错误是因为如下:
http的连接数超过最大限制,默认的情况下连接是Keep-alive的,所以这就导致了服务器保持了太多连接而不能再新建连接。
ip被封
程序请求速度过快。
解决办法如下:
第一种方法
try:
page1 = requests.get(ap)
except requests.exceptions.ConnectionError:
r.status_code = "Connection refused"
第二种方法:
request的连接数过多而导致Max retries exceeded
在header中不使用持久连接
'Connection': 'close'或requests.adapters.DEFAULT_RETRIES = 5
第三种方法:
针对请求请求速度过快导致程序报错。
解决方法可以参考以下例子:
import time while 1:
try:
page = requests.get(url)
except:
print("Connection refused by the server..")
print("Let me sleep for 5 seconds")
print("ZZzzzz...")
time.sleep(5)
print("Was a nice sleep, now let me continue...")
continue
http://www.chenxm.cc/post/536.html
原文地址:http://www.chenxm.cc/post/536.html
工作问题--------爬虫遇到requests.exceptions.ConnectionError: HTTPSConnectionPool Max retries exceeded的更多相关文章
- 关于requests.exceptions.ConnectionError: HTTPSConnectionPool的问题
错误如下: raise ConnectionError(e, request=request)requests.exceptions.ConnectionError: HTTPSConnectionP ...
- requests 处理异常错误 requests.exceptions.ConnectionError HTTPSConnectionPool [Errno 10060]
使用python requests模块调用vmallarg.vmall.com接口API时报如下错误: requests.exceptions.ConnectionError: HTTPSConnec ...
- 安装SpaCy出现报错:requests.exceptions.ConnectionError: HTTPSConnectionPool(host='raw.githubusercontent.com', port=443):
内含安装步骤及报错解决:https://www.cnblogs.com/xiaolan-Lin/p/13286885.html
- 解决python爬虫requests.exceptions.SSLError: HTTPSConnectionPool(host='XXX', port=443)问题
爬虫时报错如下: requests.exceptions.SSLError: HTTPSConnectionPool(host='某某某网站', port=443): Max retries exce ...
- 关于requests.exceptions.SSLError: HTTPSConnectionPool
问题: requests.exceptions.SSLError: HTTPSConnectionPool(host='mall.christine.com.cn', port=443): Max r ...
- python使用requests时报错requests.exceptions.SSLError: HTTPSConnectionPool
报错信息 Traceback (most recent call last): File "<stdin>", line 1, in <module> Fi ...
- 【Mac + ATX基于uiautomator2】使用weditor时,报错:requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer'))
产生以下原因找到了:是因为启动了appium,两者冲突,不能同时使用. 之前讲过怎么安装u2([Mac安装,ATX基于uiautomator2]之安装步骤)以及使用weditor, 但是经过一段时间, ...
- python requests.exceptions.ConnectionError
今天遇到一个奇葩问题, 1.r.request.post(url) 2..print r. status_code 居然第一步就报错了,原因是url不正确,按道理应该可以走到第二步然后输入404的 i ...
- 【airtest, python】报错:requests.exceptions.ConnectionError: ('Connection aborted.', ConnectionResetError(54, 'Connection reset by peer')),解决方法如下
环境及设备 mac, xcode , iphonex 问题 最近出现一个让人费解的问题,airtest 没跑多长时间,服务就断掉,而且总是报“requests.exceptions.Connectio ...
随机推荐
- finalshell连接工具
FinalShell功能特点: 1.多平台支持Windows,Mac OS X,Linux2.多标签,批量服务器管理.3.支持登录Ssh和Windows远程桌面.4.漂亮的平滑字体显示,内置100多个 ...
- python 解压、复制、删除 文件
一.python3解压文件 1.python 解压文件代码示例 如下代码主要实现zip.rar.tar.tar.gz四种格式的压缩文件的解压 def unzip_file(src_file, dst_ ...
- Go语言基础之面向对象编程中
1 Golang面向对象编程基本介绍 Golang仍然有面向对象编程的继承,封装和多态的特性,只是实现的方式和其它OPP语言不一样,随后分别介绍Golang对面向对象编程的三大特性是如何实现的. 2 ...
- 浅析word2vec(一)
1 word2vec 在自然语言处理的大部分任务中,需要将大量文本数据传入计算机中,用以信息发掘以便后续工作.但是目前计算机所能处理的只能是数值,无法直接分析文本,因此,将原有的文本数据转换为数值数据 ...
- .Net core webapi使用httpClient发送异步请求遇到TaskCanceledException: A task was canceled
前言:本人最近较多使用.net core的项目,最近在使用httpClient发送请求的时候,遇到服务器处理时间较长时,就老是会报异常:TaskCanceledException: A task wa ...
- 大白话工厂方法模式(Factory Method)
目录 简单工厂模式缺陷 简单工厂模式改造 工厂方法模式定义 工厂方法模式结构 工厂方法模式分析 参考文献 简单工厂模式缺陷 大白话简单工厂模式(Simple Factory Pattern)中通过买车 ...
- 00.JS前言
前言: 学习一门编程语言的基本步骤(01)了解背景知识 1.了解背景知识 1)什么是 JavaScript 语言? JavaScript 是一种轻量级的脚本语言.所谓“脚本语言”(scri ...
- Null项目参与排序
1.item1升序,item2升序,item3(存在NULL项目,NULL项目排在后面)升序 Collections.sort(list, Comparator.comparing(Bean::g ...
- 《手把手教你构建自己的 Linux 系统》学习笔记(10)
目录 /etc/fstab 文件的作用是什么? Linux 内核的图形化启动是怎么回事? Linux 系统中的文件名是否以大小写来进行区别? 「GRUB 中无法找到硬盘」怎么解决? 「GRUB 及配置 ...
- mybatis配置---> mybatisConfig.xml 配置加接数据源
mybatisConfig.xml 配置主要作用是连接数据源配置的前提是在完成mybatis的jar包基础之上进行的同时要确保数据用户名和密码是否正确 一:密码写在 mybatisConfig.xml ...