feat: 新增獎懲紀錄查詢

This commit is contained in:
Ting-Jun Wang 2021-07-02 02:29:08 +08:00
parent ce2f90fb80
commit 5dc8bd559a
Signed by: snsd0805
GPG Key ID: 8DB0D22BC1217D33
2 changed files with 26 additions and 3 deletions

View File

@ -74,12 +74,20 @@ if ncnu.status:
space()
# ===== Test 取得所有缺曠課記錄 =====
absenceLogs = ncnu.getAbsenceLog()
absenceLogs = ncnu.getAbsenceLogs()
if absenceLogs:
for log in absenceLogs:
print(log)
else:
print("沒有任何缺曠課記錄")
space()
# ===== Test 獎懲紀錄 =====
awardLogs = ncnu.getAwardLogs()
if awardLogs:
for log in awardLogs:
print(log)
else:
print("沒有任何獎懲紀錄")
else:
print("NCNU 教務系統登入失敗")

View File

@ -123,7 +123,7 @@ class NCNU():
else:
return None
def getAbsenceLog(self):
def getAbsenceLogs(self):
response = self.session.get("https://ccweb.ncnu.edu.tw/student/absencelist.php")
table = find(response, 'tbody')
@ -137,4 +137,19 @@ class NCNU():
'time': data[4].text.replace('\n', '')
} for data in (log.findAll('td') for log in logs)]
else:
return None
return None
def getAwardLogs(self):
response = self.session.get('https://ccweb.ncnu.edu.tw/student/aspmaker_student_merit_viewlist.php?export=csv')
datas = response.text.split('\r\n')[1:-1]
if len(datas) == 2:
return None
else:
return [{
'id': data[0],
'semester': data[1],
'award': data[2],
'count': data[3],
'content': data[4],
} for data in (data.replace('"', '').split(',') for data in datas)]