urllib3学习
urllib3.connectionpool.connection_from_url(url, **kw)
Given a url, return an ConnectionPool instance of its host.
This is a shortcut for not having to parse out the scheme, host, and port of the url before creating an ConnectionPool instance.
| Parameters: |
|
|---|
例子
>>> conn = connection_from_url('http://google.com/')
>>> r = conn.request('GET', '/')
urllib3.util.timeout module
class urllib3.util.timeout.Timeout(total=None, connect=<object object>, read=<object object>)
Bases: object
Timeout configuration.
Timeouts can be defined as a default for a pool:
timeout = Timeout(connect=2.0, read=7.0)
http = PoolManager(timeout=timeout)
response = http.request('GET', 'http://example.com/')
Or per-request (which overrides the default for the pool):
response = http.request('GET', 'http://example.com/', timeout=Timeout())
Timeouts can be disabled by setting all the parameters to None:
no_timeout = Timeout(connect=None, read=None)
response = http.request('GET', 'http://example.com/, timeout=no_timeout)
| Parameters: |
|
|---|
更详细内容请参考:https://urllib3.readthedocs.io/en/latest/reference/urllib3.util.html#module-urllib3.util.timeout
urllib3.connectionpool module
class urllib3.connectionpool.ConnectionPool(host, port=None)
Bases: object
Base class for all connection pools, such as HTTPConnectionPool and HTTPSConnectionPool.
QueueCls-
alias of
LifoQueue
close()-
Close all pooled connections and disable the pool.
scheme= None
urlopen(method, url, body=None, headers=None, retries=None, redirect=True, assert_same_host=True, timeout=<object object>, pool_timeout=None, release_conn=None, chunked=False, body_pos=None, **response_kw)
Get a connection from the pool and perform an HTTP request. This is the lowest level call for making a request, so you’ll need to specify all the raw details.
可以把“连接池”当做“快递集散中心”,每个“连接”好比“一次快递事务”。
返回值
response对象。
Note
More commonly, it’s appropriate to use a convenience method provided by RequestMethods, such as request().
Note
release_conn will only behave as expected if preload_content=Falsebecause we want to make preload_content=False the default behaviour someday soon without breaking backwards compatibility.
| Parameters: |
|
|---|
urllib3学习的更多相关文章
- Python 爬虫十六式 - 第二式:urllib 与 urllib3
Python请求标准库 urllib 与 urllib3 学习一时爽,一直学习一直爽! 大家好,我是 Connor,一个从无到有的技术小白.上一次我们说到了什么是HTTP协议,那么这一次我们就要动 ...
- Requests:Python HTTP Module学习笔记(一)(转)
Requests:Python HTTP Module学习笔记(一) 在学习用python写爬虫的时候用到了Requests这个Http网络库,这个库简单好用并且功能强大,完全可以代替python的标 ...
- 学习笔记GAN001:生成式对抗网络,只需10步,从零开始到调试
生成式对抗网络(gennerative adversarial network,GAN),目前最火的非监督深度学习.一个生成网络无中生有,一个判别网络推动进化.学技术,不先着急看书看文章.先把Demo ...
- python requests库学习笔记(上)
尊重博客园原创精神,请勿转载! requests库官方使用手册地址:http://www.python-requests.org/en/master/:中文使用手册地址:http://cn.pytho ...
- 学习笔记:python3,PIP安装第三方库(2017)
https://pip.pypa.io/en/latest/quickstart/ pip的使用文档 http://www.lfd.uci.edu/~gohlke/pythonlibs/ .whl ...
- 深度学习(TensorFlow)环境搭建:(三)Ubuntu16.04+CUDA8.0+cuDNN7+Anaconda4.4+Python3.6+TensorFlow1.3
紧接着上一篇的文章<深度学习(TensorFlow)环境搭建:(二)Ubuntu16.04+1080Ti显卡驱动>,这篇文章,主要讲解如何安装CUDA+CUDNN,不过前提是我们是已经把N ...
- 学习了一天的python,终于可以爬爬了-_-
恒久恒久以前在语言大陆就听过一种叫,人生苦短,我用python的至理名言.陆陆续续在课下和业余生活中学习的一点python,知道基本的语法和规则,不过py的库实在是太多了,而且许多概念也没有深入的学习 ...
- /usr/lib/python2.7/site-packages/requests/__init__.py:91: RequestsDependencyWarning: urllib3 (1.22) or chardet (2.2.1) doesn't match a supported version!
/usr/lib/python2.7/site-packages/requests/ __init__.py:91: RequestsDependencyWarning: urllib3(1.22)或 ...
- Python爬虫学习1: Requests模块的使用
Requests函数库是学习Python爬虫必备之一, 能够帮助我们方便地爬取. Requests: 让HTTP服务人类. 本文主要参考了其官方文档. Requests具有完备的中英文文档, 能完全满 ...
随机推荐
- void fun() const{}; const void fun(){}; 和void const fun(){}; 的区别?
void fun() const{}; const void fun(){}; 和void const fun(){}; 的区别? const void fun(){};和void const fun ...
- 12.线程通信CyclicBarrier
CountDownLatch 监听某个线程的初始化,等待初始化执行完毕后,通知主线程工作.延迟.阻塞的是主线程,在单个线程中. CyclicBarrier 针对多个线程.线程池,多个线程初始化准备之后 ...
- 剖析ASP.NET Core MVC(Part 1)- AddMvcCore(译)
原文:https://www.stevejgordon.co.uk/asp-net-core-mvc-anatomy-addmvccore发布于:2017年3月环境:ASP.NET Core 1.1 ...
- [Todo]非常好的免费IT书籍资源 & Github排名
今天看github排名,看到排在第二位的是免费书籍: https://github.com/vhf/free-programming-books/blob/master/free-programmin ...
- 关于File.separator 文件路径:window与linux下路径问题(“No such file or diretory ”异常解决方案)
最近有个在页面上传Excel文件至服务器指定目录并进行数据校验.最后入库及进行进一步处理的应用情境,我写好代码在模拟环境下测试,完全没问题:但客户试用的时候,却老是报告“No such file or ...
- Java笔记19:Java匿名内部类
匿名内部类也就是没有名字的内部类.正因为没有名字,所以匿名内部类只能使用一次,它通常用来简化代码编写.但使用匿名内部类还有个前提条件:必须继承一个父类或实现一个接口 例1:不使用匿名内部类来实现抽象方 ...
- BS中保存参数
开发中经常需要将值存起来,当点击某一项时以便知道点击了哪一项. 一:应用JS页面跳转(牛腩中讲到) HTML: <td class="txt c"><a href ...
- ios中Core Location跟Map Kit的基本使用
地图类开发应用中,离不开地理位置跟MKMapView的使用,下面就记录下自己在使用这两个东西中学到的. 不过并不是所有苹果的设备都支持地理位置,我们在使用前应该做个判断,代码如下: BOOL loca ...
- 阿里巴巴Android开发手册(规约)
阿里巴巴Android开发手册(规约) 学习了:https://www.cnblogs.com/jb2011/p/8487889.html 这个猛 https://blog.csdn.net/ali ...
- 对PHP中类、继承、抽象的理解(个人总结)
1,PHP中的类可以被继承:A extends B. 2,类被声明为abstract时:a.该类就仅仅包含模版,我们就不能创建该类的实例对象,必须通过继承来使用new创建对象. b.继承一个抽象类的时 ...