0.1s速通小猿口算保姆教程
思路
ocr识别(速度最慢,本文不讲)
1. 抓包获取答案答题
2. 修改响应体里的答案
0. 准备工作
在电脑上安装Fiddler(免费经典版就可以)
在Tools -> Options -> Connections里面把允许远程连接打开,端口号默认8888
在Http里做以下设置,然后点击右上角Actions -> Trust Root Certificate,弹窗中全部选择“yes”,将Fiddler伪证书进行安装
然后在鼠标指到右上会显示本机局域网ip地址(或者cmd -> ipconfig -> ipv4地址)
然后打开同一局域网下的安卓设备(使用模拟器可以避免90%的疑问)
在wifi里设置手动代理,输入刚刚的ip和端口号,保存
接着在浏览器里输入 ip:端口号,如:192.168.31.88:8888 ,然后点击下面蓝色链接下载证书
证书要在设置里安装(设置里直接搜证书,选择从本地存储安装)
(mumu模拟器在 设置 -> 网络和互联网 -> 互联网 -> 网络偏好设置 -> 安装证书)
然后在Fittler里面打开解密,右边点击Filters,照着箭头处设置,过滤有效信息
xyks.yuanfudao.com;
然后打开就可以打开小猿口算了
1. 抓包获取答案答题
点击FiddlerScript,找到OnBeforeResponse,添加以下代码
//保存小猿口算答案
if (oSession.uriContains("https://xyks.yuanfudao.com/leo-game-pk/android/math/pk/match")) {var jsonFilePath = "E:\\learn\\xyks\\xyks.json"; // 改成你自己的地址var jsonResponse = oSession.GetResponseBodyAsString();oSession.utilSetResponseBody(jsonResponse);File.WriteAllText(jsonFilePath, jsonResponse); // 保存 JSON
}
进入小猿口算的pk匹配会自动获取所有答案并保存在你设置目录的Json文件里
然后使用python读取答案,开始答题(下面是比大小的代码)
import json
import os
import sys
import time
from pynput import keyboard
import threading
import pyautoguidef check_data():file_path = 'xyks.json'last_modified_time = os.path.getmtime(file_path)while True:time.sleep(0.02)current_modified_time = os.path.getmtime(file_path)if current_modified_time != last_modified_time:print("答案获取成功")print(read_file())last_modified_time = current_modified_timedef read_file():with open('xyks.json', 'r', encoding='utf-8') as file:data = json.load(file)answer_list = []for question in data['examVO']['questions']:answer_list.append(question['answer'])return answer_listdef greater_than(start_x, start_y):pyautogui.moveTo(start_x, start_y)pyautogui.mouseDown()pyautogui.move(50, 20,duration=0.1) # 向右移动pyautogui.move(-50, 20,duration=0.13) # 向左移动pyautogui.mouseUp()def less_than(start_x, start_y):pyautogui.moveTo(start_x, start_y)pyautogui.mouseDown()pyautogui.move(-50, 20,duration=0.1) # 向左移动pyautogui.move(50, 20,duration=0.13) # 向右移动pyautogui.mouseUp()def start_answer():start_x, start_y = pyautogui.position()answer_ls = read_file()print("准备开始答题")for ans in answer_ls:if ans == '>':greater_than(start_x, start_y)else:less_than(start_x, start_y)time.sleep(0.04)print("答题完毕\n\n")# 开始之后按s键开始答题
def on_start_press(key):try:if key.char == 's':start_answer()except AttributeError:pass# 监听键盘
def listen_key():with keyboard.Listener(on_press=on_start_press) as listener:listener.join()if __name__ == '__main__':thread = threading.Thread(target=check_data)thread.start()listen_key()
2. 修改响应体里的答案
点击FiddlerScript,找到OnBeforeResponse,添加以下代码,用正则表达式把答案替换成1
//修改保存小猿口算答案
if (oSession.uriContains("https://xyks.yuanfudao.com/leo-game-pk/android/math/pk/match")) {var jsonFilePath = "E:\\learn\\xyks\\xyks.json";var jsonResponse = oSession.GetResponseBodyAsString(); jsonResponse = jsonResponse.replace(/answer\":\"\d+\"/g,"answer\":\"1\"");jsonResponse = jsonResponse.replace(/answers\":\[\"\d+\"/g,"answers\":\[\"1\"");oSession.utilSetResponseBody(jsonResponse);File.WriteAllText(jsonFilePath, jsonResponse); // 保存 JSON}
然后搞个连点器,或者用python快速点击(点一个点就识别成1了)
from pynput import keyboard
import threading
import pyautoguidef on_start_press(key):try:if key.char == 's':start_answer()except AttributeError:passdef start_answer():start_x, start_y = pyautogui.position()pyautogui.moveTo(start_x, start_y)for i in range(0, 23):pyautogui.click()# 按 s 开始画 1
def listen_key():with keyboard.Listener(on_press=on_start_press) as listener:listener.join()if __name__ == '__main__':listen_key()