A connection pool is a container for a collection of connections to a specific host.
If you need to make requests to the same host repeatedly, then you should use a HTTPConnectionPool.

 from urllib3 import HTTPConnectionPool

 pool = HTTPConnectionPool('www.baidu.com', maxsize=1)
res = pool.request('GET', '/s', fields={'wd': 'HELLO'})
print(res.status)
print(res.data)

By default, the pool will cache just one connection. If you’re planning on using such a pool in a multithreaded
environment, you should set the maxsize of the pool to a higher number, such as the number of threads. You can
also control many other variables like timeout, blocking, and default headers.

A ConnectionPool can be used as a context manager to automatically clear the pool after usage.

with HTTPConnectionPool('www.baidu.com', maxsize=1) as pool:
res = pool.request('GET', '/s', fields={'wd': 'HELLO'})
print(pool.pool)

API

urllib3 ConnectionPools的更多相关文章

  1. urllib3 PoolManager

    A pool manager is an abstraction for a collection of ConnectionPools.If you need to make requests to ...

  2. python中urllib, urllib2,urllib3, httplib,httplib2, request的区别

    permike原文python中urllib, urllib2,urllib3, httplib,httplib2, request的区别 若只使用python3.X, 下面可以不看了, 记住有个ur ...

  3. urllib3 ProxyManager

    ProxyManager is an HTTP proxy-aware subclass of PoolManager. It produces a singleHTTPConnectionPool ...

  4. A taste of urllib3

    import urllib3 import certifi http = urllib3.PoolManager( cert_reqs='CERT_REQUIRED', # Force certifi ...

  5. python urllib和urllib3包使用

    urllib包 urllib是一个包含几个模块来处理请求的库.分别是: urllib.request 发送http请求 urllib.error 处理请求过程中,出现的异常. urllib.parse ...

  6. Uiautomator--出现报错“urllib3.exceptions.ProtocolError:<'Connection aborted.',error<10054,''>>”的解决方式!

    在运行uiautomator时,出现报错"urllib3.exceptions.ProtocolError:<'Connection aborted.',error<10054, ...

  7. 禁用 urllib3 的安全请求警告

    报错情况: 禁用该警告: import urllib3 urllib3.disable_warnings()

  8. /usr/lib/python2.7/site-packages/requests/__init__.py:80: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version! RequestsDependencyWarning)

    [root@iZwz9bhan5nqzh979qokrkZ ~]# ansible all -m ping /usr/lib/python2.7/site-packages/requests/__in ...

  9. urllib、urllib2、urllib3区别和使用

    python3中把urllib和urllib合并为一个库了,urllib对应urllib.request 1.) python 中最早内置拥有的网络请求模块就是 urllib,我们可以看一下 urll ...

随机推荐

  1. 代码轮子之很简单但是挺管用的基于C# Task的模拟并发的代码

    代码轮子之很简单但是挺管用的基于C# Task的模拟并发的代码

  2. 手机连接wifi自动弹窗的原理及其实现方案

    一.手机连上wifi后会自动弹窗的原理 生活中,有很多需要认证的路由器,手机连接wifi热点后会自动弹出一个网页,让用户输入账号和密码,比如星巴克,肯地基,麦当劳,甚至是火车站和机场的候车室.其实这是 ...

  3. iOS中UIKit——UIFont得到iOS设备上的系统字体

    for (NSString *fontFamily  in [UIFont familyNames]) { NSLog(@"字体家族是:%@",fontFamily); for(N ...

  4. MongoDb gridfs-ngnix文件存储方案 - 图片

    http://www.cnblogs.com/wintersun/p/4622205.html 在各类系统应用服务端开发中,我们经常会遇到文件存储的问题. 常见的磁盘文件系统,DBMS传统文件流存储. ...

  5. sqoop的eval工具

    eval的作用:Evaluate a SQL statement and display the results,也就是说eval像是一个数据库的客户端工具. 一.使用eval来查询表 $ sqoop ...

  6. SVN客户端解决authorization failed问题

    遇到authorization failed问题 进人 [root@localhost conf]# pwd /opt/svndata/shell/conf [root@localhost conf] ...

  7. delphi 连接MYSQL 的方法

    需要的控件:(view as form) 1.SQLConnection1: TSQLConnection ConnectionName = 'MYSQLCONNECTION' DriverName ...

  8. 一个封装好的CSV文件操作C#类代码

    using System.Data; using System.IO; namespace DotNet.Utilities { /// <summary> /// CSV文件转换类 // ...

  9. python网络画图——networkX

    networkX tutorial 绘制基本网络图 用matplotlib绘制网络图 基本流程: 1. 导入networkx,matplotlib包 2. 建立网络 3. 绘制网络 nx.draw() ...

  10. Learning Scrapy笔记(零) - 前言

    我已经使用了scrapy有半年之多,但是却一直都感觉没有入门,网上关于scrapy的文章简直少得可怜,而官网上的文档(http://doc.scrapy.org/en/1.0/index.html)对 ...