【猿人学】web第一届 第13题 入门级 cookie

加个cookie:

cookie中有个特殊的字段 yuanrenxue_cookie,但是怎么找都找不到,通过fiddler工具看下触发的所有流量包吧:

python代码:

python 复制代码
import re
import requests

# 创建会话并设置请求头和cookie
obj = requests.session()
obj.headers={
    'Referer':'https://match.yuanrenxue.cn/list',
    'User-Agent':'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like 	Gecko) Chrome/129.0.0.0 Safari/537.36',
}
# 设置成自己的sessionid
obj.cookies.set('sessionid','bse1j3p3uluqpc3jod0t5zrjs84ht1hc')

# 获取更新后的yuanrenxue_cookie值
res = obj.get(url='https://match.yuanrenxue.cn/match/13')
print(res.text)


cookie_list = eval(re.findall('\(.*\)',res.text)[0]).split('=')
print(cookie_list)
obj.cookies.update(
    {cookie_list[0]:cookie_list[1]}
)

# 访问具体页面时一定要注意先更新请求头信息中的Referer
obj.headers.update({'Referer':'https://match.yuanrenxue.cn/match/13'})

# 向各个页面发送请求并获取数据
total_value = 0
for pid in range(1,6):
    res = obj.get(url=f'https://match.yuanrenxue.cn/api/match/13?page={pid}')
    data = res.json()['data']
    print(f"第{pid}页数据:{data}")
    for item in data:
        total_value += int(item['value'])

print(f"前5页数字总和:{total_value}")

结果:

相关推荐
wj3055853784 小时前
课程 9:模型测试记录与 Prompt 策略
linux·人工智能·python·comfyui
星寂樱易李4 小时前
iperf3 + Python-- 网络带宽、网速、网络稳定性
开发语言·网络·python
qingfeng154155 小时前
企业微信机器人开发:如何实现自动化与智能运营?
人工智能·python·机器人·自动化·企业微信
Python私教7 小时前
Playwright MCP 用 a11y 树抓页面:比全量 DOM 省 token 的采集 Agent
爬虫
彦为君8 小时前
Agent 安全:从权限提示到沙箱隔离
python·ai·ai编程
PILIPALAPENG8 小时前
Python 语法速成指南:前端开发者视角(JS 类比版)
前端·人工智能·python
用户8356290780519 小时前
Python 操作 PowerPoint 页眉与页脚指南
后端·python
枫叶林FYL10 小时前
项目九:异步高性能爬虫与数据采集中枢 —— 基于 Crawl<sub>4</sub>AI 与 Playwright 的现代化数据采集平台 项目总览
爬虫·python·深度学习·wpf
猫猫的小茶馆10 小时前
【Python】函数与模块化编程
linux·开发语言·arm开发·驱动开发·python·stm32