requests是一款Python的第三方HTTP类库,便于进行HTTP访问。
1. requests的特性
- 能够发送HTTP 1.1请求
- 无需手工为GET方法设置URL的请求参数,无需手工为POST方法组编码表单形式
- 借助于urllib3实现HTTP请求的连接会话缓存
- 支持Python 2.6, 2.7, 3.3-3.7
2. requests的安装
requests不是Python标准库,需要使用PIP安装,命令如下:
pip install requests
安装过程如下:
C:\Sam\works>pip install requests
Collecting requests
Downloading https://files.pythonhosted.org/packages/51/bd/23c926cd341ea6b7dd0b2a00aba99ae0f828be89d72b2190f27c11d4b7fb/requests-2.22.0-py2.py3-none-any.whl (57kB)
100% |████████████████████████████████| 61kB 17kB/s
Collecting certifi>=2017.4.17 (from requests)
Downloading https://files.pythonhosted.org/packages/18/b0/8146a4f8dd402f60744fa380bc73ca47303cccf8b9190fd16a827281eac2/certifi-2019.9.11-py2.py3-none-any.whl (154kB)
100% |████████████████████████████████| 163kB 18kB/s
Collecting idna<2.9,>=2.5 (from reques