first commit
This commit is contained in:
70
题库爬虫.py
Normal file
70
题库爬虫.py
Normal file
@@ -0,0 +1,70 @@
|
||||
import requests
|
||||
import json
|
||||
import os
|
||||
import time
|
||||
|
||||
# 试卷名URL
|
||||
url_submit = "https://www.casmooc.cn/server/api/study/submit"
|
||||
url_detail = "https://www.casmooc.cn/server/api/course/detail"
|
||||
headers = {
|
||||
'Accept': 'application/json, text/plain, */*',
|
||||
'Accept-Encoding': 'gzip, deflate, br, zstd',
|
||||
'Accept-Language': 'zh-CN,zh;q=0.9,en;q=0.8,en-GB;q=0.7,en-US;q=0.6',
|
||||
'Connection': 'keep-alive',
|
||||
'Content-Length': '118',
|
||||
'Content-Type': 'application/json;charset=UTF-8',
|
||||
'Cookie': 'BMAP_SECKEY=2Sq_06ybvD0Wg-a66PwUigT9UeYuT7Uw_ysn5t6J4OfrpszAHdr7_mkaZqRt9gnTLpUq1p-aip3ur40AYi2VtsxgVrhFaTJxoLZyGcgrMjKgCbXYmb6fc4iOVEmP77vqbRokn6fbDpi_xvHfy8HlyycbaZ_v8d3elOyE5wQuYRHTNmjOqify4LxNb9OW6bTO; SECKEY_ABVK=4xWRKdQvkKXaHdjRs0UoD2SGQ7KafNB/ESlqXVzqXe4%3D',
|
||||
'Host': 'www.casmooc.cn',
|
||||
'Origin': 'https://www.casmooc.cn',
|
||||
'Sec-Fetch-Dest': 'empty',
|
||||
'Sec-Fetch-Mode': 'cors',
|
||||
'Sec-Fetch-Site': 'same-origin',
|
||||
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36 Edg/125.0.0.0',
|
||||
'sec-ch-ua': '"Microsoft Edge";v="125", "Chromium";v="125", "Not.A/Brand";v="24"',
|
||||
'sec-ch-ua-mobile': "?0",
|
||||
'sec-ch-ua-platform': "Windows",
|
||||
'x-access-browser-info': 'chrome 125.0.0.0',
|
||||
'x-access-origin': 'aHR0cHM6Ly93d3cuY2FzbW9vYy5jbg==',
|
||||
'x-access-token': 'eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJleHAiOjE3MTg3NzU4NjcsIm9wZXJhdG9ySWQiOiIxMTA0OTI5OTg0In0.uakXO5tMLwQm1FaRnUxHSVwqWAHrpQqG9Wi0-dj5rSc',
|
||||
}
|
||||
|
||||
# 初始化一个空字典来存储试卷id和name值
|
||||
|
||||
data_submit = {
|
||||
"belongCourseId": "1711952903276",
|
||||
"courseId": "1711953127084",
|
||||
"isRecordAudio": 0,
|
||||
"lastLearnTime": 31.989123,
|
||||
"recordDuration": "3600",
|
||||
"studyLockUUID": "A4B6E763AA6D4A4DB6CC23CC84BECBEF"
|
||||
}
|
||||
|
||||
data_detail = {
|
||||
"id": "1711952903276",
|
||||
"firstCourseId": ""
|
||||
}
|
||||
response_submit = requests.post(url_submit, headers=headers, json=data_submit)
|
||||
response_detail = requests.post(url_detail, headers=headers, json=data_detail)
|
||||
# 检查响应状态码
|
||||
|
||||
if response_submit.status_code == 200:
|
||||
# 解析JSON数据
|
||||
data = response_submit.json()
|
||||
print("提交数据结果\n", data)
|
||||
|
||||
|
||||
else:
|
||||
print(f"请求失败,状态码:{response_submit.status_code}")
|
||||
|
||||
time.sleep(2)
|
||||
|
||||
|
||||
if response_detail.status_code == 200:
|
||||
# 解析JSON数据
|
||||
data = response_detail.json()
|
||||
print("视频播放进度\n", data)
|
||||
print(data['data']['trueStudyTime'])
|
||||
else:
|
||||
print(f"请求失败,状态码:{response_detail.status_code}")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user