使用腾讯云函数,设置语言python3.6,模板空白函数
将index.py改成zjy.py,执行方法改成zjy.auto_signin
将下面代码的内容复制到云函数的zjy.py,修改网页中zjy.py的用户名,密码
设置内存64MB,超时4s
设置环境变量TZ=Asia/Shanghai即可
添加触发方式,使用自定义触发

注意: 是定时自动签到,运行次数过多将产生费用参考云函数定价
提示: 定时签到的话,可以添加多个云函数不产生费用,实时签到只够一个账号,该代码仅在当前存在未签到,才会去签到。

以下是触发参考
定时签到参考
9点50左右有一次签到(星期二到星期五的上午9点45-54的每五秒钟执行一次)

*/5 45-54 9 * * TUE-FRI * 

13点40左右有一次签到(星期一和星期三的下午1点35-44的每五秒钟执行一次)

*/5 35-44 13 * * MON,WED * 

实时签到参考(频率高时,返回值是Unicode编码,Unicode转中文)
上午7点到19点不定时会有签到(星期一到星期五的上午7点到19点的每五秒执行一次)

*/5 * 7-19 * * MON-FRI * 

签到成功
Unicode转中文
效果
支持常规、手势、二维码签到
代码如下,开启邮箱通知,修改mailConfig中Eanbled的值False为True,按照提示配置SMTP,开启邮箱记得调整超时。开启server酱,修改serverChan中Eanbled的值False为True,并配置SCKEY。

    # -*- coding: utf8 -*-
import requests,json,time,smtplib
from email.mime.text import MIMEText
from email.header import Header
def auto_signin(event, context):
    url_api="https://zjyapp.icve.com.cn/newmobileapi/"
    headers = {
            "Content-Type": "application/x-www-form-urlencoded","Host": "zjyapp.icve.com.cn","Connection": "Keep-Alive","Accept-Encoding": "gzip","User-Agent": "okhttp/3.10.0"
        }
    userName,userPwd="用户名","密码"
    mailConfig={
            "enabled": False,"smtp_server": "SMTP地址","smtp_port": "SMTP端口","from_addr": "发件人邮箱","from_pwd": "发件人密码","to_addr": "收件人邮箱"
            #示例#"enabled": True,"smtp_server": "smtp.163.com","smtp_port": "465","from_addr": "senyuyunkeji@163.com","from_pwd": "MXEHXOJIZUEJVMBC","to_addr": "nbem@qq.com"
        }
    serverChan={
            "enabled": True,"SCKEY": "SCU99695T6594b6299e33f0473871af96b8d368ba5ecfecf25f890"
            #示例#"enabled": True,"SCKEY": "SCU99695T6594b6299e33f0473871af96b8d368ba5ecfecf25f890"
        }
    loginData = {"clientId": "761c177f3e384716ad266782b6525db9", "sourceType": "2", "userPwd": userPwd, "userName": userName,
                 "appVersion": "2.8.23","equipmentAppVersion": "2.8.23","equipmentApiVersion":10}
    session = requests.Session()
    login=session.post(url_api + "mobilelogin/newlogin", data=loginData,headers=headers)
    loginInfo=json.loads(login.text)
    if loginInfo["code"]!=1:
        return (loginInfo["msg"])
    stuId = loginInfo["userId"]
    faceDate = (time.strftime("%Y-%m-%d", time.localtime()))
    newToken=loginInfo["newToken"]
    todayClassData = {"stuId": stuId, "faceDate": faceDate,
                      "equipmentAppVersion": "2.8.23","equipmentApiVersion":10,"newToken": newToken}
    todayClass=session.post(url_api + "faceteach/getStuFaceTeachList", data=todayClassData, headers=headers)
    todayClassInfo=json.loads(todayClass.text)["dataList"]
    result=""
    for i in range(len(todayClassInfo)):
        newToken = json.loads(session.get(url_api + "mobilelogin/getNewToken?userName=" + userName + "&userPwd=" + userPwd +"&sourceType=2&clientId=761c177f3e384716ad266782b6525db9").text)["newToken"]
        inClassData = {
            "activityId": todayClassInfo[i]["Id"], "stuId": stuId, "classState": todayClassInfo[i]["state"], "openClassId": todayClassInfo[i]["openClassId"],
            "equipmentAppVersion": "2.8.23","equipmentApiVersion":10,"newToken": newToken
        }
        inClass=session.post(url_api + "faceteach/newGetStuFaceActivityList", data=inClassData, headers=headers)
        inClassInfo=json.loads(inClass.text)["dataList"]
        for n in range(len(inClassInfo)):
            if inClassInfo[n]["DataType"] == "签到" and inClassInfo[n]["State"] != 3:
                attendData = {
                    "activityId": todayClassInfo[i]["Id"], "openClassId": todayClassInfo[i]["openClassId"], "stuId": stuId, "typeId": inClassInfo[n]["Id"], "type": "1",
                    "equipmentAppVersion": "2.8.23","equipmentApiVersion":10,"newToken": newToken
                }
                attend=session.post(url_api + "faceteach/isJoinActivities", data=attendData,headers=headers)
                attendInfo=json.loads(attend.text)
                if attendInfo["isAttend"] != 1:
                    signInData = {
                    "signId": inClassInfo[n]["Id"], "stuId": stuId, "openClassId": todayClassInfo[i]["openClassId"],"sourceType": "2", "checkInCode": inClassInfo[n]["Gesture"],"activityId": todayClassInfo[i]["Id"],
                    "equipmentAppVersion": "2.8.23","equipmentApiVersion":10,"newToken": newToken
                    }
                    signIn=session.post(url_api + "faceteach/saveStuSign", data=signInData,headers=headers)
                    signInInfo=json.loads(signIn.text)
                    signInTime=time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
                    result=result+(todayClassInfo[i]["courseName"] + " " + signInTime + " " + signInInfo["msg"])+"\r\n"
    if result == "":
        result = "当前不存在未签到"
    else:
        if mailConfig["enabled"]:
            sendMail(mailConfig["smtp_server"],mailConfig["smtp_port"],mailConfig["from_addr"],mailConfig["from_pwd"],mailConfig["to_addr"],result)
        if serverChan["enabled"]:
            sendWechat(serverChan["SCKEY"],result)
    return result.replace("\r\n", " ")
def sendWechat(SCKEY,content):
    resultData={"text": "职教云签到结果", "desp": content}
    content.replace("\r\n", "\n\n")
    requests.post("https://sc.ftqq.com/" + SCKEY + ".send",data=resultData)
def sendMail(smtp_server,smtp_port,from_addr,from_pwd,to_addr,content):
    stmp=smtplib.SMTP_SSL(smtp_server,smtp_port)
    stmp.login(from_addr,from_pwd)
    message = MIMEText(content, "plain", "utf-8")
    message["From"] = Header("职教云自动签到系统", "utf-8")
    message["From"].append("<" + from_addr + ">", 'ascii')
    message["To"] = Header("用户", "utf-8")
    message["To"].append("<" + to_addr + ">", 'ascii')
    subject = "签到结果"
    message["Subject"] = Header(subject, 'utf-8')
    try:
        stmp.sendmail(from_addr, to_addr, message.as_string())
    except Exception as e:
        print ('邮件发送失败--' + str(e))

著作权、最终解释权归原作者所有,森屿暖树仅提供原作者联系方式

Last modification:May 29th, 2020 at 10:32 pm