当前位置: 首页 > news >正文

【简单】 猿人学web第一届 第15题 备周则意怠,常见则不疑

数据接口分析

数据接口 https://match.yuanrenxue.cn/api/match/15
请求时需要携带 page 页码,m为加密参数
cookie中没有加密信息,携带 SessionId请求即可在这里插入图片描述

加密参数还原

查看数据接口对应的 requests 栈
在这里插入图片描述
m参数 是通过 window.m() 方法执行后得到的
在这里插入图片描述

打上断点,查看 window.m() 方法执行了什么

instance = results.instance;
window.q = instance.exports.encode;
window.m = function (){t1 = parseInt(Date.parse(new Date())/1000/2);t2 = parseInt(Date.parse(new Date())/1000/2 - Math.floor(Math.random() * (50) + 1));return window.q(t1, t2).toString() + '|' + t1 + '|' + t2;
};

window.q = instance.exports.encode;

在这里插入图片描述

window.q 是请求 wasm 文件编译成的,可以在 python 调用 wasm 文件

# 首先将 wasm 二进制的文件保存到本地
import requests
response = requests.get('https://match.yuanrenxue.cn/static/match/match15/main.wasm').content
open('15.wasm', 'wb').write(response)

调用

def get_m():t1 = int((int(time.time()) * 1000) / 1000 / 2)t2 = int((int(time.time()) * 1000) / 1000 / 2 - random.randint(10, 60))result = pywasm.load('15.wasm')results = result.exec("encode", [t1, t2])return f'{results}|{t1}|{t2}'

python 代码

import requests
import pywasm
import random
import timeheaders = {"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/128.0.0.0 Safari/537.36",
}
cookies = {"sessionid": "你的sessionId",
}def get_m():t1 = int((int(time.time()) * 1000) / 1000 / 2)t2 = int((int(time.time()) * 1000) / 1000 / 2 - random.randint(10, 60))result = pywasm.load('15.wasm')results = result.exec("encode", [t1, t2])return f'{results}|{t1}|{t2}'def get_math15(page):url = "https://match.yuanrenxue.cn/api/match/15"params = {"m": get_m(),"page": f"{page}"}response = requests.get(url, headers=headers, cookies=cookies, params=params)return response.json()['data']if __name__ == '__main__':nums = 0for page_ in range(1, 6):nums_list = get_math15(page_)for num in nums_list:nums += num['value']print('page: ', page_, 'nums: ', nums)

http://www.mrgr.cn/news/17621.html

相关文章:

  • 【高中数学/基本不等式】若正数a,b满足a>b,且1/(a+b)+1/(a-b)=1,则3a+2b的最小值是?
  • 微软最新轻量级、多模态Phi-3.5-vision-instruct模型部署
  • 跨语言障碍:全球语言翻译神器崛起
  • 可解释性和公平性在深度学习中的应用
  • 【C++】vector(下)--下篇
  • [M二叉树] lc236. 二叉树的最近公共祖先(dfs+二叉搜索树)
  • ThinkPHP如何关闭右下角的调试信息
  • 原来这就是 布隆过滤器
  • 小琳Python课堂:Python优先级队列深入解析:`PriorityQueue`类的使用与原理
  • 利用Spring Boot实现微服务的API版本管理
  • datax编译:解决datax不支持MongoDB 6.0.10的问题
  • 新能源汽车超级电容和电池能量管理系统的simulink建模与仿真
  • python从谷歌地图获取经纬度坐标之间的导航信息
  • GIT版本管理详解
  • 【STM32】通用定时器TIM(输入捕获)
  • 高级C#开发者的 ADO.NET 数据库操作工具类深入解析与实战
  • 【python2C】排序算法
  • Spring的简单介绍
  • 数据结构-c/c++实现队列(链表实现)
  • HTTP 协议详解