Skip to content
This repository was archived by the owner on Jun 3, 2025. It is now read-only.

Commit a45fcbd

Browse files
committed
feat:新增获取个人信息✨
1 parent 5ef6979 commit a45fcbd

File tree

2 files changed

+20
-2
lines changed

2 files changed

+20
-2
lines changed

my_xxt/api.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
from my_xxt.answer_type import AnswerType
2020
from my_xxt.question_type import QuestionType
2121

22-
2322
# 加密密钥
2423
key = b"u2oh6Vu^HWe4_AES"
2524

@@ -38,6 +37,9 @@
3837
# 确认提交(get)
3938
IS_COMMIT = "https://mooc1.chaoxing.com/work/validate"
4039

40+
# 获取个人信息(get)
41+
SELF_INFO = "http://passport2.chaoxing.com/mooc/accountManage"
42+
4143
# 答案题目类型
4244
answer_type = [
4345
{"type": "单选题", "fun": "multipleChoice", "key": "0"},
@@ -144,6 +146,21 @@ def getCourse(self) -> list:
144146
i = i + 1
145147
return course_list
146148

149+
def getInfo(self) -> dict:
150+
info_html = self.sees.get(
151+
url=SELF_INFO,
152+
headers={
153+
"User-Agent": self.header,
154+
},
155+
)
156+
info_html_soup = BeautifulSoup(info_html.text, "lxml")
157+
info_html_soup = info_html_soup.find("div", attrs={"class": "infoDiv"})
158+
info = {
159+
"name": info_html_soup.find("span", attrs={"id": "messageName"})["value"],
160+
"student_number": info_html_soup.find("p", attrs={"class": "xuehao"}).text.replace("学号/工号:", "")
161+
}
162+
return info
163+
147164
def getWorks(self, course_url: str, course_name: str) -> list:
148165
"""
149166
获取一个课程的作业

my_xxt/login.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,5 +19,6 @@ def login(console: Console, xxt: XcxyXxt) -> None:
1919
if flag == 'q':
2020
exit()
2121
else:
22-
console.print("[green]登录成功")
22+
info = xxt.getInfo()
23+
console.print(f"[green]登录成功,{info['name']}")
2324
break

0 commit comments

Comments
 (0)