-
Notifications
You must be signed in to change notification settings - Fork 0
/
yichafen_main.py
48 lines (35 loc) · 1.35 KB
/
yichafen_main.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
41
42
43
44
45
46
47
48
from splinter.browser import Browser #need install splinter
import re
import xlrd
import time
shee=xlrd.open_workbook("D:\workdir\pybug\\test.xls")#the students' information table here
names={}
nums={}
cla={}
t=0
for i in range(0,22):
table=shee.sheets()[i]
nrows=table.nrows
for j in range(1,nrows):
names[t]=table.cell_value(j,3)
nums[t]=table.cell_value(j,1)
cla[t]=str(100+i+1)# class numbers
t=t+1
b= Browser('edge')#need edge browser and edge webdrivers
url=""#Your yichafen url here(the query page ,not the content page)
s=""
for i in range(0,t):
b.visit(url)
b.fill("s_shenfenzhenghao",nums[i])#maybe others,need to grab from the website
b.fill("s_xingming",names[i])# like the former comment
b.find_by_id("yiDunSubmitBtn").click()
if b.is_element_present_by_id("result_content"):
c=b.find_by_id("result_content")
ret=re.match ("(.*)[\n](.*)[\n](.*)",c.text) # the rules should match the query result,need to grab from the website
ret2=ret.group(3)
# print(ret2.split(' ')[1],' ',ret2.split(' ')[3])''
s=s+ret2.split(' ')[1]+' '+ret2.split(' ')[3]+' '+cla[i]
s=s+'\n'
time.sleep(0.1)
with open(".\\senior1.txt","w") as f:#the score details saved address,can be personalized
f.write(s)