Skip to content

Commit

Permalink
将之前的进度写成的一个User类,测试还未写。
Browse files Browse the repository at this point in the history
  • Loading branch information
longsihua2003 committed Apr 10, 2024
1 parent 1369763 commit b5c35cc
Show file tree
Hide file tree
Showing 8 changed files with 1,541 additions and 1,886 deletions.
1,253 changes: 0 additions & 1,253 deletions docs/grade.html

This file was deleted.

66 changes: 42 additions & 24 deletions docs/jwxt_get.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
{
"cell_type": "code",
"execution_count": 10,
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -30,7 +30,7 @@
},
{
"cell_type": "code",
"execution_count": 4,
"execution_count": 3,
"metadata": {},
"outputs": [
{
Expand All @@ -45,7 +45,6 @@
"def get_enc_password(origin_pwd: str) -> str:\n",
" ENC_URL = 'http://cas.ecjtu.edu.cn/cas/loginPasswdEnc'\n",
" enc_response = requests.post(ENC_URL, data={'pwd': origin_pwd})\n",
"\n",
" _ = enc_response.content.decode('utf8').replace(\"'\", '\"')\n",
" return json.loads(_)['passwordEnc']\n",
"\n",
Expand All @@ -62,7 +61,7 @@
},
{
"cell_type": "code",
"execution_count": 5,
"execution_count": 4,
"metadata": {},
"outputs": [],
"source": [
Expand All @@ -82,34 +81,47 @@
},
{
"cell_type": "code",
"execution_count": 6,
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"登录成功\n",
"classString 1-2\n",
"{\"date\":\"2024-04-10\",\"dsWeek\":1,\"userflag\":0,\"week\":7,\"weekcalendarpojoList\":[{\"classString\":\"3-4\",\"courseRequire\":\"必修课\",\"teacherName\":\"程俊峰\",\"weekDay\":3,\"classRoom\":\"31-504\",\"classSpan\":\"3,4\",\"course\":\"材料力学(B)\",\"className\":\"材料力学(B)(20232-1)\",\"weekSpan\":\"1-15\",\"pkType\":\"上课\"},{\"classString\":\"5-6\",\"courseRequire\":\"限选课\",\"teacherName\":\"邓志刚\",\"weekDay\":3,\"classRoom\":\"31-503\",\"classSpan\":\"5,6\",\"course\":\"计算方法(B)\",\"className\":\"计算方法(B)(20232-2)\",\"weekSpan\":\"1-16\",\"pkType\":\"上课\"},{\"classString\":\"7-8\",\"courseRequire\":\"必修课\",\"teacherName\":\"周丽英\",\"weekDay\":3,\"classRoom\":\"北区田径场11\",\"classSpan\":\"7,8\",\"course\":\"体育IⅤ\",\"className\":\"羽毛球Ⅳ(20232-12)\",\"weekSpan\":\"1-16\",\"pkType\":\"上课\"}],\"weekDay\":\"3\"}\n",
"classString 3-4\n",
"courseRequire 必修课\n",
"teacherName 吕敬钦\n",
"weekDay 5\n",
"classRoom 31-627\n",
"classSpan 1,2\n",
"course 软件测试技术\n",
"className 软件测试技术(20232-2)\n",
"teacherName 程俊峰\n",
"weekDay 3\n",
"classRoom 31-504\n",
"classSpan 3,4\n",
"course 材料力学(B)\n",
"className 材料力学(B)(20232-1)\n",
"weekSpan 1-15\n",
"pkType 上课\n",
"\n",
"\n",
"classString 5-6\n",
"courseRequire 限选课\n",
"teacherName 邓志刚\n",
"weekDay 3\n",
"classRoom 31-503\n",
"classSpan 5,6\n",
"course 计算方法(B)\n",
"className 计算方法(B)(20232-2)\n",
"weekSpan 1-16\n",
"pkType 上课\n",
"\n",
"\n",
"classString 3-4\n",
"classString 7-8\n",
"courseRequire 必修课\n",
"teacherName 叶云青\n",
"weekDay 5\n",
"classRoom 31-625\n",
"classSpan 3,4\n",
"course 计算机网络\n",
"className 计算机网络(20232-4)\n",
"teacherName 周丽英\n",
"weekDay 3\n",
"classRoom 北区田径场11\n",
"classSpan 7,8\n",
"course 体育IⅤ\n",
"className 羽毛球Ⅳ(20232-12)\n",
"weekSpan 1-16\n",
"pkType 上课\n",
"\n",
Expand Down Expand Up @@ -163,10 +175,16 @@
" return session\n",
"\n",
"session = requests.Session()\n",
"login(\"2022211003000111\",\"mzdwzyddn0\",session)\n",
"classes = session.post(get_classes,data={\"date\":\"2024-04-05\"})\n",
"login(\"2022211003000202\",\"Cgz040918\",session)\n",
"from datetime import datetime,timedelta\n",
"date = (datetime.now()+timedelta(days=1)).strftime(\"%Y-%m-%d\")\n",
"classes = session.post(get_classes,data={\"date\":date})\n",
"# print(classes.text)\n",
"for k,v in classes.json().items():\n",
" if k == \"weekcalendarpojoList\":\n",
" if len(v) == 0:\n",
" print(\"今天没课哦\")\n",
" # exit(0)\n",
" for item in v:\n",
" for i,j in item.items():\n",
" print(i,\" \",j)\n",
Expand All @@ -182,7 +200,7 @@
},
{
"cell_type": "code",
"execution_count": 7,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1463,7 +1481,7 @@
},
{
"cell_type": "code",
"execution_count": 8,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down Expand Up @@ -1497,7 +1515,7 @@
},
{
"cell_type": "code",
"execution_count": 11,
"execution_count": null,
"metadata": {},
"outputs": [
{
Expand Down
4 changes: 3 additions & 1 deletion docs/jwxt_get.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ def login(username:str,password:str,session:requests.Session) -> requests.Sessio


def get_grade_count(grade_html:requests.Response) -> dict:
"""获取成绩统计信息,学分情况"""
soup = BeautifulSoup(grade_html.text, 'html.parser')
data_row = soup.find_all("tr")[3]
data = [td.text for td in data_row.find_all("td")]
Expand All @@ -79,10 +80,11 @@ def get_grade_count(grade_html:requests.Response) -> dict:


def get_grade_from_semester(semester:str,grade_html:requests.Response) -> list:
"""获取某学期的课程成绩信息"""
tsemester = semester.replace(".","_")
grade_from_semester_list = []
soup = BeautifulSoup(grade_html.text, 'html.parser')

pattern = re.compile(r'\b{}\b'.format(tsemester))
ul_tags = soup.find_all("ul",class_=pattern)
for ul_tag in ul_tags:
Expand Down
Loading

0 comments on commit b5c35cc

Please sign in to comment.