├── .build ├── default.Manifest.xml ├── default.init.aardio └── default.main.aardio ├── .gitattributes ├── LICENSE ├── Publish └── lib │ └── process │ └── adb │ └── .res │ ├── AdbWinApi.dll │ ├── AdbWinUsbApi.dll │ └── adb.exe ├── README.md ├── default.aproj ├── lib └── config.aardio ├── main.aardio └── res ├── 1.png ├── 2.png ├── 3.png ├── alipay.png ├── qun.png └── screenshot.png /.build/default.Manifest.xml: -------------------------------------------------------------------------------- 1 | 2 | 5 | 10 | MillionDollar 11 | 12 | 13 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | 33 | 34 | 35 | 36 | 37 | 38 | 39 | 52 | 53 | 54 | 55 | 56 | 57 | True/PM 58 | 59 | 60 | -------------------------------------------------------------------------------- /.build/default.init.aardio: -------------------------------------------------------------------------------- 1 | //发布前触发 2 | import ide; -------------------------------------------------------------------------------- /.build/default.main.aardio: -------------------------------------------------------------------------------- 1 | //此触发器在生成EXE以后执行 2 | import ide; 3 | import fsys; 4 | 5 | //获取生成的EXE文件路径 6 | var publishFile = ide.getPublishPath(); -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | *.aproj linguist-language=Go 2 | *.aardio linguist-language=Go -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | Apache License 2 | Version 2.0, January 2004 3 | http://www.apache.org/licenses/ 4 | 5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 6 | 7 | 1. Definitions. 8 | 9 | "License" shall mean the terms and conditions for use, reproduction, 10 | and distribution as defined by Sections 1 through 9 of this document. 11 | 12 | "Licensor" shall mean the copyright owner or entity authorized by 13 | the copyright owner that is granting the License. 14 | 15 | "Legal Entity" shall mean the union of the acting entity and all 16 | other entities that control, are controlled by, or are under common 17 | control with that entity. For the purposes of this definition, 18 | "control" means (i) the power, direct or indirect, to cause the 19 | direction or management of such entity, whether by contract or 20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 21 | outstanding shares, or (iii) beneficial ownership of such entity. 22 | 23 | "You" (or "Your") shall mean an individual or Legal Entity 24 | exercising permissions granted by this License. 25 | 26 | "Source" form shall mean the preferred form for making modifications, 27 | including but not limited to software source code, documentation 28 | source, and configuration files. 29 | 30 | "Object" form shall mean any form resulting from mechanical 31 | transformation or translation of a Source form, including but 32 | not limited to compiled object code, generated documentation, 33 | and conversions to other media types. 34 | 35 | "Work" shall mean the work of authorship, whether in Source or 36 | Object form, made available under the License, as indicated by a 37 | copyright notice that is included in or attached to the work 38 | (an example is provided in the Appendix below). 39 | 40 | "Derivative Works" shall mean any work, whether in Source or Object 41 | form, that is based on (or derived from) the Work and for which the 42 | editorial revisions, annotations, elaborations, or other modifications 43 | represent, as a whole, an original work of authorship. For the purposes 44 | of this License, Derivative Works shall not include works that remain 45 | separable from, or merely link (or bind by name) to the interfaces of, 46 | the Work and Derivative Works thereof. 47 | 48 | "Contribution" shall mean any work of authorship, including 49 | the original version of the Work and any modifications or additions 50 | to that Work or Derivative Works thereof, that is intentionally 51 | submitted to Licensor for inclusion in the Work by the copyright owner 52 | or by an individual or Legal Entity authorized to submit on behalf of 53 | the copyright owner. For the purposes of this definition, "submitted" 54 | means any form of electronic, verbal, or written communication sent 55 | to the Licensor or its representatives, including but not limited to 56 | communication on electronic mailing lists, source code control systems, 57 | and issue tracking systems that are managed by, or on behalf of, the 58 | Licensor for the purpose of discussing and improving the Work, but 59 | excluding communication that is conspicuously marked or otherwise 60 | designated in writing by the copyright owner as "Not a Contribution." 61 | 62 | "Contributor" shall mean Licensor and any individual or Legal Entity 63 | on behalf of whom a Contribution has been received by Licensor and 64 | subsequently incorporated within the Work. 65 | 66 | 2. Grant of Copyright License. Subject to the terms and conditions of 67 | this License, each Contributor hereby grants to You a perpetual, 68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 69 | copyright license to reproduce, prepare Derivative Works of, 70 | publicly display, publicly perform, sublicense, and distribute the 71 | Work and such Derivative Works in Source or Object form. 72 | 73 | 3. Grant of Patent License. Subject to the terms and conditions of 74 | this License, each Contributor hereby grants to You a perpetual, 75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 76 | (except as stated in this section) patent license to make, have made, 77 | use, offer to sell, sell, import, and otherwise transfer the Work, 78 | where such license applies only to those patent claims licensable 79 | by such Contributor that are necessarily infringed by their 80 | Contribution(s) alone or by combination of their Contribution(s) 81 | with the Work to which such Contribution(s) was submitted. If You 82 | institute patent litigation against any entity (including a 83 | cross-claim or counterclaim in a lawsuit) alleging that the Work 84 | or a Contribution incorporated within the Work constitutes direct 85 | or contributory patent infringement, then any patent licenses 86 | granted to You under this License for that Work shall terminate 87 | as of the date such litigation is filed. 88 | 89 | 4. Redistribution. You may reproduce and distribute copies of the 90 | Work or Derivative Works thereof in any medium, with or without 91 | modifications, and in Source or Object form, provided that You 92 | meet the following conditions: 93 | 94 | (a) You must give any other recipients of the Work or 95 | Derivative Works a copy of this License; and 96 | 97 | (b) You must cause any modified files to carry prominent notices 98 | stating that You changed the files; and 99 | 100 | (c) You must retain, in the Source form of any Derivative Works 101 | that You distribute, all copyright, patent, trademark, and 102 | attribution notices from the Source form of the Work, 103 | excluding those notices that do not pertain to any part of 104 | the Derivative Works; and 105 | 106 | (d) If the Work includes a "NOTICE" text file as part of its 107 | distribution, then any Derivative Works that You distribute must 108 | include a readable copy of the attribution notices contained 109 | within such NOTICE file, excluding those notices that do not 110 | pertain to any part of the Derivative Works, in at least one 111 | of the following places: within a NOTICE text file distributed 112 | as part of the Derivative Works; within the Source form or 113 | documentation, if provided along with the Derivative Works; or, 114 | within a display generated by the Derivative Works, if and 115 | wherever such third-party notices normally appear. The contents 116 | of the NOTICE file are for informational purposes only and 117 | do not modify the License. You may add Your own attribution 118 | notices within Derivative Works that You distribute, alongside 119 | or as an addendum to the NOTICE text from the Work, provided 120 | that such additional attribution notices cannot be construed 121 | as modifying the License. 122 | 123 | You may add Your own copyright statement to Your modifications and 124 | may provide additional or different license terms and conditions 125 | for use, reproduction, or distribution of Your modifications, or 126 | for any such Derivative Works as a whole, provided Your use, 127 | reproduction, and distribution of the Work otherwise complies with 128 | the conditions stated in this License. 129 | 130 | 5. Submission of Contributions. Unless You explicitly state otherwise, 131 | any Contribution intentionally submitted for inclusion in the Work 132 | by You to the Licensor shall be under the terms and conditions of 133 | this License, without any additional terms or conditions. 134 | Notwithstanding the above, nothing herein shall supersede or modify 135 | the terms of any separate license agreement you may have executed 136 | with Licensor regarding such Contributions. 137 | 138 | 6. Trademarks. This License does not grant permission to use the trade 139 | names, trademarks, service marks, or product names of the Licensor, 140 | except as required for reasonable and customary use in describing the 141 | origin of the Work and reproducing the content of the NOTICE file. 142 | 143 | 7. Disclaimer of Warranty. Unless required by applicable law or 144 | agreed to in writing, Licensor provides the Work (and each 145 | Contributor provides its Contributions) on an "AS IS" BASIS, 146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 147 | implied, including, without limitation, any warranties or conditions 148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 149 | PARTICULAR PURPOSE. You are solely responsible for determining the 150 | appropriateness of using or redistributing the Work and assume any 151 | risks associated with Your exercise of permissions under this License. 152 | 153 | 8. Limitation of Liability. In no event and under no legal theory, 154 | whether in tort (including negligence), contract, or otherwise, 155 | unless required by applicable law (such as deliberate and grossly 156 | negligent acts) or agreed to in writing, shall any Contributor be 157 | liable to You for damages, including any direct, indirect, special, 158 | incidental, or consequential damages of any character arising as a 159 | result of this License or out of the use or inability to use the 160 | Work (including but not limited to damages for loss of goodwill, 161 | work stoppage, computer failure or malfunction, or any and all 162 | other commercial damages or losses), even if such Contributor 163 | has been advised of the possibility of such damages. 164 | 165 | 9. Accepting Warranty or Additional Liability. While redistributing 166 | the Work or Derivative Works thereof, You may choose to offer, 167 | and charge a fee for, acceptance of support, warranty, indemnity, 168 | or other liability obligations and/or rights consistent with this 169 | License. However, in accepting such obligations, You may act only 170 | on Your own behalf and on Your sole responsibility, not on behalf 171 | of any other Contributor, and only if You agree to indemnify, 172 | defend, and hold each Contributor harmless for any liability 173 | incurred by, or claims asserted against, such Contributor by reason 174 | of your accepting any such warranty or additional liability. 175 | 176 | END OF TERMS AND CONDITIONS 177 | 178 | APPENDIX: How to apply the Apache License to your work. 179 | 180 | To apply the Apache License to your work, attach the following 181 | boilerplate notice, with the fields enclosed by brackets "[]" 182 | replaced with your own identifying information. (Don't include 183 | the brackets!) The text should be enclosed in the appropriate 184 | comment syntax for the file format. We also recommend that a 185 | file or class name and description of purpose be included on the 186 | same "printed page" as the copyright notice for easier 187 | identification within third-party archives. 188 | 189 | Copyright [yyyy] [name of copyright owner] 190 | 191 | Licensed under the Apache License, Version 2.0 (the "License"); 192 | you may not use this file except in compliance with the License. 193 | You may obtain a copy of the License at 194 | 195 | http://www.apache.org/licenses/LICENSE-2.0 196 | 197 | Unless required by applicable law or agreed to in writing, software 198 | distributed under the License is distributed on an "AS IS" BASIS, 199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 200 | See the License for the specific language governing permissions and 201 | limitations under the License. 202 | -------------------------------------------------------------------------------- /Publish/lib/process/adb/.res/AdbWinApi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsj1029/MillionHero/c90dc070c6aec0b60675832bcfae666c90005157/Publish/lib/process/adb/.res/AdbWinApi.dll -------------------------------------------------------------------------------- /Publish/lib/process/adb/.res/AdbWinUsbApi.dll: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsj1029/MillionHero/c90dc070c6aec0b60675832bcfae666c90005157/Publish/lib/process/adb/.res/AdbWinUsbApi.dll -------------------------------------------------------------------------------- /Publish/lib/process/adb/.res/adb.exe: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsj1029/MillionHero/c90dc070c6aec0b60675832bcfae666c90005157/Publish/lib/process/adb/.res/adb.exe -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # million-hero 2 | 百万英雄,自动搜题程序 3 | 4 | **最近全民答题比较火爆,比如百万英雄,冲顶大会,芝士超人等,让普通民众也感受了一把心跳。** 5 | 6 | ### 程序全面兼容 西瓜、冲顶、芝士、花椒 7 | 8 | > - ~~TODO IOS版~~ 9 | 10 | #Update 11 | > - 2018-01-24 更新IOS版,省去安卓截屏时间,更加有效率,平均不足3秒 [传送门](https://github.com/zsj1029/MillionHero-IOS) 12 | > - 2018-01-12 优化答题逻辑,根据两种方案,给出结果,根据提示选择答案 13 | > - 2018-01-11 汉王ORC太贵不够用,切换到百度云[文字识别](http://ai.baidu.com/docs#/OCR-API/top),每天500次免费额度 14 | > - 2018-01-10 ORC采用阿里云汉王文字识别 15 | 16 | **百度ORC识别appkey改一下,人多500次也不够,如下图** 17 | 18 | ![1.png](res/3.png) 19 | 20 | - QQ吃鸡交流群 21 | 22 | 23 | 24 | > 本程序参考了一下,最近比较火的跳一跳的原理 25 | 1. 安卓手机调试模式 26 | 2. 截图 27 | 3. 截取文字部分 28 | 4. ORC文字识别 29 | 5. 调用百度,返回查询结果 30 | 6. 一道题平均查询时间不到3秒 31 | 32 | ### 现隆重介绍一下实现的语言工具 [AARDIO](http://bbs.aardio.com/) 一位国内老程序员开发的语言。[介绍点这里](http://bbs.aardio.com/portal.php?mod=view&aid=5) 33 | - 引用官方的介绍 34 | > aardio 专用于桌面软件快速开发,开发环境仅 6.5 MB, 绿色软件解压即用 - 无论个人或企业都可以永久免费使用本软件开发商用、或非商用的应用程序。使用aardio开发的软件不需要放置鸣谢链接、不需要声明使用aardio开发。 35 | 36 | - 讲真aardio非常强大,很实用,入门简单,比python、node来说简单不少,非常适合开发windows程序 37 | 38 | **使用方法如下** 39 | 1. 开启usb调试模式安卓手机一部 40 | 2. 安装ADB调试驱动 [下载](http://www.wmzhe.com/soft-39913.html) 41 | 3. 配置windows环境变量,把adb解压完整目录名加入PATH 42 | 4. 双击运行MillionDollar.exe 43 | 44 | ![1.png](res/1.png) 45 | 46 | - 手机连接成功如上图显示,否则就去看看adb调试相关的连接知识,这里就不多做介绍 47 | 48 | ![screenshot.png](res/screenshot.png) 49 | 50 | - 根据提示,当题目出现后,按下回车开始识别搜题 51 | 52 | ![2.png](res/2.png) 53 | 54 | - 程序会去百度查询,返回前几条数据直接显示 55 | - 之后我不用我介绍了,多练习练习反应能力 56 | - 预祝大家大奖拿到手软 57 | 58 | ![screenshot.png](res/alipay.png) 59 | - 吃水不忘挖井人,支付宝给个打赏,金额随意 60 | 61 | 62 | -------------------------------------------------------------------------------- /default.aproj: -------------------------------------------------------------------------------- 1 |  2 | 3 | 4 | 5 | 6 | -------------------------------------------------------------------------------- /lib/config.aardio: -------------------------------------------------------------------------------- 1 | //config 配置文件 2 | import fsys.config; 3 | config = ..fsys.config("/config/"); 4 | 5 | /** 6 | config = ..fsys.config( 7 | ..fsys.joinpath( ..fsys.getSpecial( 0x1c /*_CSIDL_LOCAL_APPDATA*/ ),"应用程序名" ) 8 | ); 9 | **/ 10 | 11 | //不需要序列化的配置名字前请添加下划线 12 | namespace config { 13 | __appName = "应用程序名"; 14 | __appVersion = "1.0.0.01"; 15 | __appDescription = "这是一个测试程序"; 16 | __website = "http://www.aardio.com/"; 17 | } 18 | 19 | /**intellisense(config) 20 | __appName = 应用程序名 21 | __appVersion = 应用程序内部版本号 22 | __appDescription = 程序说明 23 | __website = 官方网站 24 | 25 | saveAll() = 写入所有配置到文件 26 | default.load() = 从配置文件(文件名"default")载入\n加载成功返回对象,加载失败返回null空值\n!fsys_table. 27 | default.save() = 存储到配置文件(文件名"default") 28 | default.mixin = @.mixin(\n 键名 = 值__;\n 键名 = 值;\n);//该数会自动调用save函数保存配置到文件 29 | default.控件名称 = 控件默认值\n调用save()函数同步控件当前值 30 | default.属性名 = 自配置文件(文件名"default")读写属性\n属性值可以是支持序列化的普通变量,支持table对象.\n配置文件在首次使用时自动加载,退出程序时自动保存. 31 | ? = !fsys_table. 32 | 配置文件名 = 读写配置并序列化为一个表对象,\n表的成员值可以是支持序列化的普通变量,支持table对象\n配置文件在首次使用时自动加载,退出程序时自动保存. 33 | end intellisense**/ 34 | -------------------------------------------------------------------------------- /main.aardio: -------------------------------------------------------------------------------- 1 | import console; 2 | import process; 3 | import process.popen; 4 | import process.adb; 5 | import fsys; 6 | import fsys.file; 7 | import fsys.stream; 8 | import gdip; 9 | import web.json; 10 | import web.rest.client; 11 | import crypt.bin; 12 | import string.xml; 13 | import web.mshtml; 14 | import inet.url; 15 | import string.html; 16 | import thread.event; 17 | import thread.manage; 18 | import time.performance; 19 | 20 | console.setTitle("答题辅助工具"); 21 | var imgpath = "C:\screenshot\screenshot.png"; 22 | var keypath = "C:\screenshot\token.txt"; 23 | var api = "http://text.aliapi.hanvon.com/rt/ws/v1/ocr/text/recg?code=74e51a88-41ec-413e-b162-bd031fe0407e"; 24 | var appcode = "xxxxx"; 25 | var bdorcapi = "https://aip.baidubce.com/rest/2.0/ocr/v1/general_basic"; 26 | var bdhighorcapi = 'https://aip.baidubce.com/rest/2.0/ocr/v1/accurate_basic' 27 | var apiKey = "QMC9Tp8ww8yjHDXI258uVOlM"; 28 | var secretKey = "LOko3wu9ZbVXMUyribzxGkivkIf6SbMR"; 29 | var token_url = "https://aip.baidubce.com/oauth/2.0/token"; 30 | var bd_token = ""; 31 | var now = tonumber(time.now()); 32 | 33 | 34 | //api获取token 35 | var to_auth = function(){ 36 | var apiClient = web.rest.client(); 37 | var params = { 38 | grant_type = "client_credentials"; 39 | client_id = apiKey; 40 | client_secret = secretKey; 41 | } 42 | var json = apiClient.get(token_url,params); 43 | var resp = web.json.parse(json); 44 | resp.expires_in = now + resp.expires_in; 45 | bd_token = resp.access_token; 46 | var keyfile = fsys.file(keypath,"w+"); 47 | json = web.json.stringify(resp); 48 | keyfile.write(json); 49 | keyfile.close(); 50 | //console.dump(resp); 51 | } 52 | 53 | 54 | //处理过期token 55 | var get_auth = function(){ 56 | if(!fsys.searchFile(keypath)) 57 | { 58 | to_auth(); 59 | }else { 60 | var keyfile = fsys.file(keypath,"r+"); 61 | var json = keyfile.readAll(); 62 | var resp = web.json.parse(json); 63 | if(resp.expires_in == null || now > resp.expires_in){ 64 | to_auth(); 65 | }else { 66 | bd_token = resp.access_token; 67 | } 68 | keyfile.close(); 69 | } 70 | } 71 | 72 | 73 | 74 | 75 | //安卓截屏 76 | var jieping = function(time){ 77 | imgpath = "C:\screenshot\screenshot"+time+".png" 78 | fsys.delete(imgpath); 79 | process.adb("shell rm /sdcard/screenshot.png" ); 80 | sleep(50); 81 | process.adb("shell /system/bin/screencap -p /sdcard/screenshot.png" ); 82 | //process.adb.pull( "/sdcard/screenshot.png",imgpath ) 83 | while(true){ 84 | if(fsys.searchFile(imgpath)) 85 | { 86 | var files = fsys.file(imgpath); 87 | var file_size = files.size(); 88 | //console.log(file_size); 89 | if(file_size>0) 90 | { 91 | files.close(); 92 | break ; 93 | } 94 | } 95 | process.adb.pull( "/sdcard/screenshot.png",imgpath ) 96 | sleep(20); 97 | } 98 | } 99 | 100 | //截屏裁剪 101 | var caijian = function(){ 102 | //980 103 | var bitmap = gdip.bitmap(imgpath); 104 | var bitmagNew = gdip.bitmap(920,920); 105 | var graphics = bitmagNew.getGraphics(); 106 | graphics.drawImageRectRect(bitmap,0,0,920,920,80,300,920,920) 107 | bitmagNew.save("C:\screenshot\screenshot_block.png") 108 | } 109 | 110 | //百度免费每天500orc识别 111 | var bdorc = function(){ 112 | var apiClient = web.rest.client(); 113 | var headers ={ 114 | ['Content-Type'] = "application/json; charset=UTF-8"; 115 | ['Content-Type'] = "application/x-www-form-urlencoded"; 116 | } 117 | var streams = fsys.stream("C:\screenshot\screenshot_block.png","r+"); 118 | var content = streams.readAll(); 119 | var params = { 120 | access_token = bd_token; 121 | image = crypt.bin.encodeBase64(content); 122 | } 123 | var json = apiClient.post(bdorcapi,params); 124 | var resp = web.json.parse(json); 125 | //console.log(json); 126 | var question = ""; 127 | var answer = {}; 128 | if(resp.words_result==null) 129 | { 130 | console.log("识别失败:"+resp.result); 131 | return null; 132 | } 133 | 134 | var num = resp.words_result_num; 135 | var find_ques = false; 136 | for(key,val in resp.words_result){ 137 | 138 | if(!find_ques) 139 | { 140 | question = question+""+val.words; 141 | if(string.find(val.words,"?"))//如果找到问号,问题截取ok 142 | { 143 | find_ques = true; 144 | } 145 | }else { 146 | val.words = string.replace(val.words,"《",""); 147 | val.words = string.replace(val.words,"》",""); 148 | table.push(answer,val.words); 149 | } 150 | } 151 | 152 | console.log(question); 153 | //除去序号1.2.3. 154 | questions = string.replace(question,"^\d+[.]*",""); 155 | questions = string.replace(questions,"?",""); 156 | //console.log(questions); 157 | /** 158 | for( i =12;1;-1){ 159 | if(questions!=question) 160 | break ; 161 | questions = string.replace(question,i,""); 162 | }**/ 163 | 164 | var obj = { 165 | question = questions; 166 | answer = answer; 167 | } 168 | return obj; 169 | } 170 | 171 | 172 | 173 | //orc识别 174 | var orcshibie = function(){ 175 | var apiClient = web.rest.client(); 176 | var headers ={ 177 | ['Content-Type'] = "application/json; charset=UTF-8"; 178 | ['Content-Type'] = "application/octet-stream"; 179 | ['Authorization'] = "APPCODE " + appcode; 180 | } 181 | apiClient.addHeaders = headers; 182 | var streams = fsys.stream("C:\screenshot\screenshot_block.png","r+"); 183 | var content = streams.readAll(); 184 | var params = { 185 | uid = "118.12.0.12"; 186 | color = "color"; 187 | lang = "chns"; 188 | image = crypt.bin.encodeBase64(content); 189 | } 190 | 191 | var json = apiClient.post(api,web.json.stringify(params,true)); 192 | var resp = web.json.parse(json); 193 | //console.dump(resp); 194 | 195 | if(resp.code == "0"){ 196 | var question = resp.textResult; 197 | question = string.replace(question,"\r",""); 198 | question = string.replace(question,"\n",""); 199 | question = string.replace(question," ",""); 200 | console.log(question); 201 | return question; 202 | }else { 203 | console.log("识别失败:"+resp.result) 204 | return null; 205 | } 206 | } 207 | 208 | //多线程请求搜索 209 | var search_thread = function(question,answer){ 210 | import inet.url; 211 | import thread.event; 212 | import console; 213 | import web.mshtml; 214 | import string.html; 215 | //console.log(question+" "+answer); 216 | 217 | var words = string.concat(question," ",answer); 218 | words = inet.url.encode(words) 219 | html = web.mshtml(); 220 | html.document.designMode = "on"; 221 | url = "https://www.baidu.com/s?wd="+words; 222 | html.go(url); 223 | qEle = html.queryEles(className = "nums"); 224 | var content = qEle[1].innerText; 225 | var pos1 = string.indexAny(content,"约"); 226 | substr = string.sub(content,pos1); 227 | substr = string.replace(substr,"约",""); 228 | substr = string.replace(substr,"个",""); 229 | substr = string.replace(substr,",",""); 230 | console.log(answer+": "+substr/1000+"千"); 231 | //console.dump(pos2); 232 | 233 | } 234 | 235 | var search = function(obj){ 236 | //console.dump(obj); 237 | //console.log(obj.question); 238 | question = obj.question; 239 | answer = obj.answer 240 | 241 | questions = inet.url.encode(question) 242 | 243 | html = web.mshtml(); 244 | html.document.designMode = "on"; 245 | url = "https://www.baidu.com/s?wd="+questions; 246 | html.go(url); 247 | 248 | qEle = html.queryEles(className = "c-abstract"); 249 | console.log("--------------------------------------------------------------------------"); 250 | console.log("搜索返回:"); 251 | for(key,val in qEle){ 252 | if(string.find(val.innerText,"最佳答案")){ 253 | console.log(val.innerText); 254 | console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); 255 | } 256 | } 257 | 258 | if(string.find(question,"不是")||string.find(question,"不正确") 259 | ||string.find(question,"不含")||string.find(question,"不包") 260 | ||string.find(question,"不属")||string.find(question,"不在") 261 | ||string.find(question,"没有")||string.find(question,"不可能")) 262 | { 263 | console.log("*此题可能是否定题,建议选统计次数最少的答案*"); 264 | }else { 265 | console.log("*建议选统计次数最多的答案*"); 266 | } 267 | console.log("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~"); 268 | 269 | var content = html.html; 270 | content = string.html.toText(content); 271 | console.log("统计答案出现次数:") 272 | 273 | for(key,val in answer){ 274 | //console.log(val); 275 | strlist = string.split(content,string.concat("<",val,">")); 276 | console.log(string.concat(val," ",(#strlist-1),"个")); 277 | } 278 | 279 | 280 | //多线程搜索问题+答案 结果记录数 281 | console.log("--------------------------------------------------------------------------"); 282 | console.log("统计问题+答案的搜索条数:") 283 | manage = thread.manage(10) 284 | for(key,val in answer){ 285 | 286 | manage.create(search_thread,question,val); 287 | } 288 | manage.waitClose(); 289 | 290 | } 291 | 292 | 293 | 294 | 295 | var init = function(){ 296 | //关闭adb进程 297 | var proc = "adb.exe"; 298 | for processEntry in process.each(proc) { 299 | process.kill(processEntry.szExeFile) 300 | } 301 | fsys.createDir("c:/screenshot/"); 302 | get_auth();//获取百度token 303 | 304 | process.adb.killServer(); 305 | process.adb.startServer(); 306 | if( process.adb.getState() != "device" ){ 307 | console.log("请选连接安卓手机,并打开设置->开发者选项->USB调试模式" ) 308 | 309 | console.pause() 310 | return ; 311 | } 312 | console.log("设备串号",process.adb.getSerialno() ) 313 | console.log("按回车键开始识别问题..." ); 314 | } 315 | 316 | 317 | init(); 318 | 319 | var times = 1; 320 | while(true){ 321 | if( console.kbHit() ){ 322 | var kb = console.kbRead(); 323 | if(!kb) continue; 324 | if( kb.wVirtualKeyCode == 0x1B/*_VK_ESC*/ ){ 325 | process.adb.killServer(); 326 | break; 327 | } 328 | if(kb.bKeyDown==1) 329 | { 330 | console.clearScreen(); 331 | var time1 = time.performance.tick(); 332 | jieping(times); 333 | times++; 334 | caijian(); 335 | //var question = orcshibie(); 336 | //var question = '岁寒三友有哪些?'; 337 | var question = bdorc(); 338 | if(!question){ 339 | continue ; 340 | } 341 | search(question); 342 | var time2 = time.performance.tick(); 343 | console.log("--------------------------------------------------------------------------"); 344 | console.log("处理时间:"+(time2-time1)/1000+"秒"); 345 | console.log(""); 346 | console.log("按回车键开始识别下一道题..." ); 347 | process.adb("shell rm /sdcard/screenshot.png" ); 348 | } 349 | 350 | } 351 | } 352 | 353 | 354 | -------------------------------------------------------------------------------- /res/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsj1029/MillionHero/c90dc070c6aec0b60675832bcfae666c90005157/res/1.png -------------------------------------------------------------------------------- /res/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsj1029/MillionHero/c90dc070c6aec0b60675832bcfae666c90005157/res/2.png -------------------------------------------------------------------------------- /res/3.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsj1029/MillionHero/c90dc070c6aec0b60675832bcfae666c90005157/res/3.png -------------------------------------------------------------------------------- /res/alipay.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsj1029/MillionHero/c90dc070c6aec0b60675832bcfae666c90005157/res/alipay.png -------------------------------------------------------------------------------- /res/qun.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsj1029/MillionHero/c90dc070c6aec0b60675832bcfae666c90005157/res/qun.png -------------------------------------------------------------------------------- /res/screenshot.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/zsj1029/MillionHero/c90dc070c6aec0b60675832bcfae666c90005157/res/screenshot.png --------------------------------------------------------------------------------