一.前言
脚本用于智慧职教的课程签到,接口较为稳定。
如若认为有些用处请给予回复与评分,欢迎指出不足缺点,共同进步。
仅做个人学习使用,严禁用于其他用途。
二.开发环境
windows 11 22H2 Python 3.10 x64
三.调用模块
[Python] 纯文本查看 复制代码 import requests
import json
import datetime
四.代码
[Python] 纯文本查看 复制代码 '''
Author: 过往 Past
Date: 2022-11-01 09:12:32
LastEditors: Pycham
'''
#职教云自动签到
import requests
import json
import datetime
#全局变量区
user=""
passwd=''
headers = {"User-Agent": "Mozilla/5.0 (Linux; Android 10; 2206122SC Build/SKQ1.220303.001; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/103.0.5060.129 Mobile Safari/537.36 whatyApp whatyApiApp","content-type": "multipart/form-data; boundary=---011000010111000001101001"}
Authorization='Bearer '#职教权鉴
classsign=[]
#全局结束
def login(): #登录职教云获取token并获取权鉴
global Authorization,headers
payload = "-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"mobile\"\r\n\r\n"+user+"\r\n-----011000010111000001101001\r\nContent-Disposition: form-data; name=\"passwd\"\r\n\r\n"+passwd+"\r\n-----011000010111000001101001--\r\n\r\n"
querystring = {"token": json.loads(requests.request("POST", "https://user.icve.com.cn/m/peMobileLogin_accountLogin.action", data=payload, headers=headers).text)['token']}
Authorization = Authorization+json.loads(requests.request("POST", "https://user.icve.com.cn/m/zhzjMobile_getRestSsoToken.action", params=querystring).text)['data']["userAccessToken"]
headers["Authorization"]=Authorization
def getclass():#获取当日课程及其进行中的签到
global headers
classid=[]
del headers["content-type"]
headers['Host']='spoc-classroom.icve.com.cn'
payload = {"params": {"startDate": datetime.datetime.now().strftime("%Y-%m-%d"),"current": 1,"size": 8}}
for i in json.loads(requests.request("POST", "https://user.icve.com.cn/classroom-teaching-api/classroom/getClassroomByStudent", json=payload, headers=headers).text)['data']['data']["records"]:
classid.append([i['id'],i["courseName"]])
for i in classid:
payload = {"params": {"classroomId": i[0],"classroomTypeCode": 1},"page": {"curPage": 1,"pageSize": 10,"totalCount": 0,"totalPage": 0}}
for o in json.loads(requests.request("POST", "https://spoc-classroom.icve.com.cn/classroom-teaching-api/peClassroomActivity/student/classroomActivityList", json=payload, headers=headers).text)['data']["items"]:
if o["typeName"]=="签到":
if '已签到' not in requests.request("POST","https://spoc-classroom.icve.com.cn/classroom-teaching-api/sign/student/getSignResult",json={"params": {"id": o["recordId"]}}, headers=headers).text:
classsign.append([o["recordId"],o["id"],o["classroomName"],i[1]])
del headers["Host"]
def gosign():#启动签到
if "0" not in str(len(classsign)):
for i in classsign:
r=requests.request("POST","https://spoc-classroom.icve.com.cn/classroom-teaching-api/sign/student/updateSignStatus",
json={"params": {"id": i[0],
"activityId": i[1]}}, headers=headers)
if '签到成功' in r.text:
print(i[3]+i[2]+'签到成功')
else:
print("执行完毕没有可签到的项目")
if __name__ == '__main__':
login()
getclass()
gosign()
五.嗯..........
下个版本更新一下 微信推送 然后权鉴持久化存储 目前用着没什么问题 忽视其中的写法哈哈哈哈哈哈
土豪通道:
代码.txt
(3.13 KB, 下载次数: 30)
|