抓包-分析接口-加密参数为yuanrenxue_cookie
可以发现有一个链接有多次请求-查看发现第一次请求返回内容为yuanrenxue_cookie参数
创建一个Session保持会话,并将第一个请求返回的参数添加到cookie
下边附上代码参考
import requests
import re
s = requests.Session()
cookie_ ={
'sessionid':'',
}
s.cookies.update(cookie_)
url = 'https://match.yuanrenxue.com/match/13?'
rsp = s.get(url,verify=False)
cookies = re.findall("'([a-zA-Z0-9=_|])'", rsp.text)
yuanrenxue_cookie = ''.join(cookies)
key, value = yuanrenxue_cookie.split('=')
s.cookies.update({key:value})
header_={
'User-Agent': 'yuanrenxue.project',
}
s.headers = header_
if __name__ == '__main__':
num_list = []
for i in range(1,6):
url = "https://match.yuanrenxue.com/api/match/13?page={}".format(i)
r = s.get(url,verify=False).json()
data = r["data"]
print(data)
[num_list.append(i["value"]) for i in data]
print(sum(num_list))