import requests import json import json import xlrd import xlwt import pandas as pd from pprint import pprint headers = { 'Accept': 'application/json, text/javascript, */*; q=0.01', 'Accept-Encoding': 'gzip, deflate', 'Accept-Language': 'zh-CN,zh;q=0.9', 'Connection': 'keep-alive', 'Content-Length': '81', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Cookie': 'JSESSIONID=52DB78DAB54F9F8154968A66B1316389', 'Host': 'www.idsz.xin:7070', 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8', 'Referer':'http://www.idsz.xin:7070/Sale_Order', 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.198 Safari/537.36', 'X-Requested-With': 'XMLHttpRequest' } for a in range(0,1): url='http://www.idsz.xin:7070/posapi_invoke?apiname=kpi_memberVerifiAndSurplusQuery&detailtype=4&startTime=2010-01-01&endTime=2022-02-18&key=totalCount&sshopId=×CardId=&option=&page={}&pageSize=50'.format(a) response = requests.get(url=url,headers=headers) res = response.json() # for record in response: # df=pd.DataFrame(KH) # df.to_excel('流失客户.xlsx',index=False)