Skip to content

Commit a3572ca

Browse files
committed
update v0.0.8
1 parent 721fd13 commit a3572ca

File tree

4 files changed

+31
-4
lines changed

4 files changed

+31
-4
lines changed

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
setuptools.setup(
77
name="ustcjwxt",
8-
version="v0.0.7",
8+
version="v0.0.8",
99
author="brealid",
1010
author_email="brealid@mail.ustc.edu.cn",
1111
description="ustc jwxt api, for study only",

ustcjwxt/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
version_info = (0, 0, '7')
1+
version_info = (0, 0, '8')
22

33
__version__ = ".".join([str(x) for x in version_info])

ustcjwxt/course_select.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,21 @@ def get(self, s: StudentSession) -> SingleCacheDataInfo:
3535
def _get_openTurns(s: StudentSession, force_retrieve: bool = False) -> list:
3636
if not force_retrieve and cacheData.get(s).openTurns is not None:
3737
return cacheData.get(s).openTurns
38-
url = 'https://jw.ustc.edu.cn/ws/for-std/course-select/open-turns'
39-
formData = { 'bizTypeId': 2, 'studentId': s.get_student_assocID() }
38+
39+
student_ID = s.get_student_ID()
40+
if student_ID.startswith('PB'):
41+
log.log_info('学生类型: 本科生 (bizTypeId: 2)')
42+
bizTypeId = 2
43+
elif student_ID.startswith('SA'):
44+
log.log_info('学生类型: 研究生 (bizTypeId: 3)')
45+
bizTypeId = 3
46+
else:
47+
log.log_info('学生类型: 未知 (bizTypeId: -1)')
48+
log.log_error('请联系开发者获取进一步信息')
49+
bizTypeId = 1
50+
51+
url = 'https://jw.ustc.edu.cn/ws/for-std/course-select/open-turns'
52+
formData = { 'bizTypeId': bizTypeId, 'studentId': s.get_student_assocID() }
4053
response = s.post(url, data=formData)
4154
cacheData.get(s).openTurns = response.json()
4255
return cacheData.get(s).openTurns

ustcjwxt/session.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ def clear_cache(self) -> None:
6666
self.cache = dict()
6767

6868
def login_with_password(self, username: str, password: str, smcode_hook=None) -> bool:
69+
log.log_error('当前使用账号密码登录的功能暂不可用! 请使用 login_with_session')
70+
return False
71+
6972
self.clear_cache()
7073
self.username = username
7174
self.password = password
@@ -203,6 +206,17 @@ def get_student_ID(self, force_retrieve = False) -> str:
203206
self.cache['student_ID'] = student_ID
204207
return student_ID
205208
log.log_warning('未能在 cookies 中找到学号')
209+
# 从选课界面中获得学号
210+
response = self.get('https://jw.ustc.edu.cn/for-std/course-select')
211+
if response.url.startswith('https://jw.ustc.edu.cn/for-std/course-select/turns/'):
212+
p = response.text.find('<span class="pull-left"><strong>学号</strong></span>')
213+
if p != -1:
214+
p = response.text.find('<span>', p + 50) + 6
215+
q = response.text.find('</span>', p)
216+
student_ID = response.text[p:q]
217+
self.cache['student_ID'] = student_ID
218+
return student_ID
219+
log.log_warning('未能在 cookies 中找到学号')
206220
# 均失败
207221
log.log_warning('未能获得学号')
208222
return ''

0 commit comments

Comments
 (0)