小代码分享

小代码分享

法宣在线考试自动作答(且得满分)

说明

仅供学习交流
功能:法宣在线考试, 自动获取答案, 完成考试。

运行方法

1
2
3
4
1. 使用chrome浏览器登录法宣在线, 进入考试页面;
2. 单击浏览器的地址栏, 按快捷键F12;如果按不出来,说明平台截取并禁用了,那就用Chrome自带菜单: 更多工具 - 开发者工具;
3. 定位到console/控制台面板, 粘贴代码, 回车;
4. 程序开始执行, 每秒答一道题, 等待答题完成;

代码

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
var answer = [];
var times = 0;
var totalTimes = 0;

var Next = function () {
var questionId = answer[times]['questionId']
console.log("questionId", questionId)
$(`[id$=_${questionId}]`).click();
setTimeout(
function () {
var strAns = answer[times]['answerNo'];
var arrA = strAns.split('');
for (a of arrA) {
console.debug(a);
$('input[value=' + a + ']').click()
}
times += 1;
if (times < totalTimes) {
Next();
}
else {
console.debug('完成');
}
}, 1000);
};

var start = function () {
console.debug('开始');
let cookie = document.cookie;
let matchArray = cookie.match(/_EXAM(\d+)_PAPER(\d+)_SERIES(\d+)/);
let examId = matchArray[1];
let paperId = matchArray[2];
let seriesId = matchArray[3];
let answerUrl = `http://www.faxuanyun.com//ess/service/getpaper?paperId=${paperId}&series=${seriesId}_answer`
fetch(answerUrl, {
"headers": {
"cache-control": "no-cache",
"pragma": "no-cache",
"upgrade-insecure-requests": "1"
},
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
"mode": "cors",
"credentials": "include"
}).then(res => res.text()).then(body => {
console.debug("test", body);
let answerString = body.split("\n")[2];
answer = JSON.parse(answerString);
totalTimes = answer.length;
Next();
});
}
start();

原理

这个地址可以获取到考试的答案:

1
http://xf.faxuan.net/ess/service/getpaper?paperId=${paperId}&series=${seriesId}_answer
打赏
  • 版权声明: 本博客所有文章除特别声明外,著作权归作者所有。转载请注明出处!
  • Copyrights © 2019-2022 PAYIZ
  • |

感谢您的支持😊

支付宝
微信