Add exception handling, fix URL splicing problem
This commit is contained in:
+10
-2
@@ -2,6 +2,7 @@ from get_grade import get_grade
|
|||||||
|
|
||||||
|
|
||||||
def get_selected_courses(student_client):
|
def get_selected_courses(student_client):
|
||||||
|
try:
|
||||||
# 获取成绩信息
|
# 获取成绩信息
|
||||||
grade = get_grade(student_client, output_type="grade")
|
grade = get_grade(student_client, output_type="grade")
|
||||||
|
|
||||||
@@ -34,14 +35,18 @@ def get_selected_courses(student_client):
|
|||||||
# 判断课程是否未公布成绩或为异常课程
|
# 判断课程是否未公布成绩或为异常课程
|
||||||
if course["class_id"] not in grade_class_ids:
|
if course["class_id"] not in grade_class_ids:
|
||||||
# 未公布成绩
|
# 未公布成绩
|
||||||
ungraded_courses_by_semester.setdefault(yearsemester_name, []).append(
|
ungraded_courses_by_semester.setdefault(
|
||||||
|
yearsemester_name, []
|
||||||
|
).append(
|
||||||
f"{course['title'].replace('(', '(').replace(')', ')')} - {course['teacher']}"
|
f"{course['title'].replace('(', '(').replace(')', ')')} - {course['teacher']}"
|
||||||
)
|
)
|
||||||
elif course["class_id"] not in {
|
elif course["class_id"] not in {
|
||||||
course["class_id"] for course in selected_courses
|
course["class_id"] for course in selected_courses
|
||||||
}:
|
}:
|
||||||
# 异常课程
|
# 异常课程
|
||||||
abnormal_courses_by_semester.setdefault(yearsemester_name, []).append(
|
abnormal_courses_by_semester.setdefault(
|
||||||
|
yearsemester_name, []
|
||||||
|
).append(
|
||||||
f"{course['title'].replace('(', '(').replace(')', ')')} - {course['teacher']}"
|
f"{course['title'].replace('(', '(').replace(')', ')')} - {course['teacher']}"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -74,5 +79,8 @@ def get_selected_courses(student_client):
|
|||||||
selected_courses_filtering += f"\n{course}"
|
selected_courses_filtering += f"\n{course}"
|
||||||
else:
|
else:
|
||||||
selected_courses_filtering = "------\n已选课程信息为空"
|
selected_courses_filtering = "------\n已选课程信息为空"
|
||||||
|
except Exception as e:
|
||||||
|
print(e)
|
||||||
|
return "------\n无法获取未公布成绩的课程或异常的课程"
|
||||||
|
|
||||||
return selected_courses_filtering
|
return selected_courses_filtering
|
||||||
|
|||||||
+1
-1
@@ -927,7 +927,7 @@ class Client:
|
|||||||
try:
|
try:
|
||||||
url = urljoin(
|
url = urljoin(
|
||||||
self.base_url,
|
self.base_url,
|
||||||
"/xsxxxggl/xsxxwh_cxXsxkxx.html?gnmkdm=N100801",
|
"xsxxxggl/xsxxwh_cxXsxkxx.html?gnmkdm=N100801",
|
||||||
)
|
)
|
||||||
temp_term = term
|
temp_term = term
|
||||||
term = term**2 * 3
|
term = term**2 * 3
|
||||||
|
|||||||
Reference in New Issue
Block a user