当前位置: 首页 > 后端技术 > Python

猿人科学第13题

时间:2023-03-25 19:34:47 Python

抓包-解析接口-加密参数为yuanrenxue_cookie,可以发现有多个请求的链接-查看发现第一个请求返回内容为yuanrenxue_cookie参数创建Session到keepthesession,保存第一个将request返回的参数添加到cookie中,附上代码参考importrequestsimportres=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=[]foriinrange(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"])foriindata]print(总和(num_list))