在线考试翻页抓取题目导出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;
})();
相关推荐
Sarvartha8 小时前
final 关键字
java·开发语言
程序员Sunday9 小时前
JavaScript 事件循环面试题,宏任务与微任务怎么执行|Sunday面试指南
开发语言·javascript·面试·校招·事件循环·程序员sunday
Setsuna_F_Seiei9 小时前
前端转型 Agent 开发 06 之 Agent Memory 记忆系统(让 Agent 更智能,更懂你)
前端·agent·ai编程
zhangzeyuaaa10 小时前
Ruby 多线程、GVL(GIL)与 Mutex 完全指南
开发语言·前端·ruby
默_笙10 小时前
🌊 向量库和 ES 都查不出"关系",我只好给奶茶建了一张人脉网
前端·javascript
优选资讯10 小时前
标签打印软件怎么对接 Excel 数据
前端·excel
谢亮_vipxieliang11 小时前
用 PHP 构建轻量级 REST API:从路由到鉴权的完整实践
开发语言·后端·php
思无邪6611 小时前
用 AI 做 JS 逆向:从抓包到复现的完整方法论
开发语言·javascript·人工智能
一个风轻云淡11 小时前
GCC 和 GDB命令简单解读
java·linux·前端
H.莓飛12 小时前
【数据结构】二叉树_OJ题
linux·开发语言·数据结构·算法