11
11
12
12
13
13
def send_wechat (user_index , msg ):
14
+ """Send messeage to WeChat"""
14
15
wechat_url = 'http://wxpusher.zjiecode.com/api/send/message/'
15
16
wechat_url += '?appToken=' + config .app_token
16
17
wechat_url += '&content=' + msg
@@ -19,6 +20,7 @@ def send_wechat(user_index, msg):
19
20
20
21
21
22
def report (user_index ):
23
+ """Report for one user"""
22
24
print ('[Info] ' + 'Reporting for user ' + str (user_index + 1 ), end = ', ' )
23
25
print ('username: ' + config .users [user_index ]['username' ])
24
26
@@ -39,6 +41,7 @@ def report(user_index):
39
41
40
42
browser .set_window_size (480 , 720 )
41
43
44
+ # Login
42
45
print ('[Info] Logging in' )
43
46
browser .get ('https://id.sspu.edu.cn/cas/login' )
44
47
time .sleep (1 )
@@ -53,6 +56,7 @@ def report(user_index):
53
56
login_button .click ()
54
57
time .sleep (1 )
55
58
59
+ # Detect login status
56
60
try :
57
61
browser .find_element_by_class_name ('success' )
58
62
except exceptions .NoSuchElementException :
@@ -65,19 +69,23 @@ def report(user_index):
65
69
print ('[Info] Login success' )
66
70
time .sleep (0.5 )
67
71
72
+ # Jump to HSM page
68
73
print ('[Info] Jumping to HSM page' )
69
74
browser .get ('https://hsm.sspu.edu.cn/selfreport/Default.aspx' )
70
75
time .sleep (0.5 )
71
76
77
+ # Jump to Daily Report page
72
78
print ('[Info] Jumping to Daily Report page' )
73
79
browser .get ('https://hsm.sspu.edu.cn/selfreport/DayReport.aspx' )
74
80
time .sleep (1 )
75
81
82
+ # Start filling
76
83
print ('[Info] Starting auto fill' )
77
84
78
85
min_value = int (config .min_temperature * 10 )
79
86
max_value = int (config .max_temperature * 10 )
80
87
88
+ # Generate temperature using normal distribution
81
89
loc = int ((min_value + max_value ) / 2 )
82
90
scale = max_value - loc
83
91
temperature = int (normal (loc = loc , scale = scale )) / 10
@@ -86,25 +94,30 @@ def report(user_index):
86
94
87
95
print ('[Info] Auto generated temperature:' , temperature )
88
96
97
+ # Fill temperature
89
98
temperature_box = browser .find_element_by_id ('p1_TiWen-inputEl' )
90
99
temperature_box .clear ()
91
100
temperature_box .send_keys (str (temperature ))
92
101
time .sleep (0.5 )
93
102
103
+ # Check checkbox
94
104
agree_box = browser .find_element_by_id ('p1_ChengNuo-inputEl-icon' )
95
105
agree_box .click ()
96
106
time .sleep (0.5 )
97
107
108
+ # Check checkbox
98
109
condition_good = browser .find_element_by_id ('p1_DangQSTZK' ) \
99
110
.find_element_by_id ('fineui_2-inputEl-icon' )
100
111
condition_good .click ()
101
112
time .sleep (0.5 )
102
113
114
+ # Submit
103
115
submit_button = browser .find_element_by_id ('p1_ctl00' ) \
104
116
.find_element_by_id ('p1_ctl00_btnSubmit' )
105
117
submit_button .click ()
106
118
time .sleep (1 )
107
119
120
+ # Detect submit status
108
121
try :
109
122
browser .find_element_by_id ('fineui_27' )
110
123
except IndexError :
@@ -114,12 +127,14 @@ def report(user_index):
114
127
browser .quit ()
115
128
return 1
116
129
130
+ # Confirm submit
117
131
yes_button_1 = browser .find_element_by_id ('fineui_34' ) \
118
132
.find_element_by_id ('fineui_36' ) \
119
133
.find_element_by_id ('fineui_37' )
120
134
yes_button_1 .click ()
121
135
time .sleep (1 )
122
136
137
+ # Waiting for submit result
123
138
for i in range (int (config .timeout / 3 )):
124
139
time .sleep (3 )
125
140
try :
@@ -141,26 +156,31 @@ def report(user_index):
141
156
142
157
print ('[Info] Reported successfully' )
143
158
159
+ # Confirm the success message
144
160
yes_button_2 = browser .find_element_by_id ('fineui_39' ) \
145
161
.find_element_by_id ('fineui_41' ) \
146
162
.find_element_by_id ('fineui_42' )
147
163
yes_button_2 .click ()
148
164
time .sleep (1 )
149
165
166
+ # Check rank
150
167
browser .get ('https://hsm.sspu.edu.cn/selfreport/ReportHistory.aspx' )
151
168
time .sleep (1 )
152
169
170
+ # Get rank data text
153
171
txt = browser .find_element_by_id ('Panel1_DataList1' ) \
154
172
.find_element_by_class_name ('f-datalist-list' ) \
155
173
.find_elements_by_class_name ('f-datalist-item-inner' )[0 ].text
156
174
175
+ # Check whether report is successful
157
176
if txt .find (strings .msg ['success_msg' ]) == - 1 :
158
177
print ('[Error] Check failed' )
159
178
if config .users [user_index ]['use_wechat' ]:
160
179
send_wechat (user_index , strings .get_msg_failed (user_index ))
161
180
browser .quit ()
162
181
return 1
163
182
183
+ # Get rank data
164
184
if re .match (r'^(\d+)-(\d+)-(\d+)\(.*?(\d+).*?\)$' , txt ) != None :
165
185
datas = re .match (r'^(\d+)-(\d+)-(\d+)\(.*?(\d+).*?\)$' , txt )
166
186
rank = int (datas .group (4 ))
0 commit comments