A pool manager is an abstraction for a collection of ConnectionPools.
If you need to make requests to multiple hosts, then you can use a PoolManager, which takes care of maintaining
your pools so you don’t have to.

from urllib3 import PoolManager

manager = PoolManager(10)
res = manager.request('GET', 'baidu.com')
print(res.status)
print(res.data)

The PoolManager uses a Least Recently Used (LRU) policy for discarding old pools. That is, if you set the PoolManager
num_pools to 10, then after making requests to 11 or more different hosts, the least recently used pools will be
cleaned up eventually.
Cleanup of stale pools does not happen immediately but can be forced when used as a context manager.

with PoolManager(10) as manager:
res = manager.request('GET', 'baidu.com')
res = manager.request('GET', 'bing.com')

API

urllib3 PoolManager的更多相关文章

  1. A taste of urllib3

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

  2. python urllib和urllib3包使用

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

  3. 爬虫2 urllib3 爬取30张百度图片

    import urllib3 import re # 下载百度首页页面的所有图片 # 1. 找到目标数据 # page_url = 'http://image.baidu.com/search/ind ...

  4. 爬虫2 urllib3用法

    import urllib3 import json # 实例化一个连接池 # http = urllib3.PoolManager() # res = http.request('get','htt ...

  5. urllib3

    urllib3是一个功能强大.条理清晰.用于http客户端的python库,相对于urllib它所有的特点如下: 线程安全 连接池 客户端SSL/TLS验证 使用多部分编码上传文件 Helpers用于 ...

  6. python urllib和urllib3包使用(转载于)

    urllib.request 1. 快速请求 2.模拟PC浏览器和手机浏览器 3.Cookie的使用 4.设置代理 urllib.error URLError HTTPError urllib.par ...

  7. urllib和urllib3

    urllib库 urllib 是一个用来处理网络请求的python标准库,它包含4个模块. urllib.request---请求模块,用于发起网络请求 urllib.parse---解析模块,用于解 ...

  8. urllib3使用指南

    对比urllib,用urllib3处理http请求十分方便,可以嵌入web服务后端用于访问其它web实例提供的接口 一.安装 pip install urllib3 二.初始化 导入urllib3 i ...

  9. python urllib和urllib3包

    urllib.request urllib当中使用最多的模块,涉及请求,响应,浏览器模拟,代理,cookie等功能. 1. 快速请求 urlopen返回对象提供一些基本方法: read 返回文本数据 ...

随机推荐

  1. pcap文件格式及文件解析

    第一部分:PCAP包文件格式 一 基本格式: 文件头 数据包头数据报数据包头数据报...... 二.文件头: 文件头结构体 sturct pcap_file_header {      DWORD   ...

  2. ASP.NET Razor 视图引擎编程参考

    ASP.NET Razor 视图引擎编程参考   转载请注明出处:http://surfsky.cnblogs.com Rasor 视图引擎    http://msdn.microsoft.com/ ...

  3. Bootstrap CSS 描述

    <!DOCTYPE html><html lang="zh-CN"><head> <!--定于内容,和内容的编码格式--> < ...

  4. JAVA设计模式--State(状态模式)

    状态模式(State Pattern)是设计模式的一种,属于行为模式. 定义(源于Design Pattern):当一个对象的内在状态改变时允许改变其行为,这个对象看起来像是改变了其类. 状态模式主要 ...

  5. Data URL

    Data URL 早在 1995 年就被提出,那个时候有很多个版本的 Data URL Schema 定义陆续出现在 VRML 之中,随后不久,其中的一个版本被提上了议案——将它做个一个嵌入式的资源放 ...

  6. 必须会的SQL语句(八)数据库的完整性约束

    实体完整性 1.建表时定义主键   Create table 表名    (         Sno int identity(1,1),         Sname nvarchar(20),    ...

  7. 对象之间的引用传递 之 .NET中的深拷贝和浅拷贝

    1.场景 首先,场景是这样的. 有一个Person类,类中有一个类型是Car的属性.用于表述,人开的车. Car类中有一些描述诸如汽车拼盘之类的属性.基本场景就是这样.   2.浅拷贝 Person ...

  8. CentOS-6.4无线上网命令行配置

      参考:http://www.vfeelit.com/504.html 待连接的WIFI的ssid为“thm”,密码为12345678,认证方式为WPA2-PSK   1. 检查无线网卡驱动是否安装 ...

  9. 基于Vivado HLS在zedboard中的Sobel滤波算法实现

     基于Vivado HLS在zedboard中的Sobel滤波算法实现 平台:zedboard  + Webcam 工具:g++4.6  + VIVADO HLS  + XILINX EDK + ...

  10. Stop PeopleCode Processing with Error

    A blunt, but useful method for debugging PeopleCode is to use the inbuilt "Error" function ...