
教育部全国青少年普法网-考试题库与答案(自动获取题库脚本)
使用方法:
复制脚本后,打开 浏览器,按 F12 键,再打开的新“窗口”中找到 Console (控制台)将代码粘贴到下面的空白框中,回车执行即可,执行完毕会自动获取最新题库并输出。
注意,一定要登录并已经选择年级后,才可以自动获取答案。
let result_text = [], oMap = ['A', 'B', 'C', 'D', 'E'];
function getPractice(columnId) {
$.ajax({
url: ${config.practice.host}${config.practice.practice}?columnId=${columnId}
,
headers: config.apiConfig.header,
async: false
}).done(function (res) {
res.data.questionBankList.forEach(item => {
result_text.push("问题:" + item.content);
item.answerOptions.split("@!@").forEach((option, index) => {
result_text.push(oMap[index] + ": " + option)
});
result_text.push("答案:" + item.answer);
result_text.push("解析:" + item.analysis);
result_text.push("========")
});
console.log('Ok', columnId)
});
return;
}
function getColumnList() {
$.ajax({
url: ${config.practice.host}${config.practice.getColumnList}
,
headers: config.apiConfig.header,
async: false
}).then(function (res) {
let { status, message,data } = res;
if (status != '0' || data.columnList.length <= 0) {
alert('错误:' + (message || '数据异常,没有课程'));
return;
}
data.columnList.forEach(item => {
getPractice(item.columnId);
});
console.log(result_text.join("\n"));
}, function (info) {
alert('还没有登陆');
});
}
getColumnList();
本文转载于青石坞,已获得授权