针对河南大学数据结构傻逼学堂在线的自动化脚本

首先展示一下我们的答案

复制代码
{'1': ['对象'], '2': ['关系']}
{'1': ['非数值计算'], '2': ['操作']}
{'1': ['线性表']}
['D']
['B']
['B']
['C']
['C']
{'1': ['操作']}
{'1': ['数据关系', '数据对象上关系的集合']}
{'1': ['性质相同']}
{'1': ['物理结构']}
{'1': ['存储结构', '操作表示']}
['C']
['B']
['D']
['B']
['D']
['true']
['false']
['false']
['false']
['true']
['C']
['B']
['A']
['C']
['D']
['false']
['false']
['false']
['false']
['false']
['C']
['B']
['D']
['A']
['D']
['C']
['B']
['D']
['A']
['A']
{'1': ['栈']}
{'1': ['链栈', '链式栈']}
{'1': ['先进先出']}
{'1': ['队头'], '2': ['队尾']}
['B']
['C']
['C']
['C']
['D']
{'1': ['后进先出']}
{'1': ['具有递归特性的数据结构', '递归的数据结构'], '2': ['可递归求解的问题', '可以递归求解的问题']}
{'1': ['分治法']}
{'1': ['递归部分', '递归步骤']}
['B']
['B']
['C']
['B']
['C']
{'1': ['s, 'WORKER', t', 's, 'WORKER', t', 's, 'WORKER', t', 's, 'WORKER', t'], '2': [' 'GOOD BOY'', 'GOOD BOY']}
{'1': ['模式匹配']}
{'1': ['空串']}
{'1': ['堆式顺序存储结构']}
{'1': ['链式存储']}
['D']
['B']
['A']
['B']
['C']
{'1': ['01122']}
{'1': ['01123']}
{'1': ['数据元素是一个字符', '数据元素是单个字符']}
{'1': ['当前位置']}
{'1': ['7 ']}
['D']
['A']
['B']
['D']
['C']
['B']
['B']
['B']
['D']
['C']
{'1': ['非线性']}
{'1': ['1', '一']}
{'1': ['度']}
{'1': ['最大']}
{'1': ['0', '零']}
{'1': ['1']}
{'1': ['383']}
{'1': ['32']}
{'1': ['9']}
{'1': ['11']}
{'1': ['A'], '2': ['J']}
{'1': ['E'], '2': ['H']}
{'1': ['C']}
['true']
['true']
['false']
['true']
['false']
['A']
['B']
['B']
['C']
['D']
['C']
['C']
['A']
['D']
['B']
{'1': ['空']}
{'1': ['n1-1'], '2': ['n2+n3']}
{'1': ['双亲'], '2': ['孩子兄弟']}
['true']
['false']
['true']
['false']
['true']
{'1': ['叶子']}
{'1': ['6'], '2': ['261']}
{'1': ['2n-1']}
{'1': ['前缀', '最优前缀']}
['A']
['B']
['A']
['B']
['D']
{'1': ['最小']}
{'1': ['贪心算法思想', '贪心算法的思想'], '2': ['动态规划思想', '动态规划的思想']}
{'1': ['Dijkstra'], '2': ['Floyd']}
['D']
['C']
['D']
['C']
['A']
['A']
['C']
['A']
['A']
['B']
{'1': ['静态查找表', '动态查找表'], '2': ['动态查找表', '静态查找表']}
{'1': ['平均查找长度']}
{'1': ['主关键字']}
['C']
['D']
['A']
['A']
['D']
['B']
['C']
['true']
['false']
['C']
['A']
['C']
['true']
['true']
['true']
['true']
['false']
['C']
['D']
['A']
{'1': ['查找']}
{'1': ['内部排序']}
{'1': ['空间效率'], '2': ['稳定性']}
{'1': ['插入排序']}
['false']
['true']
['true']
['false']
['true']
['false']
['true']
['true']
['true']
['false']
['true']
['true']
['false']
['true']
['false']
['true']
['false']
['true']
['false']
['true']
['false']

经过抓包分析

其答案在data.problems[0].user.answer下

而且对于填空题它是answers{}

为此写了一个小的处理

让其可以提取到两类答案

对的这是源码

复制代码
import requests
j=0
for i in range(3845905,3846006):

    url = f"https://www.xuetangx.com/api/v1/lms/exercise/get_exercise_list/{i}/9357137/"
    headers = {
        "Accept": "application/json, text/plain, */*",
        "Accept-Encoding": "gzip, deflate, br, zstd",
        "Accept-Language": "zh",
        "App-Name": "xtzx",
        "Cache-Control": "no-cache",
        "Content-Type": "application/json",
        "Cookie": "_abfpc=73f3154febe39bed2d1a540a8a94f67551d2d361_2.0; cna=0e5d0ea34bdd926182ad8f3ecbef9aec; mode_type=normal; provider=xuetang; django_language=zh; point={%22point_active%22:true%2C%22platform_task_active%22:true%2C%22learn_task_active%22:true}; 59584271video_seconds=146; 77831809video_seconds=3; login_type=WX; csrftoken=BSJSNDMqRjXmygIMUjRE9kVD1dGetAh5; sessionid=n0ghs2l1c5dct15z0nlzxwztq6qzob92; k=59584271; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2259584271%22%2C%22first_id%22%3A%2219025a34692932-03fb6f51d259324-4c657b58-1638720-19025a346931fb3%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.bing.com%2F%22%7D%2C%22%24device_id%22%3A%2219025a34692932-03fb6f51d259324-4c657b58-1638720-19025a346931fb3%22%7D; JG_016f5b1907c3bc045f8f48de1_PV=1718967129887|1718968519390",
        "Django-Language": "zh",
        "Pragma": "no-cache",
        "Priority": "u=1, i",
        # "Referer": "https://www.xuetangx.com/learn/henu08091007584/henu08091007584/19322491/exercise/43306490",

        "Sec-Ch-Ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Microsoft Edge\";v=\"126\"",
        "Sec-Ch-Ua-Mobile": "?0",
        "Sec-Ch-Ua-Platform": "\"Windows\"",
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-origin",
        "Terminal-Type": "web",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0",
        "X-Client": "web",
        "X-Csrftoken": "BSJSNDMqRjXmygIMUjRE9kVD1dGetAh5",
        "Xtbz": "xt"
    }



    response = requests.get(url, headers=headers)
    data = response.json()

    try:
        anwser_list = data["data"]["problems"]
        j=j+1
        print(j)
    except:
        continue
    for list in anwser_list:
        try:
            print(list["user"]["answer"])
        except:
            print(list["user"]["answers"])

不过需要注意的是,你要F12自己抓包一下

将Cookie和X-Csrftoken搞到,然后沾到对应的请求头上

不过这还没啥

重点是:

自动填答案脚本

复制代码
from time import sleep
import requests

def promble_get(exce_idd):
    url = f"https://www.xuetangx.com/api/v1/lms/exercise/get_exercise_list/{exce_idd}/9357137/"

    headers = {
        "Accept": "application/json, text/plain, */*",
        "Accept-Encoding": "gzip, deflate, br, zstd",
        "Accept-Language": "zh",
        "App-Name": "xtzx",
        "Cache-Control": "no-cache",
        "Content-Type": "application/json",
        #替换成自己的
        "Cookie": "_abfpc=73f3154febe39bed2d1a540a8a94f67551d2d361_2.0; cna=0e5d0ea34bdd926182ad8f3ecbef9aec; mode_type=normal; provider=xuetang; django_language=zh; point={%22point_active%22:true%2C%22platform_task_active%22:true%2C%22learn_task_active%22:true}; 77831809video_seconds=3; 59584271video_seconds=151; undefinedvideo_seconds=151; login_type=P; csrftoken=dadHEX0qMOTyNfvQbDNd2zm3Fu1VoVtG; sessionid=9ml5t7q958j7rnd03owedypb5ek7oqb5; k=77831809; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2277831809%22%2C%22first_id%22%3A%2219025a34692932-03fb6f51d259324-4c657b58-1638720-19025a346931fb3%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.bing.com%2F%22%7D%2C%22%24device_id%22%3A%2219025a34692932-03fb6f51d259324-4c657b58-1638720-19025a346931fb3%22%7D; JG_016f5b1907c3bc045f8f48de1_PV=1718967129887|1718970073104",
        "Django-Language": "zh",
        "Pragma": "no-cache",
        "Priority": "u=1, i",
        "Referer": "https://www.xuetangx.com/learn/henu08091007584/henu08091007584/19322491/exercise/43306308",
        "Sec-Ch-Ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Microsoft Edge\";v=\"126\"",
        "Sec-Ch-Ua-Mobile": "?0",
        "Sec-Ch-Ua-Platform": "\"Windows\"",
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-origin",
        "Terminal-Type": "web",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0",
        "X-Client": "web",
        #替换成自己的
        "X-Csrftoken": "dadHEX0qMOTyNfvQbDNd2zm3Fu1VoVtG",
        "Xtbz": "xt"
    }

    response = requests.get(url, headers=headers)
    datad = response.json()
    anwerlist = datad["data"]["problems"]
    list = []
    for ll in anwerlist:
        list.append(ll["problem_id"])
    return list

exce_id = [3845905, 3845907, 3845910, 3845913, 3845915, 3845917, 3845920, 3845923, 3845925,
 3845929, 3845931, 3845933, 3845936, 3845939, 3845942, 3845945, 3845948, 3845954,
 3845957, 3845960, 3845962, 3845964, 3845967, 3845970, 3845971, 3845973, 3845976,
 3845979, 3845982, 3845984, 3845987, 3845988, 3845990, 3845991,
    3845992, 3845993,3845995, 3845997,
    3845998, 3845999, 3846000, 3846002, 3846004, 3846005]

leaf_id = [
    43306297,
    43306301,
    43306308,
    43306312,
    43306316,
    43306323,
    43306328,
    43306335,
    43306340,
    43306346,
    43306350,
    43306358,
    43306363,
    43306368,
    43306374,
    43306380,
    43306386,
    43306398,
    43306404,
    43306410,
    43306415,
    43306421,
    43306428,
    43306433,
    43306438,
    43306444,
    43306449,
    43306456,
    43306463,
    43306468,
    43306472,
    43306475,
    43306478,
    43306480,
    43306482,
    43306486,
    43306490,
    43306493,
    43306496,
    43306499,
    43306503,
    43306505,
    43306509,
    43306512
]
data = [
    [1,
     {1: "对象", 2: "关系"},
     {1: "非数值计算", 2: "操作"},
     {1: "线性表"}
    ],
    [2,
     ["D"],
     ["B"],
     ["B"],
     ["C"],
     ["C"]
    ],
    [3,
     {1: "操作"},
     {1: "数据关系,数据对象上关系的集合"},
     {1: "性质相同"},
     {1: "物理结构"},
     {1: "存储结构, 操作表示"}
    ],
    [4,
     ['C'],
     ['B'],
     ['D'],
     ['B'],
     ['D']
    ],
    [5,
     ['true'],
     ['false'],
     ['false'],
     ['false'],
     ['true']
    ],
    [6,
     ['C'],
     ['B'],
     ['A'],
     ['C'],
     ['D']
    ],
    [7,
     ['false'],
     ['false'],
     ['false'],
     ['false'],
     ['false']
    ],
    [8,
     ['C'],
     ['B'],
     ['D'],
     ['A'],
     ['D']
    ],
    [9,
     ['C'],
     ['B'],
     ['D'],
     ['A'],
     ['A']
    ],
    [10,
     {1: "栈"},
     {1: "链栈, 链式栈"},
     {1: "先进先出"},
     {1: "队头", '2': "队尾"}
    ],
    [11,
     ['B'],
     ['C'],
     ['C'],
     ['C'],
     ['D']
    ],
    [12,
     {1: "后进先出"},
     {1: "具有递归特性的数据结构, 递归的数据结构", 2: "可递归求解的问题, 可以递归求解的问题"},
     {1: "分治法"},
     {1: "递归部分, 递归步骤"}
    ],
    [13,
     ['B'],
     ['B'],
     ['C'],
     ['B'],
     ['C']
    ],
    [14,
     {1: "s, 'WORKER', t, s, 'WORKER', t, s, 'WORKER', t, s, 'WORKER', t", '2': " 'GOOD BOY', GOOD BOY"},
     {1: "模式匹配"},
     {1: "空串"},
     {1: "堆式顺序存储结构"},
     {1: "链式存储"}
    ],
    [15,
     ['D'],
     ['B'],
     ['A'],
     ['B'],
     ['C']
    ],
    [16,
     {1: "01122"},
     {1: "01123"},
     {1: "数据元素是一个字符, 数据元素是单个字符"},
     {1: "当前位置"},
     {1: 7 }
    ],
    [17,
     ['D'],
     ['A'],
     ['B'],
     ['D'],
     ['C']
    ],
    [18,
     ['B'],
     ['B'],
     ['B'],
     ['D'],
     ['C']
    ],
    [19,
     {1: "非线性"},
     {1: "1, 一"},
     {1: "度"},
     {1: "最大"},
     {1: "0, 零"}
    ],
    [20,
     {1: "1"},
     {1: "383"},
     {1: "32"},
     {1: "9"},
     {1: "11"}
    ],
    [21,
     {1: "A", 2: "J"},
     {1: "E", 2: "H"},
     {1: "C"}
    ],
    [22,
     ['true'],
     ['true'],
     ['false'],
     ['true'],
     ['false']
    ],
    [23,
     ['A'],
     ['B'],
     ['B'],
     ['C'],
     ['D']
    ],
    [24,
     ['C'],
     ['C'],
     ['A'],
     ['D'],
     ['B']
    ],
    [25,
     {1: "空"},
     {1: "n1-1", 2: "n2+n3"},
     {1: "双亲", 2: "孩子兄弟"}
    ],
    [26,
     ['true'],
     ['false'],
     ['true'],
     ['false'],
     ['true']
    ],
    [27,
     {1: "叶子"},
     {1: "6", 2: "261"},
     {1: "2n-1"},
     {1: "前缀, 最优前缀"}
    ],
    [28,
     ['A'],
     ['B'],
     ['A'],
     ['B'],
     ['D']
    ],
    [29,
     {1: "最小"},
     {1: "贪心算法思想, 贪心算法的思想", 2: "动态规划思想, 动态规划的思想"},
     {1: "Dijkstra", 2: "Floyd"}
    ],
    [30,
     ['D'],
     ['C'],
     ['D'],
     ['C'],
     ['A']
    ],
    [31,
     ['A'],
     ['C'],
     ['A'],
     ['A'],
     ['B']
    ],
    [32,
     {1: "静态查找表, 动态查找表", 2: "动态查找表, 静态查找表"},
     {1: "平均查找长度"},
     {1: "主关键字"}
    ],
    [33,
     ['C'],
     ['D'],
     ['A']
    ],
    [34,
     ['A'],
     ['D'],
     ['B']
    ],
    [35,
     ['C'],
     ['true'],
     ['false']
    ],
    [36,
     ['C'],
     ['A'],
     ['C'],
     ['true'],
     ['true']
    ],
    [37,
     ['true'],
     ['true'],
     ['false']
    ],
    [38,
     ['C'],
     ['D'],
     ['A']
    ],
    [39,
     {1: "查找"},
     {1: "内部排序"},
     {1: "空间效率", 2: "稳定性"},
     {1: "插入排序"}
    ],
    [40,
     ['false'],
     ['true'],
     ['true'],
     ['false'],
     ['true']
    ],
    [41,
     ['false'],
     ['true'],
     ['true'],
     ['true']
    ],
    [42,
     ['false'],
     ['true'],
     ['true'],
     ['false']
    ],
    [43,
     ['true'],
     ['false'],
     ['true']
    ],
    [44,
     ['false'],
     ['true'],
     ['false'],
     ['true'],
     ['false']
    ]
]
i = -1

for item in data:
    # print(item)
    url = "https://www.xuetangx.com/api/v1/lms/exercise/problem_apply/"
    # 设置HTTP头信息
    headers = {
        "Accept": "application/json, text/plain, */*",
        "Accept-Encoding": "gzip, deflate, br, zstd",
        "Accept-Language": "zh",
        "App-Name": "xtzx",
        "Cache-Control": "no-cache",
        "Content-Type": "application/json",
        # 必要的
        "Cookie": "_abfpc=73f3154febe39bed2d1a540a8a94f67551d2d361_2.0; cna=0e5d0ea34bdd926182ad8f3ecbef9aec; mode_type=normal; provider=xuetang; django_language=zh; point={%22point_active%22:true%2C%22platform_task_active%22:true%2C%22learn_task_active%22:true}; 77831809video_seconds=3; 59584271video_seconds=151; undefinedvideo_seconds=151; login_type=P; csrftoken=dadHEX0qMOTyNfvQbDNd2zm3Fu1VoVtG; sessionid=9ml5t7q958j7rnd03owedypb5ek7oqb5; k=77831809; sensorsdata2015jssdkcross=%7B%22distinct_id%22%3A%2277831809%22%2C%22first_id%22%3A%2219025a34692932-03fb6f51d259324-4c657b58-1638720-19025a346931fb3%22%2C%22props%22%3A%7B%22%24latest_traffic_source_type%22%3A%22%E8%87%AA%E7%84%B6%E6%90%9C%E7%B4%A2%E6%B5%81%E9%87%8F%22%2C%22%24latest_search_keyword%22%3A%22%E6%9C%AA%E5%8F%96%E5%88%B0%E5%80%BC%22%2C%22%24latest_referrer%22%3A%22https%3A%2F%2Fwww.bing.com%2F%22%7D%2C%22%24device_id%22%3A%2219025a34692932-03fb6f51d259324-4c657b58-1638720-19025a346931fb3%22%7D; JG_016f5b1907c3bc045f8f48de1_PV=1718967129887|1718970073104",
        "Django-Language": "zh",
        "Origin": "https://www.xuetangx.com",
        "Pragma": "no-cache",
        "Referer": "https://www.xuetangx.com/learn/henu08091007584/henu08091007584/19322491/exercise/43306496",
        "Sec-Ch-Ua": "\"Not/A)Brand\";v=\"8\", \"Chromium\";v=\"126\", \"Microsoft Edge\";v=\"126\"",
        "Sec-Ch-Ua-Mobile": "?0",
        "Sec-Ch-Ua-Platform": "\"Windows\"",
        "Sec-Fetch-Dest": "empty",
        "Sec-Fetch-Mode": "cors",
        "Sec-Fetch-Site": "same-origin",
        "Terminal-Type": "web",
        "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36 Edg/126.0.0.0",
        "X-Client": "web",
        # 必要的
        "X-Csrftoken": "dadHEX0qMOTyNfvQbDNd2zm3Fu1VoVtG",
        "Xtbz": "xt"
    }
    i += 1
    j = 0
    problem_id_list = promble_get(exce_id[i])
    for item_true in item[1:]:
        print(item_true)
        print(problem_id_list[j])
        data = {
            "leaf_id": leaf_id[i],
            "classroom_id": 19322491,
            "exercise_id": exce_id[i],
            "problem_id": problem_id_list[j],
            "sign": "henu08091007584",
            "answers": str(item_true),
            "answer": str(item_true),
        }
        j+=1
        sleep(5)
        response = requests.post(url, headers=headers, json=data)
        print(response.json())

同理也是那两个换成自己的

然后这个可能有点不一样

很简单自己交个题打开网络抓包,对应的改改进行了

已经经过博主测试,代码可行,可以自动填答案哈哈

解放你的双手吧老弟

相关推荐
tuokuac3 小时前
docker中nginx配置报错解决
linux·运维·服务器
Joren的学习记录4 小时前
【Linux运维大神系列】docker详解(四)
linux·运维·docker
Elastic 中国社区官方博客5 小时前
让我们把这个 expense 工具从 n8n 迁移到 Elastic One Workflow
大数据·运维·elasticsearch·搜索引擎·ai·信息可视化·全文检索
( •̀∀•́ )9206 小时前
GitHub Actions SSH 部署密钥
运维·ssh·github
louqle6 小时前
docker基本知识及常用命令汇总
运维·docker·容器
学烹饪的小胡桃6 小时前
【运维学习】实时性能监控工具 WGCLOUD v3.6.2 更新介绍
linux·运维·服务器·学习·工单系统
叫致寒吧6 小时前
Docker
运维·docker·容器
菜鸟233号6 小时前
力扣669 修剪二叉搜索树 java实现
java·数据结构·算法·leetcode
白露与泡影7 小时前
使用systemd,把服务装进 Linux 心脏里~
linux·运维·python
l1t8 小时前
用docker安装oracle 19c
运维·数据库·docker·oracle·容器