{"id":21270245,"url":"https://github.com/henson/answer","last_synced_at":"2025-07-29T05:34:16.713Z","repository":{"id":49878629,"uuid":"118231133","full_name":"henson/Answer","owner":"henson","description":"答题助手，适用于 百万英雄 / 芝士超人 / 冲顶大会 / 花椒百万赢家 等多个直播答题类 APP，支持 iOS、Android 手机和模拟器，3 秒出结果","archived":false,"fork":false,"pushed_at":"2018-01-23T14:34:52.000Z","size":870,"stargazers_count":137,"open_issues_count":5,"forks_count":42,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-04-06T00:11:33.145Z","etag":null,"topics":["android","android-adb","golang","hq-trivia","ios","simulator","tesseract-ocr","webdriveragent"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/henson.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-01-20T10:05:49.000Z","updated_at":"2025-02-23T17:49:03.000Z","dependencies_parsed_at":"2022-08-03T00:00:30.722Z","dependency_job_id":null,"html_url":"https://github.com/henson/Answer","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/henson/Answer","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henson%2FAnswer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henson%2FAnswer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henson%2FAnswer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henson%2FAnswer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/henson","download_url":"https://codeload.github.com/henson/Answer/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/henson%2FAnswer/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":264739258,"owners_count":23656591,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","android-adb","golang","hq-trivia","ios","simulator","tesseract-ocr","webdriveragent"],"created_at":"2024-11-21T08:16:44.450Z","updated_at":"2025-07-29T05:34:16.682Z","avatar_url":"https://github.com/henson.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Go Report Card](https://goreportcard.com/badge/github.com/henson/Answer)](https://goreportcard.com/report/github.com/henson/Answer)  [![Travis Status for henson/Answer](https://travis-ci.org/henson/Answer.svg?branch=master)](https://travis-ci.org/henson/Answer)  [![GitHub release](https://img.shields.io/github/release/henson/Answer.svg)](https://github.com/henson/Answer/releases/tag/v1.0)\n\n# Answer\n答题助手，适用于 百万英雄 / 芝士超人 / 冲顶大会 / 花椒百万赢家 等多个直播答题类 APP，支持 iOS、Android 手机和模拟器，3 秒出结果。\n\n![](/doc/1.png)\n\n**目录**\n\n- [答题助手](#Answer)\n  - [特点](#特点)\n  - [更新日志](#更新日志)\n  - [方法原理](#方法原理)\n  - [文本关联相似度算法](#文本关联相似度算法)\n  - [使用步骤](#使用步骤)\n    -[Android](#Android)\n    -[iOS](#iOS)\n  - [项目参考](#项目参考)\n- [TODO](#TODO)\n\n## 特点\n\n- 超快的响应速度\n- 支持iOS、Android\n- 支持真机测试和模拟器\n- 全面覆盖百万英雄/芝士超人/冲顶大会/花椒百万赢家等多个直播答题类APP\n- 优化搜索逻辑保证高正确率\n- 多维度参考值，答案交叉验证\n\n## 更新日志\n\n- 2018.01.23\n  - 把OCR识别方式分离（[issues/1](https://github.com/henson/Answer/issues/1)）\n  - fix [issues/3](https://github.com/henson/Answer/issues/3)\n- 2018.01.21\n  - 加入搜狗汪仔答题助手的结果\n- 2018.01.20\n  - 改进 ABD 手机截屏获取方式，提高速度\n  - 题目和选项一次截取识别\n- 2018.01.18\n  - 增加知识图谱结果\n- 2018.01.15\n  - 调整适应性，百万英雄/芝士超人/冲顶大会/花椒百万赢家等全适用\n- 2018.01.10\n  - 改进算法逻辑，提高正确率\n\n\n## 方法原理\n\n1. ADB 获取手机截屏\n\n  - ~~命令行生成截屏图片，把图片传输到电脑上~~\n```\nadb shell screencap -p /sdcard/screenshot.png\nadb pull /sdcard/screenshot.png .\n```\n\n  - 直接读取屏幕数据，速度更快（参考 [http://blog.csdn.net/wirelessqa/article/details/29187339](http://blog.csdn.net/wirelessqa/article/details/29187339)）\n```\nadb shell screencap -p\n```\n\n2. OCR 识别题目与选项文字   \n\n  ![](/doc/cut.png)\n\n  ​\n  两个方法：\n\n  - 谷歌 [Tesseract](https://github.com/tesseract-ocr/tesseract) ，安装软件即可，不同电脑配置运行效率不同\n  - [百度 OCR](https://cloud.baidu.com/product/ocr) ，需要注册百度 API，每天调用次数有限\n  \n3. 申请百度OCR\n\n* [注册百度云账号](http://ai.baidu.com/tech/ocr/general)，打开[管理中心](https://console.bce.baidu.com/iam)，然后按下图操作\n\n![](/doc/baidu.gif)\n\n\n4. 通过算法对搜索结果进行筛选、判断\n\n    目前用到的算法：\n  - 文本关联相似度算法\n  - 结巴分词算法\n\n\n## 文本关联相似度算法\n\n（参考 [github.com/smileboywtu/MillionHeroAssistant](https://github.com/smileboywtu/MillionHeroAssistant)）\n\n通过分别统计问题与三个答案的关联度来选择正确的答案，在集合相当大的情况下，关联度会呈现正相关。\n\n假设题目是： \n\n*中国历史上著名的科举制度开始于那个朝代？*\n- 汉朝\n- 唐朝\n- 隋朝\n\n我们先用百度分别搜索`汉朝`，`唐朝`，`隋朝`，得到如下数据：\n\n朝代 | 搜索出的数量（来自百度为您找到相关结果约）\n---- | ------------------------------------------\n汉朝 | 17900000\n唐朝 | 30500000\n隋朝 | 16600000\n\n然后我们在用`题目` + `答案`的方式，搜索示例：\n\n`中国历史上著名的科举制度开始于那个朝代？ 汉朝` 得到三次的搜索结果：\n\n 关键字  | 搜索出的数量（来自百度为您找到相关结果约）\n-------- | ------------------------------------------\nQ + 汉朝 | 602000\nQ + 唐朝 | 837000\nQ + 隋朝 | 658000\n\n关联度计算方式：\n\n``` shell\nK = count(Q \u0026 A) / (count(Q) * count(A))\n```\n\n关联度如下：\n\n答案 | 关联度\n---- | ------\n汉朝 | 0.0336\n唐朝 | 0.0274\n隋朝 | 0.0396\n\n\n## 使用步骤\n### Android\n\n#### 1. 安装 ADB\n\n**windows**\n\n下载地址：https://adb.clockworkmod.com/ ，并配置环境变量\n\n**Mac**\n\n使用 brew 进行安装 `brew cask install android-platform-tools`\n\n\n\n安装完后插入安卓设备且安卓已打开 USB 调试模式，终端输入 `adb devices` ，显示设备号则表示成功。我手上的机子是坚果 pro1，第一次不成功,查看设备管理器有叹号，使用 [handshaker](https://www.smartisan.com/apps/handshaker) 加载驱动后成功，也可以使用豌豆荚之类的试试。\n\n```\nList of devices attached\n6934dc33    device\n```\n\n若不成功，可以参考[Android 和 iOS 操作步骤](https://github.com/wangshub/wechat_jump_game/wiki/Android-%E5%92%8C-iOS-%E6%93%8D%E4%BD%9C%E6%AD%A5%E9%AA%A4)进行修改\n\n\n#### 2.安装模拟器\n\n**windows**\n\n  - 安装[夜神模拟器](https://www.yeshen.com/)或[逍遥模拟器](http://www.xyaz.cn/)，然后在模拟器上安装西瓜视频、冲顶大会等答题APP\n  - 把模拟器设置成竖屏（分辨率900*1440），打开 USB 调试模式\n  - 确认端口号，夜神模拟器62001，逍遥模拟器21503\n  - 连接测试，连接成功会有提示\n  ```shell\n  adb connect 127.0.0.1:62001\n  ```\n\n#### 3. 安装谷歌 Tesseract\n\nWindows下链接：\n*推荐使用安装版，在安装时选择增加中文简体语言包*\n- 安装版：\n  https://digi.bib.uni-mannheim.de/tesseract/tesseract-ocr-setup-3.05.01.exe\n- 免安装版：\n  https://github.com/parrot-office/tesseract/releases/download/3.5.1/tesseract-Win64.zip\n  *免安装版需要下载[中文语言包](https://github.com/tesseract-ocr/tesseract/wiki/Data-Files)，放置到Tesseract的`tessdata`目录下*\n\n其他系统：\nhttps://github.com/tesseract-ocr/tesseract/wiki\n\n### iOS\n\n#### 1.安装WDA\n\niOS 真机如何安装 WebDriverAgent（参考 [https://testerhome.com/topics/7220](https://testerhome.com/topics/7220)）\n\n#### 2.安装tesseract以及简体中文包\n\n**Mac**\n\n```shell\nbrew install tesseract\ncd /usr/local/Cellar/tesseract/{version}/share/tessdata\nwget https://github.com/tesseract-ocr/tessdata/raw/master/chi_sim.traineddata\n```\n\n### 配置 Golang 环境\n\n#### 安装 Golang\n```\nhttps://golang.org/doc/\n```\n\n#### 从源码安装本项目\n\n```\ngo get -u github.com/henson/Answer\n```\n\n#### 直接下载可执行文件\n\n根据平台直接下载各版本运行文件： [releases](https://github.com/henson/Answer/releases)\n\n\n### 运行\n\n 1. 根据实际情况设置配置文件\n\n**配置参数说明：**\n\n```\n# 是否开始调试模式\ndebug: true\n# 游戏名称, xigua西瓜视频/cddh冲顶大会/huajiao花椒/zscr芝士超人\napp: xigua\n# 是否模拟自动答题\nautomatic: false\n# 对应的设备类型：ios or android\ndevice: android\n# android 连接地址\nadb_address: '127.0.0.1:62001'\n# ios 设备连接wda的地址\nwda_address: '127.0.0.1:8100'\n# 西瓜视频裁剪区域：x,y,w,h\nxg_q_x: 30\nxg_q_y: 240\nxg_q_w: 840\nxg_q_h: 180\nxg_a_x: 30\nxg_a_y: 410\nxg_a_w: 840\nxg_a_h: 450\n……\n```\n\n  2. 填入百度 OCR key\n\n修改参数：\n\n```\n# 百度OCR API参数\nBaidu_API_Key: \"**************************\"\nBaidu_Secret_Key: \"**************************\"\n```\n\n  3. 程序运行：\n\n```\n./Answer\n```\n或\n```\ncd cmd\ngo run main.go\n```\n\n## 项目参考\n\n  - [qanswer](https://github.com/silenceper/qanswer) (golang)\n  - [MillionHeroAssistant](https://github.com/smileboywtu/MillionHeroAssistant) (python)\n  - [TopSup](https://github.com/Skyexu/TopSup) (python)\n  - [wenda-helper](https://github.com/rrdssfgcs/wenda-helper) (python)\n\n本项目在开发过程中参考了以上开源项目，在此对开源作者表示感谢！\n\n## TODO\n\n- 对题目进行分类，建立题型库，针对不同题型采取不同的处理方法\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenson%2Fanswer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhenson%2Fanswer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhenson%2Fanswer/lists"}