关于校园通使用过程中的相关脚本

Posted 末初mochu7

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了关于校园通使用过程中的相关脚本相关的知识,希望对你有一定的参考价值。

文章目录


PS:某些词汇过不了CSDN审核,所以用英文,真的很无语

期末成绩查询

import requests
import pandas as pd
import json

studentcode_list = []
query_url = "http://www.jxusptpay.com:80/stuManagement/App/Achievement/StudentAchievement/getStudentAchievement.action"
query_headers = "Accept": "application/json, text/javascript, */*; q=0.01",
                 "X-Requested-With": "XMLHttpRequest",
                 "User-Agent": "Mozilla/5.0 (Linux; android 10; V1914A Build/QP1A.190711.020; wv) AppleWebKit/537.36 (Khtml, like Gecko) Version/4.0 Chrome/85.0.4183.101 Mobile Safari/537.36",
                 "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8",
                 "Origin": "http://www.jxusptpay.com",
                 "Referer": "http://www.jxusptpay.com/stuManagement/App/Achievement/StudentAchievement.action",
                 "Accept-Encoding": "gzip, deflate",
                 "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
                 "Connection": "close"
query_data = "pageNum": "1", "pageSize": "13", "semesterID": "5", "examinationID": "-1" # semesterID指查哪个学期
my_cookies = "studentCode": "xxxxxxx" # 提供一个任意一个班级内学号
all_data_list = []
my_resp = requests.post(url=query_url, headers=query_headers, cookies=my_cookies, data=query_data)
my_data_list = json.loads(my_resp.text)['data']['list']
first_row = [data['itemName'] for data in my_data_list]
first_row.insert(0, "姓名")
first_row.append("总分")
all_data_list.append(first_row)
for student_code in studentcode_list:
    data_row = []
    query_cookies = "studentCode": student_code
    resp = requests.post(url=query_url, headers=query_headers, cookies=query_cookies, data=query_data)
    data_list = json.loads(resp.text)['data']['list']
    stu_name = data_list[0]["name"]
    data_row.append(stu_name)
    stu_score = [data['score'] for data in data_list]
    data_row.extend(stu_score)
    data_row.append(sum(stu_score))
    all_data_list.append(data_row)
df = pd.DataFrame(all_data_list)
df.to_excel('class.xlsx')

Class Signin Automatic

需要校园通账号密码

# Python3
# Author: mochu7
import requests
import json
import datetime
import time

StudentAccount = [['张三', '账号', '密码'], ['李四', '账号', '密码'], ['王五', '账号', '密码']] # 校园通账号密码

def StudentLogin(StuId, StuPassword):
    login_url = "http://jxusptpay.com:80/StudentApp/Login/Login/StudentLogin"
    login_headers = "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0",
               "Accept": "application/json, text/javascript, */*; q=0.01",
               "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
               "Accept-Encoding": "gzip, deflate", "X-Requested-With": "XMLHttpRequest",
               "Content-Type": "multipart/form-data; boundary=---------------------------42502287411117441599485456745"
    login_data = "-----------------------------42502287411117441599485456745\\r\\n" \\
                 "Content-Disposition: form-data; name=\\"student\\"" \\
                 "\\r\\n\\r\\n\\r\\n" \\
                 "-----------------------------42502287411117441599485456745\\r\\n" \\
                 "Content-Disposition: form-data; name=\\"password\\"" \\
                 "\\r\\n\\r\\n\\r\\n" \\
                 "-----------------------------42502287411117441599485456745\\r\\n" \\
                 "Content-Disposition: form-data; name=\\"platform\\"" \\
                 "\\r\\n\\r\\n1\\r\\n" \\
                 "-----------------------------42502287411117441599485456745--\\r\\n".format(StuId, StuPassword)
    resp = session.post(url=login_url, headers=login_headers, data=login_data)
    resp_json = json.loads(resp.text)
    login_msg = resp_json['msg']
    print(resp.text)
    # print(resp.cookies)
    return login_msg, resp

def GetStuSign():
    SiginId = None
    GetStuSign_url = "http://www.jxusptpay.com:80/StudentApp/SignIn/StudentSignin/GetStudentSignIn"
    GetStuSign_headers = "Accept": "application/json, text/javascript, */*; q=0.01",
                          "X-Requested-With": "XMLHttpRequest",
                          "User-Agent": "Mozilla/5.0 (Linux; Android 10; V1914A Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.101 Mobile Safari/537.36",
                          "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryqzAkRL7L3HlcKLf7",
                          "Origin": "http://www.jxusptpay.com",
                          "Referer": "http://www.jxusptpay.com/StudentApp/SignIn/StudentSignin",
                          "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
                          "Connection": "close"
    GetStuSign_data = "------WebKitFormBoundaryqzAkRL7L3HlcKLf7--\\r\\n"
    step1_resp = session.post(url=GetStuSign_url, headers=GetStuSign_headers, data=GetStuSign_data)
    # print(step1_resp.text)
    resp_json = json.loads(step1_resp.text)
    GetStuSign_msg = resp_json['msg']
    try:
        SiginId = resp_json['data']['id']
    except:
        pass
    return GetStuSign_msg, SiginId, step1_resp

def GpsSignIn(SiginId):
    GpsSignIn_url = "http://www.jxusptpay.com:80/StudentApp/SignIn/StudentSignin/GpsSignIn"
    GpsSignIn_headers = "Accept": "application/json, text/javascript, */*; q=0.01",
                        "X-Requested-With": "XMLHttpRequest",
                        "User-Agent": "Mozilla/5.0 (Linux; Android 10; V1914A Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.101 Mobile Safari/537.36",
                        "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundarypKKcS4ZECP9zCIJt",
                        "Origin": "http://www.jxusptpay.com",
                        "Referer": "http://www.jxusptpay.com/StudentApp/SignIn/StudentSignin",
                        "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
                        "Connection": "close"
    GpsSignIn_data = "------WebKitFormBoundarypKKcS4ZECP9zCIJt\\r\\n" \\
                    "Content-Disposition: form-data; name=\\"signinId\\"\\r\\n" \\
                    "\\r\\n\\r\\n" \\
                    "------WebKitFormBoundarypKKcS4ZECP9zCIJt\\r\\n" \\
                    "Content-Disposition: form-data; name=\\"itemId\\"\\r\\n" \\
                    "\\r\\n1\\r\\n" \\
                    "------WebKitFormBoundarypKKcS4ZECP9zCIJt\\r\\n" \\
                    "Content-Disposition: form-data; name=\\"longitude\\"\\r\\n" \\
                    "\\r\\n115.82197462593913\\r\\n" \\
                    "------WebKitFormBoundarypKKcS4ZECP9zCIJt\\r\\n" \\
                    "Content-Disposition: form-data; name=\\"latitude\\"\\r\\n" \\
                    "\\r\\n28.90447703508046\\r\\n" \\
                    "------WebKitFormBoundarypKKcS4ZECP9zCIJt--\\r\\n".format(SiginId)
    step2_resp = session.post(url=GpsSignIn_url, headers=GpsSignIn_headers, data=GpsSignIn_data)
    print(step2_resp.text)

def FinalProcess(StuId, StuPassword):
    login_msg, resp = StudentLogin(StuId, StuPassword)
    if login_msg == "登入成功":
        GetStuSign_msg, SiginId, step1_resp = GetStuSign()
        if GetStuSign_msg == "操作成功":
            # 签到
            GpsSignIn(SiginId)
        else:
            print(step1_resp.text)
    elif login_msg == "登入服务器用户名或密码错误":
        print(login_msg)
    else:
        print(resp.text)


if __name__ == "__main__":
    start_time = datetime.datetime.now()
    print('\\n[+] 脚本启动时间:'.format(start_time.strftime('%Y-%m-%d %H:%M:%S')))
    session = requests.session()
    for info in StudentAccount:
        name, username, password = info[0], info[1], info[2]
        print(name)
        FinalProcess(username, password)
        # time.sleep(60) # 五分钟内登录服务器次数不得超过5次
    end_time = datetime.datetime.now()
    print('[+] 脚本运行时间: 秒\\n'.format((end_time-start_time).total_seconds()))

Dormitory Signin Automatic

需要校园通账号密码

# Python3
# Author: mochu7
import requests
import json
import datetime
import time

StudentAccount = [['张三', '账号', '密码'], ['李四', '账号', '密码'], ['王五', '账号', '密码']] # 校园通账号密码

def StudentLogin(StuId, StuPassword):
    login_url = "http://jxusptpay.com:80/StudentApp/Login/Login/StudentLogin"
    login_headers = "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:97.0) Gecko/20100101 Firefox/97.0",
               "Accept": "application/json, text/javascript, */*; q=0.01",
               "Accept-Language": "zh-CN,zh;q=0.8,zh-TW;q=0.7,zh-HK;q=0.5,en-US;q=0.3,en;q=0.2",
               "Accept-Encoding": "gzip, deflate", "X-Requested-With": "XMLHttpRequest",
               "Content-Type": "multipart/form-data; boundary=---------------------------42502287411117441599485456745"
    login_data = "-----------------------------42502287411117441599485456745\\r\\n" \\
                 "Content-Disposition: form-data; name=\\"student\\"" \\
                 "\\r\\n\\r\\n\\r\\n" \\
                 "-----------------------------42502287411117441599485456745\\r\\n" \\
                 "Content-Disposition: form-data; name=\\"password\\"" \\
                 "\\r\\n\\r\\n\\r\\n" \\
                 "-----------------------------42502287411117441599485456745\\r\\n" \\
                 "Content-Disposition: form-data; name=\\"platform\\"" \\
                 "\\r\\n\\r\\n1\\r\\n" \\
                 "-----------------------------42502287411117441599485456745--\\r\\n".format(StuId, StuPassword)
    resp = session.post(url=login_url, data=login_data, headers=login_headers)
    resp_json = json.loads(resp.text)
    login_msg = resp_json['msg']
    print(resp.text)
    # print(resp.cookies)
    return login_msg, resp

def GetDorMac():
    GetDorMac_msg = None
    DoorMac = None
    StuIsLogin_url = "https://www.jxusptpay.com/StudentApp/doorLock/openDoor/StudentIsSign"
    step1_resp = session.post(url=StuIsLogin_url)
    resp_json = json.loads(step1_resp.text)
    GetDorMac_msg = resp_json['msg']
    try:
        DoorMac = resp_json['data']['door']['doorBluetoothMac']
    except:
        pass
    return GetDorMac_msg, DoorMac, step1_resp

def GetToken():
    GetToken_msg = None
    ProveToken = None
    RelPerPro_url = "https://www.jxusptpay.com/StudentApp/doorLock/openDoor/RealPersonProving"
    step2_resp = session.post(url=RelPerPro_url)
    resp_json = json.loads(step2_resp.text)
    ProveToken = resp_json['data']['token']
    GetToken_msg = resp_json['msg']
    # ProveToken存在时效,时间较短,大概30秒左右
    return GetToken_msg, ProveToken, step2_resp

def Biopsy(ProveToken):
    Biopsy_msg = None
    RealId = None
    file_perfix = datetime.datetime.now().strftime("%Y-%m-%d-%H-%M-%S")
    Biopsy_url = "http://121.36.226.29:80/FaceRecognition/FaceRecognition/FaceRecognition/BiopsyToFile"
    Biopsy_headers = "Accept": "application/json, text/javascript, */*; q=0.01",
                     "User-Agent": "Mozilla/5.0 (Linux; Android 10; V1914A Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.101 Mobile Safari/537.36",
                     "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundaryyG2D8PGa3bWIwLdg",
                     "Origin": "http://www.jxusptpay.com", "X-Requested-With": "com.aheadedu.stuteams.stumanagement",
                     "Referer": "http://www.jxusptpay.com/StudentApp/doorLock/openDoor/dormitorySign",
                     "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
                     "Connection": "close"
    Biopsy_data = "------WebKitFormBoundaryyG2D8PGa3bWIwLdg\\r\\n" \\
                  "Content-Disposition: form-data; name=\\"multipartFile\\"; filename=\\".mp4\\"\\r\\n" \\
                  "Content-Type: video/mp4\\r\\n\\r\\n" \\
                  "ftypmp42isimmp42...\\x00\\r\\n" \\
                  "------WebKitFormBoundaryyG2D8PGa3bWIwLdg\\r\\n" \\
                  "Content-Disposition: form-data; name=\\"token\\"\\r\\n\\r\\n" \\
                  "\\r\\n" \\
                  "------WebKitFormBoundaryyG2D8PGa3bWIwLdg--\\r\\n".format(file_perfix, ProveToken)
    step3_resp = session.post(url=Biopsy_url, headers=Biopsy_headers, data=Biopsy_data, timeout=6)
    resp_json = json.loads(step3_resp.text)
    RealId = resp_json['data']['id']
    Biopsy_msg = resp_json['msg']
    return Biopsy_msg, RealId, step3_resp

def DorStuSign(DoorMac, RealId):
    StuSignin_url = "http://www.jxusptpay.com:80/StudentApp/doorLock/openDoor/StudentSign"
    StuSign_headers = "Accept": "application/json, text/javascript, */*; q=0.01", "X-Requested-With": "XMLHttpRequest",
                     "User-Agent": "Mozilla/5.0 (Linux; Android 10; V1914A Build/QP1A.190711.020; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/85.0.4183.101 Mobile Safari/537.36",
                     "Content-Type": "multipart/form-data; boundary=----WebKitFormBoundary9ENXVdDjergUgb4W",
                     "Origin": "http://www.jxusptpay.com",
                     "Referer": "http://www.jxusptpay.com/StudentApp/doorLock/openDoor/dormitorySign",
                     "Accept-Encoding": "gzip, deflate", "Accept-Language": "zh-CN,zh;q=0.9,en-US;q=0.8,en;q=0.7",
                     "Connection": "close"
    StuSign_data = "------WebKitFormBoundary9ENXVdDjergUgb4W\\r\\n" \\
                   "Content-Disposition: form-data; name=\\"signId\\"\\r\\n" \\
                   "\\r\\n1\\r\\n" \\
                   "------WebKitFormBoundary9ENXVdDjergUgb4W\\r\\n" \\
                   "Content-Disposition: form-data; name=\\"realId\\"\\r\\n" \\
                   "\\r\\n\\r\\n" \\
                   "------WebKitFormBoundary9ENXVdDjergUgb4W\\r\\n" \\
                   "Content-Disposition: form-data; name=\\"mac\\"\\r\\n" \\
                   "\\r\\n\\r\\n" \\
                   "------WebKitFormBoundary9ENXVdDjergUgb4W--\\r\\n".format(RealId, DoorMac)
    resp4 = session.post(url=StuSignin_url, headers=StuSign_headers, data=StuSign_data)
    print(resp4.text)

def FinalProcess(StuId, StuPassword):
    login_msg, resp = StudentLogin(StuId, StuPassword)
    if login_msg == "登入成功":
        # 获取门锁MAc地址
        GetDorMac_msg, DoorMac, step1_resp = GetDorMac()
        if GetDorMac_msg == "当前无需签到":
            print(GetDorMac_msg)
        elif GetDorMac_msg == "当前时间段已签到":
            print(GetDorMac_msg)
        elif GetDorMac_msg == "操作成功":
            # 获取Token
            GetToken_msg, ProveToken, step2_resp = GetToken()
            if GetToken_msg == "操作成功":
                # 活体验证
                Biopsy_msg, RealId, step3_resp = Biopsy(ProveToken)
                if Biopsy_msg == "操作成功":
                    # 签到
                    DorStuSign(DoorMac, RealId)
                else:
                    # 活检错误处理,重复GetToken以及Biopsy步骤,直至操作成功
                    while True:
                        ProveToken = GetToken()[1]
                        Biopsy_msg, RealId, step3_resp = Biopsy(ProveToken)
                        if Biopsy_msg == "操作成功":
                            # 签到
                            DorStuSign(DoorMac, RealId)
                            break
            else:
                print(step2_resp.text)
        else:
            print(step1_resp.text)
    elif login_msg == "登入服务器用户名或密码错误":
        print(login_msg)
    else:
        print(resp.text)


if __name__ == "__main__":
    start_time = datetime.datetime.now()
    print('\\n[+] 脚本启动时间:'.format(start_time.strftime('%Y-%m-%d %H:%M:%S')))
    session = requests.session()
    for info in StudentAccount:
        name, username, password = info[0], info[1], info[2]
        print(name)
        FinalProcess(username, password)
       # time.sleep(60) # 五分钟内登录服务器次数不得超过5次
    end_time = datetime.datetime.now()
    print('[+] 脚本运行时间: 秒\\n'.format((end_time-start_time).total_seconds()))

Health Report Automatic

需要校园通账号密码

# Python3
# Author: mochu7
import requests
import random
import datetime
import json
import time

xxx_StudentAccount = [['xxx班-张三', '账号', '密码'], ['xxx班-李四', '账号', '密码'], ['xxx班-王五', '账号', '密码']] # 校园通账号密码
yyy_StudentAccount = [['yyy班-张三', '账号', '密码'], ['yyy班-李四', '账号', '密码'], ['yyy班-王五', '账号', '密码']]
Stu_dict = "xxx":xxx_StudentAccount, "yyy":yyy_StudentAccount
class_list = ["xxx", "yyy"]
# xxx yyy 为班号
#Temperature Range:36.2℃~37.2℃
Temperature_list = ['36.2', '36.3', '36.4',以上是关于关于校园通使用过程中的相关脚本的主要内容,如果未能解决你的问题,请参考以下文章

关于校园论坛帖子的相关脚本

关于校园论坛帖子的相关脚本

关于校园论坛帖子的相关脚本

如何通过活体检测

鸿蒙《校园通》--游玩南昌模块

鸿蒙《校园通》--校园生活模块