使用时换成具体的url,key和value即可
import requests import json # GET url = 'http://www.baidu.com' params = {'key': 'value'} headers = {'key': 'value'} cookies = {'key': 'value'} response = requests.get(url, params=params, headers=headers, cookies=cookies) print(response.text) # 返回的文本 print(response.json()) # 返回的json数据 print(response.status_code) # 返回状态码 #POST url = 'http://www.baidu.com' # form params = {'key': 'value'} response = requests.post(url, data=params) # json payload = {'key': 'value'} response = requests.post(url, json=json.dumps(payload)