requests 发送http请求
导包
import requests
GET
发送请求
payload = {'key1': 'value1', 'key2': 'value2'} r = requests.get("http://httpbin.org/get", params=payload)
获取响应
r.text # 获取unicode数据
POST
发送请求
r = requests.post('http://httpbin.org/post', data = {'key':'value'})
获取响应
r.text # 获取unicode数据
PUT
发送请求
r = requests.put('http://httpbin.org/put', data = {'key':'value'})
获取响应
r.text # 获取unicode数据
DELETE
发送请求
r = requests.delete('http://httpbin.org/delete')
获取响应
r.text # 获取unicode数据