例如:需要搜10页数据,用接口去处理
第一步:去搜索对应的接口
第二步,复制接口到apipost系统
第三步,复住到apipost系统
第四步骤,数据分析
第五步,生成python脚本,导入到python系统
第六步,将生成的代码复制到pycharm中
调整代码:
1、我们的分页要调整
对应python脚本,将p的值变成可输入的
for page in range(1,6):
payload = "p=" + str(page) + "&chain_id=444&status=&room_number=&type=1&key=93791f91093e3110de228eb0a1b953cd&admin_id=11&agent_id=0&is_daili=0"
print(payload)
2、返回值参数优化
第7步,参考代码
import requests
url = "https://1111.111.cn/Manage/Upgrade/TvUpgradeList"
# p="1"
for page in range(1,6):
payload = "p="+str(page)+"&chain_id=444&status=&room_number=&type=1&key=22&admin_id=11&agent_id=0&is_daili=0"
headers = {
"accept": "application/json, text/plain, */*",
"accept-language": "zh-CN,zh;q=0.9",
"cache-control": "no-cache",
"content-type": "application/x-www-form-urlencoded",
"origin": "https://1",11
"pragma": "no-cache",
"priority": "u=1, i",
"referer": "https://111/",
# "sec-ch-ua": ""Google Chrome";v="125", "Chromium";v="125", "Not.A/Brand";v="24"",
"sec-ch-ua-mobile": "?0",
# "sec-ch-ua-platform": ""Windows"",
"sec-fetch-dest": "empty",
"sec-fetch-mode": "cors",
"sec-fetch-site": "same-origin",
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36"
}
response = requests.request("POST", url, data=payload, headers=headers)
# print(response.text)
# print(response.json()['data']['list'])
m=response.json()['data']['list']
for x in m:
#房间号
# print(x['room_number'])
#升级状态
print(x['status_label'])