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. pxecfg&kickstart生成脚本

    em tm 00:00:00:00:00:12 10.180.1.12 255.255.255.0 173.45.34.25 255.255.255.225 173.45.34.1 em tm 00: ...

  2. SQL 数据库 复制 与订阅 实现数据同步

    摘自: http://www.jb51.net/article/18039.htm

  3. css中float left与float right的使用说明

    转自:http://www.jb51.net/css/33740.html   脚本之家 No! 要注意以下几点: 1. 浮动元素会被自动设置成块级元素,相当于给元素设置了display:block( ...

  4. jQuery源码的几篇文章

    http://lingyu.wang/#/post/2014/5/8/read-jq-src-1 http://lingyu.wang/#/post/2014/5/10/read-jq-src-2 h ...

  5. Android 按键式事件

    1. package com.fish.helloworld; import android.app.Activity; import android.graphics.Color; import a ...

  6. Android IOS WebRTC 音视频开发总结(十二)-- sufaceview

    谈到音视频不得不谈谈对视频呈现的理解,为了让大家能有一个更好的理解,先看看android里面SurfaceView的原理,后续陆续分享其绘画原理. 说明:本文是转载的,转载自哪里我也不知道,貌似经过很 ...

  7. 地球坐标系与投影方式的理解(关于北京54,西安80,WGS84;高斯,兰勃特,墨卡托投影)

    一.地球模型 地球是一个近似椭球体,测绘时用椭球模型逼近,这个模型叫做参考椭球,如下图: 赤道是一个半径为a的近似圆,任一圈经线是一个半径为b的近似圆.a称为椭球的长轴半径,b称为椭球的短轴半径. a ...

  8. javaSE第十天

    第十天    57 1. 形式参数和返回值的问题(理解)    57 (1)形式参数:    57 (2)返回值类型:    57 (3)链式编程    57 2. 包(理解)    57 (1)其实 ...

  9. Python-2.7.11+Django-1.9.4安装配置

    1.去python官网下载2.7的最新版本 https://www.python.org/downloads 1.1 解压Python-2.7.11.tgz tar xvf Python-2.7.11 ...

  10. Win2003打不开https的问题

    碰到客户做问题是能打开https://www.baidu.com 这个网页 打不开 https://sha256.alipay.com/SHA256/index.htm支付宝这个网页      解决办 ...