This repository was archived by the owner on Oct 27, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-score.py
More file actions
145 lines (99 loc) · 3.51 KB
/
get-score.py
File metadata and controls
145 lines (99 loc) · 3.51 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import time
import codecs
import os
from splinter import Browser
def output_class_exam(Score):
file_object = open('G:/The-Rating-of-Examination/exam/'+exam, 'a', encoding = 'utf-8') # 使用时需修改路径
file_object.write(Score[0]+' ')
file_object.write(Score[1]+' ')
for j in range(2,10):
file_object.write(str(Score[j])+' ')
file_object.write(str(Score[10])+'\n')
file_object.close()
def get_score_from_html(num, str):
st = str.index('姓名')+24
ed = st+str[st::].find(' </span>')
Name = str[st:ed:]
# Chinese = 0
# ChineseRating = 0
# if str.find('语文') != -1:
# st = str.index('语文')+58
# ed = st+str[st::].find('</div></td>')
# Chinese = float(str[st:ed:])
# st = ed+56
# ed = st+str[st::].find('</div></td>')
# ChineseRating = float(str[st:ed:])
Chinese = 0
if str.find('语文') != -1:
st = str.index('语文')+58
ed = st+str[st::].find('</div></td>')
Chinese = float(str[st:ed:]) if st < ed else 0
Math = 0
if str.find('数学') != -1:
st = str.index('数学')+58
ed = st+str[st::].find('</div></td>')
Math = float(str[st:ed:]) if st < ed else 0
English = 0
if str.find('英语') != -1:
st = str.index('英语')+58
ed = st+str[st::].find('</div></td>')
English = float(str[st:ed:]) if st < ed else 0
Physical = 0
if str.find('物理') != -1:
st = str.index('物理')+58
ed = st+str[st::].find('</div></td>')
Physical = float(str[st:ed:]) if st < ed else 0
Chemistry = 0
if str.find('化学') != -1:
st = str.index('化学')+58
ed = st+str[st::].find('</div></td>')
Chemistry = float(str[st:ed:]) if st < ed else 0
Biology = 0
if str.find('生物') != -1:
st = str.index('生物')+58
ed = st+str[st::].find('</div></td>')
Biology = float(str[st:ed:]) if st < ed else 0
Three = 0
ThreeRating = 0
if min(Chinese, Math, English):
Three = Chinese + Math + English
SD = 0
if min(Physical, Chemistry, Biology):
SD = Physical + Chemistry + Biology
All = 0
if min(Three, SD):
All = Three + SD
Score = [num, Name, Chinese, Math, English, Physical, Chemistry, Biology, Three, SD, All]
print (num, Name, Chinese, Math, English, Physical, Chemistry, Biology, Three, SD, All)
output_class_exam(Score)
def catch(num):
print ('Exam: '+exam+' Num: '+num+' '+time.strftime('%Y-%m-%d %H:%M:%S',time.localtime(time.time())))
browser.find_by_id('xuehao').fill(num+'\'or\'')
browser.select('kaoshi', exam)
time.sleep(0.5)
browser.find_by_name('Submit').click()
# file_object = open(exam+'-'+num, 'w', encoding = 'utf-8')
# file_object.write(browser.html[2986:9006:])
# file_object.close()
if len(browser.html) > 2000:
get_score_from_html(num, browser.html[2986:20000:])
# else:
# NoScore.append(num)
browser.back()
def get_exam_score():
print ('Start to Copy The Exam '+exam)
for num in range(stars_num,32299):
if num%100==99:
browser.reload()
if num%100>=1 and num%100<=70 and (num//100%100)>=4 and (num//100%100)!=21:
catch(str(num))
if __name__ == '__main__':
exam = input()
stars_num = int(input())
browser = Browser('chrome')
browser.visit('http://jszx.stedu.net/jszxcj/search.htm')
# List = ['10', '11', '120', '12', '13', '14', '15', '20', '21', '220', '22', '23', '24', '25', '30', '31', '32', '322', '330', '331', '33', '34', '35', '352', '36', '37']
get_exam_score()
browser.quit()