Skip to content

Commit

Permalink
Fix student id bug
Browse files Browse the repository at this point in the history
  • Loading branch information
AkiChase committed May 22, 2022
1 parent 348ab11 commit da270e4
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions server/course_helper/routers/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,12 +213,20 @@ async def login_by_ids(session: requests.Session, account: str, pw: str, login_u


def get_user_info(s: Session) -> dict:
res = s.get('https://course2.xmu.edu.cn/meol/popups/viewstudent_info.jsp?SID=224501&from=welcomepage')
res = s.get('https://course2.xmu.edu.cn/meol/welcomepage/student/index.jsp')
sid = re.search(r'viewstudent_info.jsp\?SID=(\d.*?)&', res.text).group(1)

res = s.get(f'https://course2.xmu.edu.cn/meol/popups/viewstudent_info.jsp?SID={sid}&from=welcomepage')
html = etree.HTML(res.text)
table = html.xpath("//table[@class='infotable']")[0]
result = [x.text.strip() for x in table.xpath("//td")]
return {
result = [x.text.strip() for x in table.xpath(".//td")]

out = {
'id': result[1],
'name': result[2],
'college': result[3]
}

logger.debug('用户信息', out)

return out

0 comments on commit da270e4

Please sign in to comment.