在线考试翻页抓取题目导出js

在线考试翻页抓取题目导出js

bash 复制代码
// 自动翻页 
(async function() {
  var ex = window.__kmsExamine;
  var total = 50;
  var allQuestions = [];

  for (var i = 0; i < total; i++) {
    // 直接读当前题数据
    var topic = ex.__currentExamTopic;
    if (topic) {
      allQuestions.push({
        order: i + 1,
        type: topic.typeNameText || topic.typeName,
        subject: topic.subject,
        options: topic.options || []
      });
      console.log('✓ 第' + (i+1) + '题: ' + (topic.subject||'').slice(0,20));
    }

    if (i < total - 1) {
      // 模拟点下一题
      ex.__jumpOrder = i + 1;
      ex.__jumpFdId = ex._fdId_;
      await new Promise(function(resolve) {
        // 拦截数据加载完成
        var origInit = ex.__initTopic__;
        // 直接点击下一题按钮
        document.querySelector('#lui-id-62, [title="下一题"]').click();
        setTimeout(resolve, 1200);
      });
    }
  }

  // 生成Word
  var html = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns="http://www.w3.org/TR/REC-html40"><head><meta charset="utf-8"><style>body{font-family:宋体;font-size:12pt;line-height:2}.q{margin-bottom:16px}.qt{font-weight:bold}.op{margin-left:2em}</style></head><body><h2 style="text-align:center">26年交付体系制度考核-二次开发类</h2>';

  allQuestions.forEach(function(q) {
    html += '<div class="q"><div class="qt">' + q.order + '.【' + q.type + '】' + q.subject + '</div>';
    (q.options || []).forEach(function(opt) {
      html += '<div class="op">' + opt.value + '. ' + opt.text + '</div>';
    });
    html += '</div>';
  });
  html += '</body></html>';

  var blob = new Blob(['\ufeff' + html], {type: 'application/msword'});
  var a = document.createElement('a');
  a.href = URL.createObjectURL(blob);
  a.download = '考试题目.doc';
  a.click();

  console.log('✅ 完成!共' + allQuestions.length + '题');
  window.__examQuestions = allQuestions;
})();
相关推荐
神仙别闹3 小时前
基于 C++ 实现(控制台)学生成绩管理系统
开发语言·c++
伞伞悦读3 小时前
【第36期】Python 目录与路径详解:pathlib、文件遍历、创建、复制、移动和删除风险
开发语言·python
GreenTea4 小时前
GrokBot 核心成员 Lauren Tan:每月交付 2000 个 PR 的人,是怎么用 AI 的
前端·后端·架构
mCell5 小时前
用 Knip 清理 AI Coding 留下的冗余代码
前端·ai编程·前端工程化
笃行3506 小时前
使用Rokid AIUI做了一个童年推箱子游戏
前端
2601_966949656 小时前
只拿到股票代码还不够:量化程序到底还需要哪些标的信息?——从数据建模开始理解股票元数据
开发语言·python·数据分析·pandas·量化交易·股票数据·quantdash
m0_734571766 小时前
深入理解5g <十八>传输块tbsize的计算
开发语言·5g
excel7 小时前
前端加密的作用与使用场景
前端
RAN11426760088 小时前
1.3第一个程序的介绍
开发语言·qt
计算机魔术师8 小时前
纽约时报版权诉讼披露:微软高管内部称训练 AI 是人类历史上最大规模劳动窃取
前端