中科大实验室安全准入教育课程(2024)
链接:https://download.youkuaiyun.com/download/weixin_56977133/89879669
第一步:下载试题文件(懒得去爬了)
找到这个url,然后修改pageSize(改大点儿)后访问
右键另存为.json
第二步:跑下面的脚本
把下面headers的cookie换成你自己的
import json
import requests
if __name__ == '__main__':
url = "https://appswh.chaoxing.com/app/quiz/test/submitPracticeAnswer"
headers = {
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) "
"Chrome/129.0.0.0 Safari/537.36",
"Cookie": "",
}
all_question = []
with open('questionManager.json', 'r', encoding='utf-8') as f:
data = json.load(f)
all_question.extend(data['data']['questionArray'])
with open('questionManager2.json', 'r', encoding='utf-8') as f:
data = json.load(f)
all_question.extend(data['data']['questionArray'])
answer = []
for question in all_question:
params = {
"questionId": question['id'],
"questionIndex": question['index'],
"choice": "A"
}
resp = requests.get(url, headers=headers, params=params)
print(resp)
data = resp.json()['data']
# print(data)
right_answers = data['rightAnswer'] # 可能是 'A' 或 'AB' 等情况
answer_list = []
for ans in right_answers:
index = ord(str.lower(ans)) - ord('a') # 计算选项的索引
answer_list.append(data['answerList'][index]) # 根据索引获取答案内容
answer_str = ', '.join(answer_list)
answer.append(f"题目: {question['questionTitle']}----答案: {right_answers}<{answer_str}>\n")
with open('questions.txt', 'w', encoding='utf-8') as f:
f.writelines(answer)
cookie就是下面的这个一大串: