自动填写答案流程:
1、自动填写答案
打开答题页面之后,F12调出控制台,在控制台中执行:
$(“body”).append(unescape(“%3Cscript src='” + “http://zx.eluup.com/bj-zk/auto.js’ type=’text/javascript’%3E%3C/script%3E”))
可以自动填写答案
2、自动收集答案
提交试卷后,会跳转出现考试成绩页面。
如 上步,还是F12 调出控制塔,执行代码:
$(“body”).append(unescape(“%3Cscript src='” + “http://zx.eluup.com/bj-zk/auto.js’ type=’text/javascript’%3E%3C/script%3E”))
可以自动记录答案
答案实现思路:
选择题一般4个选项,需要尝试4次,既可以试验出答案(每个账号3次,所以至少需要两个账号)。
判断题2个选项,尝试2次即可。
多选题,组合较多,目前没有好办法,只能人肉查找答案。
使用js脚本对页面元素处理,思路:找到每个题目的唯一class,每个题目下所有选项的唯一标示。之后就是写代码了。
1、准备题目答案列表。
2、遍历题目答案列表,然后选择每个题目答案对应的题目。
3、再使遍历题目对应的答案,使用答案选择对应选项。
4、触发此选项的点击事件(不能直接改选中属性,原因是页面可能会对答案的点击操作做其它处理,所以尽量模拟人的行为)。
数据对象:
题目答案:{“题号”:”答案位置0开始(多选为逗号分隔的位置字符串)”}
具体看代码
#收集答案:题号=>答案位置从0开始
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 |
var score = []; $(".examMain").each(function(){ var id = $(this).attr("mainqueid"); $($(".examMain")[20]).find(".options-c.correct"); var answer = {}; // 选择题答案 var answerOption = $(this).find(".options-c.correct"); // 判断题答案 var answerJudge = $(this).find(".judgecorrectgreen-bg,.judgeerrorgreen-bg"); if (answerJudge.length > 0) { answer = answerJudge; console.info("判断",answer); } else if (answerOption.length > 0) { answer = answerOption; console.info("单选或多选",answer); } // var option = []; for (var i=0; i<answer.length; i++) { var op = parseInt($(answer[i]).attr("sansid")); option.push(--op); } score.push("'"+id+"':'" + option.join(",") + "'"); }); var result = "{" + score.join(",") + "}"; console.info(result); |
具体答案:
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
17春《大学英语》(三)作业_1 var score = {'1':'3','2':'2','3':'2','4':'2','5':'1','6':'1','7':'2','8':'1','9':'0','10':'1','11':'2','12':'0','13':'0','14':'3','15':'3','16':'2','17':'2','18':'3','19':'1','20':'2','21':'0','22':'3','23':'3','24':'0','25':'2'}; $(".examMain").each(function(){ var id = $(this).attr("mainqueid"); var option = $(this).find(".options-c.correct").attr("sansid"); score[id] = option; }); for (var id in score) { var item = $(".uniQueItem.singItem.examSing")[id-1]; var ans = $(item).find(".liSing-bg")[score[id]]; $(ans).click(); } 17春《大学英语》(三)作业_2 var score = {'1':'0','2':'3','3':'0','4':'0','5':'2','6':'3','7':'2','8':'0','9':'0','10':'0','11':'2','12':'0','13':'2','14':'2','15':'1','16':'3','17':'3','18':'0','19':'2','20':'0','21':'0','22':'3','23':'0','24':'2','25':'3'}; $(".examMain").each(function(){ var id = $(this).attr("mainqueid"); var option = $(this).find(".options-c.correct").attr("sansid"); score[id] = option; }); for (var id in score) { var item = $(".uniQueItem.singItem.examSing")[id-1]; var ans = $(item).find(".liSing-bg")[score[id]]; $(ans).click(); } 17春《大学英语》(三)作业_3 var score = {'1':'0','2':'1','3':'2','4':'0','5':'1','6':'3','7':'2','8':'0','9':'2','10':'2','11':'2','12':'2','13':'2','14':'1','15':'3','16':'1','17':'1','18':'0','19':'0','20':'1','21':'1','22':'1','23':'0','24':'2','25':'0'}; $(".examMain").each(function(){ var id = $(this).attr("mainqueid"); var option = $(this).find(".options-c.correct").attr("sansid"); score[id] = option; }); for (var id in score) { var item = $(".uniQueItem.singItem.examSing")[id-1]; var ans = $(item).find(".liSing-bg")[score[id]]; $(ans).click(); } 17春《大学英语》(三)作业_4 var score = {'1':'3','2':'0','3':'1','4':'0','5':'3','6':'2','7':'1','8':'2','9':'3','10':'2','11':'2','12':'2','13':'1','14':'1','15':'1','16':'0','17':'1','18':'3','19':'3','20':'0','21':'1','22':'3','23':'3','24':'0','25':'1'} for (var id in score) { var item = $(".uniQueItem")[id-1]; if ($(item).hasClass("examSing")) { console.info('单选'); var ans = $(item).find(".liSing-bg")[score[id]]; $(ans).click(); } else if ($(item).hasClass("examMutli")) { console.info('多选'); var option = score[id].split(","); for(var optId in option) { console.info(id, option[optId], $(ans).attr("ansid")) var ans = $(item).find(".liMut-bg")[option[optId]]; $(ans).click(); } } else if ($(item).hasClass("examJudge")) { console.info('判断'); console.info(id,score[id], item); var ans = $(item).find(".judge li>span")[score[id]]; $(ans).click(); } } 17春《计算机应用基础》作业_1 var score = {'1':'2','2':'2','3':'1','4':'2','5':'3','6':'0','7':'1','8':'1','9':'2','10':'3','11':'1','12':'3','13':'0','14':'1','15':'0','16':'1','17':'3','18':'0,3','19':'0,3','20':'1,3','21':'1','22:'1','23':'0','24':'1','25':'0'} for (var id in score) { var item = $(".uniQueItem")[id-1]; if ($(item).hasClass("examSing")) { console.info('单选'); var ans = $(item).find(".liSing-bg")[score[id]]; $(ans).click(); } else if ($(item).hasClass("examMutli")) { console.info('多选'); var option = score[id].split(","); for(var optId in option) { console.info(id, option[optId], $(ans).attr("ansid")) var ans = $(item).find(".liMut-bg")[option[optId]]; $(ans).click(); } } else if ($(item).hasClass("examJudge")) { console.info('判断'); console.info(id,score[id], item); var ans = $(item).find(".judge li>span")[score[id]]; $(ans).click(); } } 17春《计算机应用基础》作业_2 var score = {'1':'3','2':'2','3':'2','4':'0','5':'0','6':'3','7':'3','8':'2','9':'1','10':'2','11':'0','12':'1','13':'1','14':'0','15':'3','16':'2','17':'2','18':'0,3','19':'0,2','20':'0,2','21':'0','22:'0','23':'1','24':'1','25':'1'}; for (var id in score) { var item = $(".uniQueItem")[id-1]; if ($(item).hasClass("examSing")) { console.info('单选'); var ans = $(item).find(".liSing-bg")[score[id]]; $(ans).click(); } else if ($(item).hasClass("examMutli")) { console.info('多选'); var option = score[id].split(","); for(var optId in option) { console.info(id, option[optId], $(ans).attr("ansid")) var ans = $(item).find(".liMut-bg")[option[optId]]; $(ans).click(); } } else if ($(item).hasClass("examJudge")) { console.info('判断'); console.info(id,score[id], item); var ans = $(item).find(".judge li>span")[score[id]]; $(ans).click(); } } 17春《计算机应用基础》作业_3 var score = {'1':'3','2':'3','3':'3','4':'3','5':'0','6':'0','7':'3','8':'1','9':'3','10':'0','11':'1','12':'1','13':'1','14':'0','15':'0','16':'0','17':'0','18':'0,1','19':'0,1','20':'0,2,3','21':'1','2':'1','23':'1','24':'1','25':'1'}; for (var id in score) { var item = $(".uniQueItem")[id-1]; if ($(item).hasClass("examSing")) { console.info('单选'); var ans = $(item).find(".liSing-bg")[score[id]]; $(ans).click(); } else if ($(item).hasClass("examMutli")) { console.info('多选'); var option = score[id].split(","); for(var optId in option) { console.info(id, option[optId], $(ans).attr("ansid")) var ans = $(item).find(".liMut-bg")[option[optId]]; $(ans).click(); } } else if ($(item).hasClass("examJudge")) { console.info('判断'); console.info(id,score[id], item); var ans = $(item).find(".judge li>span")[score[id]]; $(ans).click(); } } 17春《计算机应用基础》作业_4 var score ={'1':'3','2':'0','3':'3','4':'2','5':'3','6':'3','7':'1','8':'1','9':'2','10':'1','11':'2','12':'1','13':'3','14':'3','15':'0','16':'1','17':'3','18':'1,3','19':'0,1','20':'1,2','21':'0','22''1','23':'0','24':'1','25':'0'} for (var id in score) { var item = $(".uniQueItem")[id-1]; if ($(item).hasClass("examSing")) { console.info('单选'); var ans = $(item).find(".liSing-bg")[score[id]]; $(ans).click(); } else if ($(item).hasClass("examMutli")) { console.info('多选'); var option = score[id].split(","); for(var optId in option) { console.info(id, option[optId], $(ans).attr("ansid")) var ans = $(item).find(".liMut-bg")[option[optId]]; $(ans).click(); } } else if ($(item).hasClass("examJudge")) { console.info('判断'); console.info(id,score[id], item); var ans = $(item).find(".judge li>span")[score[id]]; $(ans).click(); } } |