ChatGPT助力继续教育自动答题
第一个提示词:
使用python写一个答题程序,
get调用https://gp.chinahrt.com/gp6/exam/stu/exam/go_exam?examId=a4f7819169f24119a0f6010d389210b9&isExercise=0&t=74fc6e1a-af04-4887-8c52-62a636ca923a
获取试题,结果
{
“code”: “0”,
“msg”: “成功”,
“data”: {
“blanceSeconds”: 822,
“pager”: {
“id”: “18496604-ce6b-48bb-a612-a55ab1722abe”,
“begin_at”: 1747530048039,
“end_at”: null,
“exam_duration”: 30,
“exam_name”: “碳中和背景下生物质能产业发展形势与展望”,
“exam_total_score”: null,
“exam_pass_score”: null,
“current_time”: 1747531025815,
“exam_score”: null,
“exam_result”: null,
“exam_show_result_time”: null,
“if_show_answer”: null,
“show_type”: 0,
“summary”: {
“total”: {
“items”: 5,
“score”: 100.0
},
“single”: {
“items”: 3,
“score”: 20.0
},
“multiple”: {
“items”: 0,
“score”: 0.0
},
“fill”: {
“items”: 0,
“score”: 0.0
},
“judge”: {
“items”: 2,
“score”: 20.0
},
“qa”: {
“items”: 0,
“score”: 0.0
},
“line”: {
“items”: 0,
“score”: 0.0
},
“treatise”: {
“items”: 0,
“score”: 0.0
}
},
“single_list”: [
{
“id”: “ca01e57670d44e1cb3451e89c8f5d407”,
“my_answer”: “”,
“order”: 1,
“mark”: 0,
“question”: “()是最早提出摆脱2050年对化石能源依赖的国家。”,
“choices”: {
“sort”: “ABCD”,
“list”: [
{
“choice”: “丹麦”,
“code”: “A”
},
{
“choice”: “瑞典”,
“code”: “B”
},
{
“choice”: “德国”,
“code”: “C”
},
{
“choice”: “英国”,
“code”: “D”
}
]
},
“true_answer”: null,
“get_score”: null,
“result”: null,
“analysis”: null,
“my_answer_mutl”: null,
“lineQuestion”: “()是最早提出摆脱2050年对化石能源依赖的国家。”,
“lineLeft”: null
},
{
“id”: “1b054591defb4105a314e8727ce8b1e6”,
“my_answer”: “”,
“order”: 2,
“mark”: 0,
“question”: “下列选项中,属于生物炼制的终端用户产品的是()。”,
“choices”: {
“sort”: “ABCD”,
“list”: [
{
“choice”: “纸浆、氢氟碳化物、溶剂”,
“code”: “A”
},
{
“choice”: “醋酸盐、树脂、层压板、粘合剂”,
“code”: “B”
},
{
“choice”: “香料化学品、活性炭、燃料增强剂”,
“code”: “C”
},
{
“choice”: “化肥、药品、农药、塑料、润滑油和油类”,
“code”: “D”
}
]
},
“true_answer”: null,
“get_score”: null,
“result”: null,
“analysis”: null,
“my_answer_mutl”: null,
“lineQuestion”: “下列选项中,属于生物炼制的终端用户产品的是()。”,
“lineLeft”: null
},
{
“id”: “4bd654b7e0384b09ac0d9469f3cbc8b5”,
“my_answer”: “”,
“order”: 3,
“mark”: 0,
“question”: “下列选项中,不属于交通燃料的转化途径的是()。”,
“choices”: {
“sort”: “ABCD”,
“list”: [
{
“choice”: “酯化”,
“code”: “A”
},
{
“choice”: “费托合成”,
“code”: “B”
},
{
“choice”: “热解”,
“code”: “C”
},
{
“choice”: “气化”,
“code”: “D”
}
]
},
“true_answer”: null,
“get_score”: null,
“result”: null,
“analysis”: null,
“my_answer_mutl”: null,
“lineQuestion”: “下列选项中,不属于交通燃料的转化途径的是()。”,
“lineLeft”: null
}
],
“multi_list”: [],
“fill_list”: [],
“judge_list”: [
{
“id”: “9d8aacea474e4a998f6422f61f59a498”,
“my_answer”: “”,
“order”: 4,
“mark”: 0,
“question”: “原料可获得性、产品供应链可行性、模型可扩展性等问题限制了生物炼制的商业化发展。”,
“choices”: null,
“true_answer”: null,
“get_score”: null,
“result”: null,
“analysis”: null,
“my_answer_mutl”: null,
“lineQuestion”: “原料可获得性、产品供应链可行性、模型可扩展性等问题限制了生物炼制的商业化发展。”,
“lineLeft”: null
},
{
“id”: “f7ddc76b38ad4ee08e00f12bf53fc7e2”,
“my_answer”: “”,
“order”: 5,
“mark”: 0,
“question”: “生物质能作为可再生能源的重要组成部分,被认为是实现碳减排的重要方式。”,
“choices”: null,
“true_answer”: null,
“get_score”: null,
“result”: null,
“analysis”: null,
“my_answer_mutl”: null,
“lineQuestion”: “生物质能作为可再生能源的重要组成部分,被认为是实现碳减排的重要方式。”,
“lineLeft”: null
}
],
“line_list”: [],
“qa_list”: [],
“treatise_list”: [],
“singleResultSum”: {
“rightCount”: 0,
“errorCount”: 0,
“noAnswerCount”: 3,
“score”: 0.0
},
“multiResultSum”: {
“rightCount”: 0,
“errorCount”: 0,
“noAnswerCount”: 0,
“score”: 0.0
},
“fillResultSum”: {
“rightCount”: 0,
“errorCount”: 0,
“noAnswerCount”: 0,
“score”: 0.0
},
“judgResultSum”: {
“rightCount”: 0,
“errorCount”: 0,
“noAnswerCount”: 2,
“score”: 0.0
},
“qaResultSum”: {
“rightCount”: 0,
“errorCount”: 0,
“noAnswerCount”: 0,
“score”: 0.0
},
“lineResultSum”: {
“rightCount”: 0,
“errorCount”: 0,
“noAnswerCount”: 0,
“score”: 0.0
},
“treatiseResultSum”: {
“rightCount”: 0,
“errorCount”: 0,
“noAnswerCount”: 0,
“score”: 0.0
}
},
“existSingle”: true,
“existMulti”: false,
“existFill”: false,
“existJudge”: true,
“existLine”: false,
“existQa”: false,
“existTreatise”: false,
“useName”: “N3verL4nd”,
“needCheckFace”: false
},
“success”: true
}
post调用https://gp.chinahrt.com/gp6/exam/stu/exam/submit_exam_all_answer提交答案,post使用url-encoded编码
paperId:72806965-8f69-40ef-b310-8582207ad0e0
answers:[{“id”:“56df93736f0b498b93b72c1397584ba0”,“mark”:0,“answer”:“B”},{“id”:“c91eef5b5fd546c6a3c9d66ef1aeb0f8”,“mark”:0,“answer”:“A”},{“id”:“659a5db72d284923b6b58835991abfe0”,“mark”:0,“answer”:“A”},{“id”:“87c1d326aad84b6fa7677e6045089f5e”,“mark”:0,“answer”:“0”},{“id”:“97a7cec2f0ab4e87949f9f14e5df9786”,“mark”:0,“answer”:“0”}]
gpt返回结果:
下面是一个 Python 脚本,它实现了如下功能:
使用 requests 发送 GET 请求获取试题;
解析返回的 JSON 数据;
根据试题生成模拟答案(你可以修改为根据题意自动答题或手动输入);
使用 POST 请求将答案提交回服务器。
你可以在本地运行此脚本,前提是你安装了 requests 库(通过 pip install requests 安装)。
import requests
import json
import random
import time# === 常量配置 ===
GET_URL = "https://gp.chinahrt.com/gp6/exam/stu/exam/go_exam"
POST_URL = "https://gp.chinahrt.com/gp6/exam/stu/exam/submit_exam_all_answer"
EXAM_ID = "a4f7819169f24119a0f6010d389210b9"
T_PARAM = "74fc6e1a-af04-4887-8c52-62a636ca923a"headers = {"User-Agent": "Mozilla/5.0","Content-Type": "application/x-www-form-urlencoded",# "Cookie": "your-auth-cookie-here" # ← 必须登录才有效
}def get_exam_data():params = {"examId": EXAM_ID,"isExercise": "0","t": T_PARAM}response = requests.get(GET_URL, params=params, headers=headers)return response.json()def generate_random_answers(pager):answers = []for q in pager.get("single_list", []):codes = [c["code"] for c in q["choices"]["list"]]answer = random.choice(codes)answers.append({"id": q["id"],"mark": 0,"answer": answer})for q in pager.get("judge_list", []):answer = random.choice(["0", "1"])answers.append({"id": q["id"],"mark": 0,"answer": answer})return answersdef submit_answers(paper_id, answers):data = {"paperId": paper_id,"answers": json.dumps(answers, ensure_ascii=False)}response = requests.post(POST_URL, data=data, headers=headers)return response.json()def run_loop_until_full_score():attempt = 0while True:attempt += 1print(f"第 {attempt} 次尝试获取试题并提交答案...")exam_data = get_exam_data()if exam_data.get("code") != "0":print("试题获取失败:", exam_data.get("msg"))breakpager = exam_data["data"]["pager"]paper_id = pager["id"]answers = generate_random_answers(pager)result = submit_answers(paper_id, answers)if not result.get("success"):print("提交失败:", result.get("msg"))breakscore = result["data"].get("score", 0)print(f"当前得分:{score}")if score >= 100:print("🎉 成功获得满分!")breaktime.sleep(1.5) # 防止请求过快被封# === 启动 ===
run_loop_until_full_score()
通过不端优化,形成最终的答题脚本
import requests
import json
import random
import time# === 常量配置 ===
EXAM_LIST_URL = "https://gp.chinahrt.com/gp6/exam/stu/exam/examList"
GET_URL = "https://gp.chinahrt.com/gp6/exam/stu/exam/go_exam"
POST_URL = "https://gp.chinahrt.com/gp6/exam/stu/exam/submit_exam_all_answer"headers = {"User-Agent": "Mozilla/5.0","Content-Type": "application/x-www-form-urlencoded","hrttoken": "换成你自己的token"
}def get_latest_exam_id():params = {"isHistory": 0,"curPage": 1,"pageSize": 10,"examResult": 103001}response = requests.get(EXAM_LIST_URL, params=params, headers=headers)data = response.json()if data.get("code") != "0":print("获取考试列表失败:", data.get("msg"))return Nonefor exam in data["data"]["data"]:print(f"选定考试:《{exam['name']}》")return exam["id"]print("没有找到可用的考试。")return Nonedef get_exam_data(exam_id):params = {"examId": exam_id,"isExercise": "0"}response = requests.get(GET_URL, params=params, headers=headers)return response.json()def generate_random_answers(pager):answers = []for q in pager.get("single_list", []):codes = [c["code"] for c in q["choices"]["list"]]answer = random.choice(codes)answers.append({"id": q["id"],"mark": 0,"answer": answer})for q in pager.get("judge_list", []):answer = random.choice(["0", "1"])answers.append({"id": q["id"],"mark": 0,"answer": answer})return answersdef submit_answers(paper_id, answers):data = {"paperId": paper_id,"answers": json.dumps(answers, ensure_ascii=False)}response = requests.post(POST_URL, data=data, headers=headers)return response.json()def run_loop_until_full_score():while True:exam_id = get_latest_exam_id()if not exam_id:print('所有考试已通过!!!')returnattempt = 0while True:attempt += 1print(f"\n第 {attempt} 次尝试获取试题并提交答案...")exam_data = get_exam_data(exam_id)if exam_data.get("code") != "0":print("试题获取失败:", exam_data.get("msg"))breakpager = exam_data["data"]["pager"]paper_id = pager["id"]answers = generate_random_answers(pager)result = submit_answers(paper_id, answers)if not result.get("success"):print("提交失败:", result.get("msg"))breakscore = result["data"].get("score", 0)print(f"当前得分:{score}")if score >= 60:print("🎉 已通过!")breaktime.sleep(1.5) # 防止请求频率过高# === 启动程序 ===
run_loop_until_full_score()
实现的效果:自动选择未通过的考试,循环答题。
hrttoken 获取方式: