requests 发送请求模块。
- payload = {'key1': 'value1', 'key2': ['value2', 'value3']}
- headers = {'user-agent': 'my-app/0.0.1'}
- allow_redirects=False
- timeout=0.1 --指的是收到第一个字节的时间
- r = requests.post('http://httpbin.org/get', params=payload, data=payload)
-
- r.text
- r.content -- 二进制,处理非文本请求
- r.raw -- 设置请求参数stream=True,
- r.status_code
- r.cookies -- dict
- r.raise_for_status()
- r.headers
-