现提供可直接运行的 Windows 版本,界面粗糙了些,只是在虚拟机下的 Windows10 系统上测试没有问题。但有个问题是在 Windows 环境下,数据库保存不了用户名和密码,目前每次打开软件之后都需要重新输入(Mac 下不好调试,我再研究下,实在不行改为存文件吧)。
[color=]https://www.123684.com/s/EgIvTd-GGgk3?提取码:52pj
[Python] 纯文本查看 复制代码
'''
--- 本程序仅查看《好·分·数》的总成绩、各科目分数
--- 因学校使用了好·分·数平台查分等其他功能,这本该学校义务提供的事项现在只能花钱才能获取,(有点想 TM M人 -_-#)
--- 参考本站作者 @nuz 的成品 好分数.exe,可惜接口有问题,一直提示"无效的用户密码或无互联网链接"。拉取代码调试一下吧
--- 结果 qfluentwidgets 这个库一直安装不成功,无奈...
--- 移动端的可降级 app,我看的 V3.10.0 的版本,可直接显示分数
--- 先暂且提供源码吧,后续增加 UI(看看大家的意见) 和其他功能(可行的话),另外后续还会再提供 iOS 版本的快捷指令
--- 本代码仅供学习与参考,不做其他非法用途
--- ⚠️ 温馨提示:需要修改以下 'userName' 和 'password' 字段的内容
'''
import requests
from base64 import b64encode
class Hfx(object):
def __init__(self):
# TODO: 修改登录好分数平台的用户名、密码
self.user = {
# 手机号 or 邮箱 (邮箱账号未验证)
'userName': '',
'password': ''
}
self.userInfo = {}
self.cookies = {
'hfs-session-id': ''
}
self.headers = {
'Accept': 'application/json, text/plain, */*',
'Content-Type': 'application/json;charset=UTF-8',
'Origin': 'https://www.haofenshu.com',
'Referer': 'https://www.haofenshu.com/',
'Sec-Fetch-Dest': 'empty',
'Sec-Fetch-Mode': 'cors',
'Sec-Fetch-Site': 'cross-site',
'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36',
'deviceType': '3',
'sec-ch-ua': '"Chromium";v="130", "Google Chrome";v="130", "Not?A_Brand";v="99"',
'sec-ch-ua-mobile': '?0',
'sec-ch-ua-platform': '"macOS"',
}
self.base_url = 'https://hfs-be.yunxiao.com'
def login(self):
json_data = {
'loginName': self.user['userName'],
'password': b64encode(hfx.user['password'].encode('utf-8')).decode('utf-8'),
'roleType': 2,
'loginType': 1,
'rememberMe': 2,
}
response = requests.post(f'{self.base_url}/v2/users/sessions', cookies=self.cookies, headers=self.headers,
json=json_data).json()
if response['code'] == 0:
self.userInfo = response['data']
token = self.userInfo['token']
self.cookies['hfs-session-id'] = token
self.headers['Hfs-Token'] = token
self.getUserSnapshot()
else:
print(response['msg'])
def getUserSnapshot(self):
response = requests.get(f'{self.base_url}/v2/user-center/user-snapshot', cookies=self.cookies,
headers=self.headers).json()
if response['code'] == 0:
linkedStudent = response['data']['linkedStudent']
keys = list(linkedStudent.keys())
for key in keys:
self.userInfo[key] = linkedStudent[key]
print(f'{self.userInfo["studentName"]} --- {self.userInfo["schoolName"]}·{self.userInfo["sgrade"]}'
f'{self.userInfo["className"]}班')
self.getExamList()
else:
print(response['msg'])
def getExamList(self):
params = {
'start': '-1'
}
response = requests.get(f'{self.base_url}/v3/exam/list', params=params, headers=self.headers).json()
if response['code'] == 0:
data = response['data']
list = data['list']
print(f'\n{data["limitTip"]}\n')
for paper in list:
self.getOverviewExam(paper['examId'])
else:
print(response['msg'])
def getOverviewExam(self, examId): # 2299726
response = requests.get(f'{self.base_url}/v3/exam/{examId}/overview', cookies=self.cookies,
headers=self.headers).json()
if response['code'] == 0:
data = response['data']
papers = data['papers']
print(f'● 年级总人数:{data["gradeStuNum"]}人 \t 班级总人数:{data["classStuNum"]}人')
print('-----------------------------------')
print(f'● {data["name"]}\n')
# print(f'\t得分:{data["score"]}分/{data["manfen"]}分,得分评级:{data["scoreS"]},'
# f'班级排名:{data["classRank"]}(仅作参考,不准),班级评级:{data["classRankS"]}')
print(f'\t得分:{data["score"]}分/{data["manfen"]}分,得分评级:{data["scoreS"]},班级评级:{data["classRankS"]}')
for paper in papers:
print(f'\t{paper["name"]}\t\t{paper["score"]}分/{paper["manfen"]}分,得分评级:{paper["scoreS"]}')
print('\n\n')
else:
print(response['msg'])
if __name__ == '__main__':
hfx = Hfx()
hfx.login()