-
Notifications
You must be signed in to change notification settings - Fork 0
/
grade.py
40 lines (38 loc) · 1.08 KB
/
grade.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#!/usr/bin/env python
#coding:utf-8
import requests
import os
import re
name = []
grade = []
if os.path.isfile('.gradeconfig'):
file = open('.gradeconfig', 'r')
some = file.read()
some = some.split(':')
xuehao = some[0]
passwd = some[1]
file.close()
else:
xuehao = input('输入你的学号:')
passwd = input('输入你的密码:')
file = open('.gradeconfig', 'w+')
file.write(xuehao + ':' + passwd)
file.close()
loginUrl = 'http://jwweb.yzu.edu.cn:7777/pls/wwwbks/bks_login2.login'
gradeUrl = 'http://jwweb.yzu.edu.cn:7777/pls/wwwbks/bkscjcx.curscopre'
postdate = {
'stuid':xuehao,
'pwd':passwd
}
session = requests.Session()
result = session.post(loginUrl, data=postdate)
result = session.get(gradeUrl)
result.encoding = 'gbk'
page = result.text
myItems = re.findall('<TR>.*?<p.*?<p.*?<p.*?>(.*?)</p>.*?<p.*?<p.*?<p.*?<p.*?<p.*?<p.*?<p.*?<p.*?>(.*?)</p>.*?<p.*?<p.*?<p.*?<p.*?</TR>', page, re.S)
for item in myItems:
name.append(item[0])
grade.append(item[1])
for i in range(len(name)):
print('%s : %s\n'%(name[i], grade[i]))
input()