如何获取传智教育高校教辅平台的题库中的所有题目信息
- 如何获取题库API接口
1,打开系统题库,如https://tch.ityxb.com/teaching/141bf4f969044ae3890d99cc15246353/questionBank/list?sys=1
2,按 F12 键, 选择 Network
选项卡,刷新页面,找到接口请求,如https://tch.ityxb.com/back/bxg/question/queryQuestion?pageSize=20&pageNumber=1&point=&searchType=1&questionContent=&textbook=141bf4f969044ae3890d99cc15246353&chapter=&questionType=&difficulty=&question_content=&t=1712745681047,复制该接口地址。
3,复制 URL, 打开浏览器,输入该地址,按回车键,即可看到题目信息。将 pageSize 改为 10000
或大一些,可以获取更多题目信息。 4,将获取到的题目信息保存到本地,如test.json 文件。 5,使用 Python 脚本读取
test.json 文件,获取题目信息。
import json
# 0-单选
# 1-多选
# 2-判断
# 3-填空
# 4-简答
# 题型-questionType
# 难度-difficulty
# 题目-questionContent
# 选项-options
# 答案-answer
```python
with open('test.json', 'r', encoding='utf-8') as file:
data = json.load(file)
dtype = {"0": "单选", "1": "多选", "2": "判断", "3": "填空", "4": "简答"}
res_str = ""
for i in range(len(data['data']['records'])):
print(i, end="##")
print(dtype[data['data']['records'][i]['questionType']], end="##")
print(data['data']['records'][i]['difficulty'], end="##")
print(data['data']['records'][i]['questionContent'], end="##")
if data['data']['records'][i]['questionType'] in "01":
print(data['data']['records'][i]['options'], end="##")
print(data['data']['records'][i]['answer'], end="\n")
res_str += (str(i) + "##" + dtype[data['data']['records'][i]['questionType']] + "##" + data['data']['records'][i]['difficulty'] +
"##" + data['data']['records'][i]['questionContent'] + "##" + data['data']['records'][i]['answer'] + "\n")
open('Linux_题库.txt', 'w', encoding='utf-8').write(res_str)