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. __main__:1: Warning: Unknown table 'employ' 0L

    __main__:1: Warning: Unknown table 'employ' 0L from warnings import filterwarnings import MySQLdb fi ...

  2. 用pxe启动iso光盘里的pe

    用pxe启动iso光盘里的pe 我不是个运维,所以pxe我是由于一台比较老的笔记本不能u盘启动.光驱又坏了的情况下,硬盘上的系统在我不小心下...ghostexp解压ghost文件到c盘的时候,c盘是 ...

  3. (笔记)angular 路由

  4. jQuery层级元素选择器

    第一个: 1:空格表示所有 2:> 第一层 3:+/- 同级 +:之后的第一个元素 -:之后所有同级 d 代码示例: <!DOCTYPE html PUBLIC "-//W3C/ ...

  5. javaSE第十三天

    第十三天    76 1. StringBuffer(掌握)    76 (1)说明:    77 (2)StringBuffer的构造方法    77 (3)StringBuffer的常见功能    ...

  6. 【风马一族_php】PHP与Mysql建立连接

    让php发出 Hi作为基础 http://www.cnblogs.com/sows/p/5990157.html 配置apache      ../apache/conf/httpd.conf 创建p ...

  7. CentOS 5.x版本升级Mysql

    #-----------------------------CentOS 5.x版本升级Mysql ------------------#! /bin/sh #1.关闭selinuxcp -rp /e ...

  8. Winform菜单之ContextMenuStrip

    ContextMenuStrip实际就是上下文菜单,就是右键单击某个窗体或者控件后出来的菜单. 从工具栏里拖一个出来放在窗口上就行 然后进行一系列的设置,设置方法跟前面的MenuStrip基本是一样的 ...

  9. MongoDB(4):多种方式关闭服务命令

    http://blog.csdn.net/czw698/article/details/8791153 MongoDB 提供几种关闭服务的命令,具体为以下: 一 使用 Crtl+C 关闭  [mong ...

  10. php抓取post方式提交的页面

    function curlBy($url, $data=array()) {        $ch = curl_init();        if(!empty($data)){           ...