方法一,参考https://www.cnblogs.com/becks/p/11364175.html,直接把request内的data=data改成json=data,注,“C”是脚本中定义的变量
方法二:格式转换,输入data=json.dumps(data),先把data转换成json数据,然后再发起请求,以上两种方法都需要在引入json库,import json
附全部脚本,本脚本解决通过数据递增,实现数据删除
import requests import json a = 2967 def test (c): cookies = { ‘__guid‘: ‘xxxx‘, ‘cna‘: ‘u1IqFGLwrC0CAXb5ccVY9A84‘, ‘isg‘: ‘xxx-B7JB1kDuKBsu‘, ‘monitor_count‘: ‘2‘, } headers = { ‘authority‘: ‘storeapi-dev.xxx.com‘, ‘pragma‘: ‘no-cache‘, ‘cache-control‘: ‘no-cache‘, ‘access-control-request-method‘: ‘GET‘, ‘origin‘: ‘https://adminagent-fat.xxx.com‘, ‘user-agent‘: ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36‘, ‘access-control-request-headers‘: ‘authorization,req-host‘, ‘accept‘: ‘*/*‘, ‘sec-fetch-site‘: ‘same-site‘, ‘sec-fetch-mode‘: ‘cors‘, ‘referer‘: ‘https://adminagent-fat.xxx.com/‘, ‘accept-encoding‘: ‘gzip, deflate, br‘, ‘accept-language‘: ‘zh-CN,zh;q=0.9‘, ‘req-host‘: ‘adminagent-fat.xxx.com‘, ‘authorization‘: ‘Bearer xxxxx.xxx.XLO4e6X2K70cS3Uz8kDmmhQMWCHg2yifeocnywlKLS8‘, ‘content-type‘: ‘application/json; charset=utf-8‘, ‘Connection‘: ‘keep-alive‘, ‘Pragma‘: ‘no-cache‘, ‘Cache-Control‘: ‘no-cache‘, ‘User-Agent‘: ‘Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/78.0.3904.108 Safari/537.36‘, ‘Accept‘: ‘image/webp,image/apng,image/*,*/*;q=0.8‘, ‘Sec-Fetch-Site‘: ‘cross-site‘, ‘Sec-Fetch-Mode‘: ‘no-cors‘, ‘Referer‘: ‘https://adminagent-fat.xxx.com/‘, ‘Accept-Encoding‘: ‘gzip, deflate, br‘, ‘Accept-Language‘: ‘zh-CN,zh;q=0.9‘, } params = ( (‘rend‘, ‘0.8061441194209389‘), ) data = {"Ids":[c]} data=json.dumps(data) response = requests.post(‘https://storeapi-dev.xxx.com/100000000028/ImageCenter/DelPic‘, headers=headers, params=params, cookies=cookies, data=data) print(response.text) for b in range(10000): c = a + b test (c)