当前位置:网站首页>猿人学-第三题
猿人学-第三题
2022-08-06 22:24:00 【爱吃辣椒的锅包肉】
1.1 目标网站
https://match.yuanrenxue.com/match/3
1.2 查看请求和访问逻辑
1.2.1 打开fiddle进行抓包,可以看到两个请求
可以看到会请求两个请求, 第一个请求返回Set-Cookie,第二个请求带上就可以访问。

对生成数据的接口进行重放, 发现不能够正常返回数据, 对两个请求同时进行重放, 发现数据返回正常。
1.2.2 Python模拟请求

发现访问并没有返回到cookie, 对网页端和python模拟进行对比发现Python模拟请求头顺序不对


这里发现请求头不是按照顺序来的, 其中:
你向 headers 关键字参数传入一个 OrderedDict,就可以向提供一个带排序的 header。
然而,Requests 使用的默认 header 的次序会被优先选择。
这意味着如果你在 headers 关键字参数中覆盖了默认 header和关键字参数中别的 header 相比,它们也许看上去会是次序错误的。
requests 库 的header排序是会被优先选择的,而 Session对象中不会。
那么用户应该考虑在 Session 对象上面设置默认 header,只要将 Session 设为一个定制的 OrderedDict 即可。这样就会让它成为优选的次序。

2.1 代码
from collections import Counter
import requests
import urllib3
urllib3.disable_warnings()
headers = {
"Host": "match.yuanrenxue.com",
"Connection": "keep-alive",
"Content-Length": "0",
"sec-ch-ua": '".Not/A)Brand";v="99", "Google Chrome";v="103", "Chromium";v="103"',
"sec-ch-ua-mobile": "?0",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/103.0.0.0 Safari/537.36",
"sec-ch-ua-platform": "Windows",
"Accept": "*/*",
"Origin": "https://match.yuanrenxue.com",
"Sec-Fetch-Site": "same-origin",
"Sec-Fetch-Mode": "cors",
"Sec-Fetch-Dest": "empty",
"Referer": "https://match.yuanrenxue.com/match/3",
"Accept-Encoding": "gzip, deflate, br",
"Accept-Language": "zh-CN,zh;q=0.9",
"Cookie": "m=e6370aff58adacf77e6ddbbe8b365047|1659771468000; Hm_lvt_c99546cf032aaa5a679230de9a95c7db=1659761954,1659767697,1659767716,1659771472; qpfccr=true; no-alert3=true; Hm_lvt_9bcbda9cbf86757998a2339a0437208e=1659443435,1659452878,1659761832,1659771825; tk=-3495643738000386252; sessionid=wob9s7wdgrmmsnb7o8cl3a0ycqhmi9lf; Hm_lpvt_9bcbda9cbf86757998a2339a0437208e=1659771870; Hm_lpvt_c99546cf032aaa5a679230de9a95c7db=1659771870",
}
proxies = {
"http": "http://localhost:8000",
"https": "http://localhost:8000",
}
session = requests.session()
data_list = []
for page in range(1, 6):
if page == 4 or page == 5:
headers['user-agent'] = 'yuanrenxue.project'
session.headers = headers
res = session.post("https://match.yuanrenxue.com/jssm", verify=False)
# cookie_index = {"sessionid": res.cookies.get("sessionid")}
url_api = 'http://match.yuanrenxue.com/api/match/3?page={page}'.format(page=page)
res_dic = session.get(url=url_api).json()
for i in res_dic['data']:
data = i['value']
# print(data)
data_list.append(data)
print(max(data_list, key=data_list.count))
边栏推荐
- 【无标题】
- June Broker Gold Works Picks
- OpenCV基础图像的基本操作
- uniapp swipe left to delete effect 2, effect 1 (choose one of 2 methods) (organize)
- 3000字超详细介绍文件的最基本操作方法
- Understand Chisel language. 33. Chisel advanced hardware generator (2) - Chisel combinational logic circuit generation: take BCD coding table as an example
- 硅谷课堂第九课-整合网关与订单和营销模块
- Axure9 basic interactions (2)
- 从 VLAN 到 IPVLAN: 聊聊虚拟网络设备及其在云原生中的应用
- 户外移动电源:华宝新能、EcoFlow上演“龙虎斗”
猜你喜欢
随机推荐
硅谷课堂第十一课-公众号消息和微信授权
推荐一个全新硬件/嵌入式刷题网站!免费!好用!
ORACLE 12C 新功能 max_idle_time
Harvested the "Innovation Pioneer" of the first computing power conference, what trends did Jinan Supercomputing "Data Storage Cluster System" reveal?
GZIP文件压缩原理以及实现
迄今为止见过最详细的零拷贝技术讲解
Use the class loader to get the file path error and report a null pointer exception
】 【 mention test platform
Generate requirements. TXT
正确按照字典顺序比较字符串之 localeCompare
深夜回家坐电梯选择站在哪个位置相对会更安全? 蚂蚁新村8月6日答案
uniapp swipe left to delete effect 1, effect 2 (choose one of 2 methods) (sorting)
cdh6, use oozie for spark jar task scheduling
Axure9基本交互操作(二)
package DotaChessSelfPlay is not in GOROOT以及 relative import paths are not supported in module mode
从 min 到 max 的随机数
0x0000003b蓝屏什么原因 win7蓝屏0x0000003b怎么恢复
June Broker Gold Works Picks
k8s部署redis集群(6节点,3主3从集群模式)
12条MySQL优化技巧,提速不止十倍!









