forked from dongchao-1/XDU.grQueryScore
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.py
More file actions
executable file
·35 lines (29 loc) · 914 Bytes
/
query.py
File metadata and controls
executable file
·35 lines (29 loc) · 914 Bytes
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
#!/usr/bin/env python
# coding:utf-8
import requests
import re
from setting import url,stu,courses
# http://210.27.12.1:90/queryDegreeScoreAction.do?studentid=xdleess20120514sn1585°reecourseno=0821005
def getScore(url,stu,course):
payload = {'studentid' : stu, 'degreecourseno' : course}
r = requests.get(url, params = payload)
start = r.text.find('<tbody>')
end = r.text.find('</tbody>')
tbody = r.text[start:end]
val = []
while '</td>' in tbody:
end = tbody.find('</td>')
start = tbody.rfind('>',0,end)
val.append(tbody[start+1:end].strip())
tbody = tbody[end+len('</td>'):]
return val
def getAllScore(url,stu,courses):
scores = []
for course in courses:
scores.append(getScore(url,stu,course))
return scores
if __name__ == '__main__':
scores = getAllScore(url,stu,courses)
print u'课程名称,学分,成绩'
for each in scores:
print "%s,%s,%s" % (each[1], each[2], each[4])