更新题库
This commit is contained in:
@@ -50,6 +50,7 @@ const JD_API_HOST = 'https://api.m.jd.com/client.action';
|
|||||||
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"});
|
$.msg($.name, '【提示】请先获取京东账号一cookie\n直接使用NobyDa的京东签到获取', 'https://bean.m.jd.com/bean/signIndex.action', {"open-url": "https://bean.m.jd.com/bean/signIndex.action"});
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
await requireTk()
|
||||||
for (let i = 0; i < cookiesArr.length; i++) {
|
for (let i = 0; i < cookiesArr.length; i++) {
|
||||||
if (cookiesArr[i]) {
|
if (cookiesArr[i]) {
|
||||||
cookie = cookiesArr[i];
|
cookie = cookiesArr[i];
|
||||||
@@ -150,8 +151,25 @@ function getQuestions() {
|
|||||||
let i = 0, questionList = []
|
let i = 0, questionList = []
|
||||||
for (let vo of data.result.questionList) {
|
for (let vo of data.result.questionList) {
|
||||||
$.question = vo
|
$.question = vo
|
||||||
|
let option = null, hasFound = false
|
||||||
|
|
||||||
console.log(`去查询第${++i}题:【${vo.questionStem}】`)
|
console.log(`去查询第${++i}题:【${vo.questionStem}】`)
|
||||||
let ans = -1, option = null
|
let ques = $.tk.filter(qo => qo.questionId === vo.questionId)
|
||||||
|
|
||||||
|
if (ques.length) {
|
||||||
|
ques = ques[0]
|
||||||
|
let ans = JSON.parse(ques.correct)
|
||||||
|
let opt = vo.options.filter(bo => bo.optionDesc === ans.optionDesc)
|
||||||
|
if (opt.length) {
|
||||||
|
console.log(`在题库中找到题啦~`)
|
||||||
|
option = opt[0]
|
||||||
|
hasFound = true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!option) {
|
||||||
|
console.log(`在题库中未找到题`)
|
||||||
|
let ans = -1
|
||||||
for (let opt of vo.options) {
|
for (let opt of vo.options) {
|
||||||
let str = vo.questionStem + opt.optionDesc
|
let str = vo.questionStem + opt.optionDesc
|
||||||
console.log(`去搜索${str}`)
|
console.log(`去搜索${str}`)
|
||||||
@@ -168,16 +186,22 @@ function getQuestions() {
|
|||||||
} else {
|
} else {
|
||||||
console.log(`选择搜索返回结果最多的一项【${option.optionDesc}】\n`)
|
console.log(`选择搜索返回结果最多的一项【${option.optionDesc}】\n`)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
let b = {
|
let b = {
|
||||||
"questionToken": vo.questionToken,
|
"questionToken": vo.questionToken,
|
||||||
"optionId": option.optionId
|
"optionId": option.optionId
|
||||||
}
|
}
|
||||||
$.option = option
|
$.option = option
|
||||||
await answer(b)
|
await answer(b)
|
||||||
questionList.push($.question)
|
if (!hasFound) questionList.push($.question)
|
||||||
if (i < data.result.questionList.length)
|
if (i < data.result.questionList.length) {
|
||||||
|
if (hasFound)
|
||||||
|
await $.wait(2 * 1000)
|
||||||
|
else
|
||||||
await $.wait(5 * 1000)
|
await $.wait(5 * 1000)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
for (let vo of questionList) {
|
for (let vo of questionList) {
|
||||||
$.question = vo
|
$.question = vo
|
||||||
await submitQues({
|
await submitQues({
|
||||||
@@ -369,6 +393,25 @@ function TotalBean() {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function requireTk() {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
$.get({
|
||||||
|
url: `http://qn6l5d6wm.hn-bkt.clouddn.com/question.json?t=${new Date().getTime()}`,
|
||||||
|
headers: {
|
||||||
|
'User-Agent': 'Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4371.0 Safari/537.36'
|
||||||
|
}
|
||||||
|
}, (err, resp, data) => {
|
||||||
|
try {
|
||||||
|
$.tk = JSON.parse(data).RECORDS
|
||||||
|
} catch (e) {
|
||||||
|
console.log(e)
|
||||||
|
} finally {
|
||||||
|
resolve()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
function safeGet(data) {
|
function safeGet(data) {
|
||||||
try {
|
try {
|
||||||
if (typeof JSON.parse(data) == "object") {
|
if (typeof JSON.parse(data) == "object") {
|
||||||
|
Reference in New Issue
Block a user