8
8
9
9
10
10
def request_schedule (
11
- school_id : str ,
12
- class_id = 0 ,
13
- professor = 0 ,
14
- classroom = 0 ,
15
- interest_activity = 0 ,
16
- school_week = 0 ,
17
- student_id = 0 ,
18
- soup = False ,
11
+ school_id : str ,
12
+ class_id = 0 ,
13
+ professor = 0 ,
14
+ classroom = 0 ,
15
+ interest_activity = 0 ,
16
+ school_week = 0 ,
17
+ student_id = 0 ,
18
+ soup = False ,
19
19
):
20
20
"""
21
21
It requests schedule from easistent.com and returns it as a response
@@ -49,13 +49,13 @@ def request_schedule(
49
49
50
50
51
51
def get_schedule_data (
52
- school_id : str ,
53
- class_id = 0 ,
54
- professor = 0 ,
55
- classroom = 0 ,
56
- interest_activity = 0 ,
57
- school_week = 0 ,
58
- student_id = 0 ,
52
+ school_id : str ,
53
+ class_id = 0 ,
54
+ professor = 0 ,
55
+ classroom = 0 ,
56
+ interest_activity = 0 ,
57
+ school_week = 0 ,
58
+ student_id = 0 ,
59
59
):
60
60
"""
61
61
Date format is: YYYY-MM-DD
@@ -101,7 +101,8 @@ def get_schedule_data(
101
101
"" .join (
102
102
re .findall (
103
103
"[0-9]" ,
104
- [item .text .split ("," )[0 ] for item in soup .select ("body > div > span" )][
104
+ [item .text .split ("," )[0 ] for item in
105
+ soup .select ("body > div > span" )][
105
106
0
106
107
],
107
108
)
@@ -123,10 +124,12 @@ def get_schedule_data(
123
124
month = int (temp_date [1 ]),
124
125
year = today .year ,
125
126
)
126
- dates_formatted .append (str (temp_datetime .strftime ("%Y-%m-%d" )))
127
+ dates_formatted .append (
128
+ str (temp_datetime .strftime ("%Y-%m-%d" )))
127
129
dates .append (temp_datetime )
128
130
if count >= 0 :
129
- row = table_row .find_all ("td" , class_ = "ednevnik-seznam_ur_teden-td" )
131
+ row = table_row .find_all ("td" ,
132
+ class_ = "ednevnik-seznam_ur_teden-td" )
130
133
hour_name = str (row [0 ].find (class_ = "text14" ).text )
131
134
hour_time = row [0 ].find (class_ = "text10" ).text .replace (" " , "" )
132
135
hour_times .append (hour_time )
@@ -187,18 +190,18 @@ def get_schedule_data(
187
190
try :
188
191
subject = (
189
192
section .find (class_ = "text14" )
190
- .text .replace ("\n " , "" )
191
- .replace ("\t " , "" )
193
+ .text .replace ("\n " , "" )
194
+ .replace ("\t " , "" )
192
195
)
193
196
group_raw = section .find_all (
194
197
class_ = "text11 gray bold"
195
198
)
196
199
teacher_classroom = (
197
200
section .find (class_ = "text11" )
198
- .text .replace ("\n " , "" )
199
- .replace ("\t " , "" )
200
- .replace ("\r " , "" )
201
- .split (", " )
201
+ .text .replace ("\n " , "" )
202
+ .replace ("\t " , "" )
203
+ .replace ("\r " , "" )
204
+ .split (", " )
202
205
)
203
206
teacher = teacher_classroom [0 ]
204
207
classroom = teacher_classroom [1 ]
@@ -212,11 +215,11 @@ def get_schedule_data(
212
215
for gr in group_raw :
213
216
group .append (gr .text )
214
217
if ("id" in section .attrs ) and bool (
215
- re .match (
216
- r"ednevnik-seznam_ur_teden-blok"
217
- r"-\d\d\d\d\d\d-\d\d\d\d-\d\d-\d\d" ,
218
- section .attrs ["id" ],
219
- )
218
+ re .match (
219
+ r"ednevnik-seznam_ur_teden-blok"
220
+ r"-\d\d\d\d\d\d-\d\d\d\d-\d\d-\d\d" ,
221
+ section .attrs ["id" ],
222
+ )
220
223
):
221
224
# Check for blocks
222
225
for block in section :
@@ -250,21 +253,22 @@ def get_schedule_data(
250
253
try :
251
254
subject = (
252
255
block .find (class_ = "text14" )
253
- .text .replace ("\n " , "" )
254
- .replace ("\t " , "" )
256
+ .text .replace ("\n " , "" )
257
+ .replace ("\t " , "" )
255
258
)
256
259
group_raw = block .find_all (
257
260
class_ = "text11 gray bold"
258
261
)
259
262
teacher_classroom = (
260
263
block .find (class_ = "text11" )
261
- .text .replace ("\n " , "" )
262
- .replace ("\t " , "" )
263
- .replace ("\r " , "" )
264
- .split (", " )
264
+ .text .replace ("\n " , "" )
265
+ .replace ("\t " , "" )
266
+ .replace ("\r " , "" )
267
+ .split (", " )
265
268
)
266
269
teacher = teacher_classroom [0 ]
267
- classroom = teacher_classroom [1 ]
270
+ classroom = teacher_classroom [
271
+ 1 ]
268
272
except IndexError :
269
273
pass
270
274
except AttributeError :
@@ -282,7 +286,8 @@ def get_schedule_data(
282
286
"event" : event ,
283
287
"hour" : hour_name ,
284
288
"week_day" : int (day_num ),
285
- "hour_in_block" : int (classes_in_hour ),
289
+ "hour_in_block" : int (
290
+ classes_in_hour ),
286
291
"date" : date_formatted ,
287
292
}
288
293
scraped_data [day_num ][hour_name ][
@@ -314,5 +319,15 @@ def get_schedule_data(
314
319
scraped_data ["request_data" ]["class" ] = current_class
315
320
scraped_data ["request_data" ]["request_week" ] = current_week
316
321
scraped_data ["request_data" ]["request_epoch" ] = request_time
322
+ scraped_data ["request_data" ]["used_data" ] = \
323
+ {
324
+ "school_id" : school_id ,
325
+ "class_id" : class_id ,
326
+ "professor" : professor ,
327
+ "classroom" : classroom ,
328
+ "interest_activity" : interest_activity ,
329
+ "school_week" : school_week ,
330
+ "student_id" : student_id
331
+ }
317
332
318
333
return scraped_data
0 commit comments