1 Star 0 Fork 0

Fate_ZTC/python_study

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
wending_shua.py 2.15 KB
一键复制 编辑 原始数据 按行查看 历史
tianchengz 提交于 2024-08-27 14:46 . 增加代码提交
import requests
# 课程Id
# 低幼儿童文学名著导读 1589
# 幼儿园组织与管理 1588
# 马克思主义基本原理概论 1260
# 中国近现代史纲要 1261
# 学前儿基心理健康与辅导 1590
# 幼儿区班级管理 1298
LESSON_ID = 1298
def get_lesson_hour():
url = "https://nbv.iwdjy.com/api/lesson/getLessonHour"
body = {
"id": LESSON_ID,
"token": "ROd0g2ATHMHqWUfOazakoK7M4IAvTKs9XumhMv1M4xINW",
"url": f"https://www.iwdjy.com/course-detail?id={LESSON_ID}",
"host": "www.iwdjy.com"
}
headers = {
"Content-Type": "application/json"
}
response = requests.post(url, json=body, headers=headers)
if response.status_code == 200:
return response.json()
else:
response.raise_for_status()
def process_lesson_hour_data():
try:
result = get_lesson_hour()
if 'data' in result and 'data' in result['data']:
data_array = result['data']['data']
for item in data_array:
hourId = item['id']
save_user_house(hourId)
return data_array
else:
print("返回数据中不包含预期的data字段")
return None
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
return None
def save_user_house(hourId):
url = "https://nbv.iwdjy.com/api/lesson/saveUserHour"
body = {
"hour_id": hourId,
"play_time": 3500.000888,
"face_url": "",
"token": "ROd0g2ATHMHqWUfOazakoK7M4IAvTKs9XumhMv1M4xINW",
"url": f"https://www.iwdjy.com/course-learn?id={LESSON_ID}&learnId={hourId}&teacherId=0",
"host": "www.iwdjy.com"
}
headers = {
"Content-Type": "application/json"
}
response = requests.post(url, json=body, headers=headers)
if response.status_code == 200:
print(response.json())
else:
response.raise_for_status()
# 调用函数并打印返回数据
if __name__ == "__main__":
try:
process_lesson_hour_data()
print("执行完成!")
except requests.exceptions.RequestException as e:
print(f"Request failed: {e}")
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
Python
1
https://gitee.com/Fate_ZTC/python_study.git
[email protected]:Fate_ZTC/python_study.git
Fate_ZTC
python_study
python_study
master

搜索帮助