- 打开浏览器开发者工具,选择Network的Fetch/XHR
- 刷新页面找到 https://stu.ityxb.com/back/bxg/my/busywork/findStudentBusywork?busyworkId=2a6803xxxxxx
复制Response的所有内容 - 将Response的内容保存为json格式的文件
- 使用Python脚本读取json文件并以excel格式输出
import glob
import pandas as pd
import json
all_questions = []
for file_path in glob.glob('*.json'):
print(file_path)
with open(file_path, 'r', encoding='utf-8') as file:
data = json.load(file)
# 提取单选题数据
for question in data['resultObject'].get('danxuan', {}).get('lists', []):
question_text = question['questionContentText']
options = [option['text'] for option in question['questionOptionList']]
ans = question['answer']
sul = question['solution']
all_questions.append([question_text] + options + [ans] + [sul])
# 提取多选题数据
for question in data['resultObject'].get('duoxuan', {}).get('lists', []):
question_text = question['questionContentText']
options = [option['text'] for option in question['questionOptionList']]
ans = question['answer']
sul = question['solution']
all_questions.append([question_text] + options + [ans] + [sul])
# 提取判断题数据
for question in data['resultObject'].get('panduan', {}).get('lists', []):
question_text = question['questionContentText']
options = [None, None, None, None]
ans = question['answer']
sul = question['solution']
all_questions.append([question_text] + options + [ans] + [sul])
print(all_questions)
# 创建DataFrame
df = pd.DataFrame(all_questions, columns=['题干/小题题干', '选项A', '选项B', '选项C', '选项D','答案','解析'])
# 保存到Excel文件
df.to_excel('oneToFive.xlsx', index=False)