今⽇校园⾃动健康上报⾃动填表疫情上报!Python⽜逼!
开发环境
•python3.0
-----⾃动填表/打卡/上报原理
其实也就是模拟⼀个数据包,调⽤今⽇校园的api;实现登⼊功能;然后查未填写的表;倘若表的序列号已经存在你的代码包⾥⾯,就会⾃动将包数据发到职教云服务器上⾯去,倘若没有,将会把表⾃动打包程json;然后你只需要编辑下json数据,以后这个序列的包就可以⾃动提交了
-----使⽤说明
理论上⽀持⼤部分学校(IAP登录⽅式,⾃⼰先试试能⽤不)和任意表单内容的⾃定义。⽬前已知两种学⼯号登录⽅式,均已实现。运⾏以下命令即可
pip install -
python3 DailyCP.py 学校全名学号密码定位地址
12
注意系统时间是否设置正确
Linux下可以使⽤corntab -e设置定时任务让程序每天⾃动打卡(下⾯的是设置0-9点触发的)
0 9 * * * python3 DailyCP.py 学校全名学号密码定位地址
1
•部分代码(主要函数)
import requests
import json
import io
import random
import time
import re
import pyDes
import base64
import uuid
import sys
import os
from Crypto.Cipher import AES
class DailyCP:
def __init__(self, schoolName="合肥学院"):
self.key = "ST83=@XV"#dynamic when app update self.session = requests.session
self.host = ""
self.loginUrl = ""
self.isIAPLogin = True
self.session.headers.update({
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)
Chrome/83.0.4103.61 Safari/537.36 Edg/83.0.478.37",
#"X-Requested-With": "",
"Pragma": "no-cache",
"Accept": "application/json, text/plain, */*",
#"Accept":
"text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9",
# "User-Agent": "okhttp/3.12.4"
})
extension = {"deviceId":str(uuid.uuid4),"systemName":"保密级操作系统","userId":"5201314","appVersion":"8.1.13","model":"天河⼀号","lon":0.0,"systemVersion":"初号机","lat":0.0} self.session.headers.update({"Cpdaily-Extension": pt(json.dumps(extension))})
self.setHostBySchoolName(schoolName)
def setHostBySchoolName(self,schoolName):
ret = quest("static.campushoy/apicache/tenantListSort")
school = [j for i in ret["data"] for j in i["datas"] if j["name"] == schoolName]
if len(school) == 0:
print("不⽀持的学校或者学校名称错误,以下是⽀持的学校列表")
print(ret)
exit
ret = quest("httpsz://mobile.campushoy/v6/config/guest/tenant/info?ids={ids}".format(ids=school[0]["id"])) self.loginUrl = ret["data"][0]["ampUrl"]
if ret == "":
python新手代码useridprint("学校并没有申请⼊驻今⽇校园平台")
exit
print("{name}的登录地址{url}".format(name=schoolName,url=self.loginUrl))
self.host = re.findall(r"//(.*?)/",self.loginUrl)[0]
#ret = quest(ret["data"][0]["ampUrl"],parseJson=False).url
#self.isIAPLogin = "campusphere" in ret
#if not self.isIAPLogin:
# print("注意:包含AuthServer的登陆⽅式并未测试!且每⼀个学校的登录⽅式都不⼀样。")
#ret = re.findall(r"//(.*?)/",ret)
#if len(ret) == 0:
# exit
#self.host = ret[0]
def encrypt(self,text):
k = pyDes.des(self.key, pyDes.CBC, b"x01x02x03x04x05x06x07x08", pad=None, padmode=pyDes.PAD_PKCS5) ret = k.encrypt(text)
return base64.b64encode(ret).decode
def passwordEncrypt(self,text:str,key:str):
pad = lambda s: s + (len(key) - len(s) % len(key)) * chr(len(key) - len(s) % len(key))
unpad = lambda s: s[:-ord(s[len(s) - 1:])]
text = pad("TdEEGazAXQMBzEAisrYaxRRax5kmnMJnpbKxcE6jxQfWRwP2J78adKYm8WzSkfXJ"+text).encode("utf-8")
aes = de(key), AES.MODE_de("ya8C45aRrBEn8sZH"))
return base64.pt(text))
def request(self,url:str,body=None,parseJson=True,JsonBody=True,Referer=None):
url = url.format(host=self.host)
if Referer != None: self.session.headers.update({"Referer":Referer})
if body == None:ret = (url)
else:
self.session.headers.update({"Content-Type": ("application/json" if JsonBody else "application/x-www-form-urlencoded")})
ret = self.session.post(url,data=(json.dumps(body) if JsonBody else body))
if parseJson:return json.)
else:return ret
def decrypt(self,text):
k = pyDes.des(self.key, pyDes.CBC, b"x01x02x03x04x05x06x07x08", pad=None, padmode=pyDes.PAD_PKCS5) ret = k.decrypt(base64.b64decode(text))
return ret.decode
def checkNeedCaptcha(self, username):
url = "{host}/iap/checkNeedCaptcha?username={username}".format(host=self.host,username=username) ret = (url)
ret = json.)
return ret["needCaptcha"]
def generateCaptcha(self):
url = "{host}/iap/generateCaptcha?ltId={client}&codeType=2".format(host=self.host,client=self.client)
ret = (url)
t
def getBasicInfo(self):
quest("{host}/iap/tenant/basicInfo","{}")
def login(self, username, password, captcha=""):
if "campusphere" in self.loginUrl:return self.loginIAP(username,password,captcha)
else: return self.loginAuthserver(username,password,captcha)
def loginIAP(self, username, password, captcha=""):
self.session.headers.update({"X-Requested-With": ""})
client = ret[ret.find("=")+1:]
ret = quest("{host}/iap/security/lt","lt={client}".format(client=client),True,False)
client = ret["result"]["_lt"]
#ptSalt = ret["result"]["_encryptSalt"]

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。