在线考试翻页抓取题目导出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;
})();
相关推荐
neo33011 小时前
debian13 编译源码qt5.15.18
开发语言·qt
坚持就完事了2 小时前
Linux的重定向符
运维·服务器·前端
Xiu Yan2 小时前
Java 转 C++ 系列:STL常用函数
java·开发语言·c++·stl·visual studio
爬虫练习生2 小时前
极验4ast解混淆流程
javascript
**蓝桉**2 小时前
负载均衡概述
开发语言·阿里云·云计算·负载均衡
:1212 小时前
java面试基础
java·开发语言
代码羊羊2 小时前
Rust泛型编程:从零成本抽象到极致性能
开发语言·windows·rust
小樱花的樱花2 小时前
Linux Shell命令入门
linux·服务器·开发语言
沫璃染墨2 小时前
C++ std::list 深度解析:迭代器、splice 核心接口与排序效率全解
开发语言·c++