Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

Commit

Permalink
头脑王者转移到知乎答题王,anyproxy 增加 wss 支持
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuweiyou committed Feb 19, 2018
1 parent d045e7b commit 59aa28d
Show file tree
Hide file tree
Showing 10 changed files with 67 additions and 71 deletions.
57 changes: 1 addition & 56 deletions 头脑王者/README.md
Original file line number Diff line number Diff line change
@@ -1,58 +1,3 @@
# 头脑王者

爬取题库、答题辅助

## 准备

- Node.js 9.x 以上
- MongoDB
- 安装依赖 `npm i`

## 功能

### 爬取题库

> 爬题思路:不断进行好友对战获取题目,随意提交答案会返回正确答案,存入数据库,重复的忽略
分别使用两个微信号登录游戏,抓登录的请求,复制返回的 `uid``token`

填入 [src/crawl.js](src/crawl.js) 中,执行 `npm run crawl` 开始自动爬取

如果出现 “上局异常退出,请重新登录” 的提示,先退出爬题脚本,用第一个微信号**完全退出游戏进程**,重新进入游戏,再重新爬即可

爬题需要一定的时间,也可以直接导入[我爬好的题库 MongoShell BSON(.json)](quizzes.json)(近 1.7w 题)数据库名为 `tnwz`

导入命令,注意你的文件路径

```bash
mongoimport -d tnwz -c quizzes --file ~/Downloads/quizzes.json --jsonArray --drop
```

### 答题辅助

执行 `npm run ca` 生成 RootCA,将生成的证书安装到手机上,并在手机上设置代理 IP(电脑的局域网 IP) 和 端口(8001)

证书配置遇到困难可以看[这里](http://anyproxy.io/cn/#%E8%AF%81%E4%B9%A6%E9%85%8D%E7%BD%AE)

一切都配置好之后,**完全退出游戏进程**,执行 `npm run robot`,再重新进入游戏

答题时,如果该题在题库中,终端会输出正确答案,手机上正确答案前面会显示一个 ``

如果本题不在题库里,会自动打开百度搜索答案,并将本题正确答案记录到题库中

## 截图

<table>
<tr>
<td>
<img src="https://user-images.githubusercontent.com/8413791/35086936-551678b8-fc69-11e7-8e58-a75ad403ffde.png" alt="王者截图">
</td>
<td>
<img src="https://user-images.githubusercontent.com/8413791/35084177-a7642b58-fc5d-11e7-9774-10a0b17dc39c.png" alt="辅助截图">
</td>
</tr>
</table>

![爬取截图](https://user-images.githubusercontent.com/8413791/35079048-36290192-fc40-11e7-9514-036e786dbe5d.png)

![题库截图](https://user-images.githubusercontent.com/8413791/35079110-7303a0a4-fc40-11e7-9e09-1b67415d8855.png)
“头脑王者” 小程序违规被封,已改名为 [知乎答题王](../知乎答题王)
57 changes: 56 additions & 1 deletion 知乎答题王/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,58 @@
# 知乎答题王

由于头脑王者违规被封,改名为知乎答题王,所以目前直接使用 [头脑王者](../头脑王者) 的辅助即可
爬取题库、答题辅助

## 准备

- Node.js 9.x 以上
- MongoDB
- 安装依赖 `npm i`

## 功能

### 爬取题库

> 爬题思路:不断进行好友对战获取题目,随意提交答案会返回正确答案,存入数据库,重复的忽略
分别使用两个微信号登录游戏,抓登录的请求,复制返回的 `uid``token`

填入 [src/crawl.js](src/crawl.js) 中,执行 `npm run crawl` 开始自动爬取

如果出现 “上局异常退出,请重新登录” 的提示,先退出爬题脚本,用第一个微信号**完全退出游戏进程**,重新进入游戏,再重新爬即可

爬题需要一定的时间,也可以直接导入[我爬好的题库 MongoShell BSON(.json)](quizzes.json)(近 1.7w 题)数据库名为 `zhdtw`

导入命令,注意你的文件路径

```bash
mongoimport -d zhdtw -c quizzes --file ~/Downloads/quizzes.json --jsonArray --drop
```

### 答题辅助

执行 `npm run ca` 生成 RootCA,将生成的证书安装到手机上,并在手机上设置代理 IP(电脑的局域网 IP) 和 端口(8001)

证书配置遇到困难可以看[这里](http://anyproxy.io/cn/#%E8%AF%81%E4%B9%A6%E9%85%8D%E7%BD%AE)

一切都配置好之后,**完全退出游戏进程**,执行 `npm run robot`,再重新进入游戏

答题时,如果该题在题库中,终端会输出正确答案,手机上正确答案前面会显示一个 ``

如果本题不在题库里,会自动打开百度搜索答案,并将本题正确答案记录到题库中

## 截图

<table>
<tr>
<td>
<img src="https://user-images.githubusercontent.com/8413791/35086936-551678b8-fc69-11e7-8e58-a75ad403ffde.png" alt="王者截图">
</td>
<td>
<img src="https://user-images.githubusercontent.com/8413791/35084177-a7642b58-fc5d-11e7-9774-10a0b17dc39c.png" alt="辅助截图">
</td>
</tr>
</table>

![爬取截图](https://user-images.githubusercontent.com/8413791/35079048-36290192-fc40-11e7-9514-036e786dbe5d.png)

![题库截图](https://user-images.githubusercontent.com/8413791/36367267-dbb177ce-158c-11e8-8c82-2eae80263a43.png)
4 changes: 2 additions & 2 deletions 头脑王者/package.json → 知乎答题王/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
"scripts": {
"ca": "anyproxy-ca",
"crawl": "node src/crawl.js",
"robot": "anyproxy --intercept --ignore-unauthorized-ssl --rule=src/robot.js"
"robot": "anyproxy --intercept --ignore-unauthorized-ssl --ws-intercept --rule=src/robot.js"
},
"dependencies": {
"anyproxy": "^4.0.4",
"anyproxy": "^4.0.6",
"axios": "^0.17.1",
"mongoose": "^4.13.9"
}
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const mongoose = require('mongoose')

const db = mongoose.connect('mongodb://localhost/tnwz', {
const db = mongoose.connect('mongodb://localhost/zhdtw', {
useMongoClient: true,
autoReconnect: true
})
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ const crypto = require('crypto')
const axios = require('axios')
const querystring = require('querystring')
const sleep = require('./sleep')
require('../database/mongo')
const QuizModel = require('../database/quiz-model')
require('./mongo')
const QuizModel = require('./quiz-model')

const request = axios.create({
baseURL: 'https://question.hortor.net/',
Expand Down
4 changes: 2 additions & 2 deletions 头脑王者/src/crawl.js → 知乎答题王/src/crawl.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const Tnwz = require('./common/tnwz')
const Zhdtw = require('./common/zhdtw')

Tnwz.crawl([
Zhdtw.crawl([
{
uid: '',
token: ''
Expand Down
10 changes: 3 additions & 7 deletions 头脑王者/src/robot.js → 知乎答题王/src/robot.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,9 @@
const exec = require('child_process').exec
const Tnwz = require('./common/tnwz')
const QuizModel = require('./database/quiz-model')
const Zhdtw = require('./common/zhdtw')
const QuizModel = require('./common/quiz-model')

// AnyProxy 只支持 yield 语法,暂不支持 await
module.exports = {
* beforeDealHttpsRequest (requestDetail) {
return ['question.hortor.net', 'question-zh.hortor.net']
.some(domain => requestDetail.host.indexOf(domain) !== -1)
},
* beforeSendRequest (requestDetail) {
// 原先采用的是改数据发送,经测试发现会频繁的提示需要重新登录,所以改为只提示答案了
},
Expand All @@ -25,7 +21,7 @@ module.exports = {
// 从题库里找答案
this._quiz = yield QuizModel.findOne({quiz: this._findQuiz.quiz})
if (this._quiz) {
const answer = Tnwz.transformAnswer(this._quiz, this._findQuiz) - 1
const answer = Zhdtw.transformAnswer(this._quiz, this._findQuiz) - 1
const option = this._findQuiz.options[answer]
this._findQuiz.options[answer] = '√ ' + option
body.data = this._findQuiz
Expand Down

0 comments on commit 59aa28d

Please sign in to comment.