-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathany.py
More file actions
executable file
·30 lines (27 loc) · 1.09 KB
/
any.py
File metadata and controls
executable file
·30 lines (27 loc) · 1.09 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
from requests import get
from students_repository import StudentsRepository
import time
import re
repository = StudentsRepository()
def get_content(first_time):
response = get("http://anytask.urgu.org/course/47")
content = response.content.decode()
a = re.findall(r"<td>(.*?)</td>", content)
b = re.findall(r'<td align="center" class="student_(.*?)">', content)
for i in range(0, len(a), 3):
number = int(b[(i // 3) * 11])
scores = re.findall(r'<td align="center" class="student_{}">.*?<span class="label.*?">(.*?)</span>.*?</td>'.format(number), content, re.DOTALL)
for j in range(len(scores)):
scores[j] = int(scores[j])
if first_time:
student_info = [a[i].replace(" ", " "), a[i + 1], number, scores]
repository.add_new_student(student_info)
else:
repository.try_to_change_student(number, scores)
if not first_time:
repository.get_report()
get_content(True)
print("Программа заработала")
while True:
time.sleep(60)
get_content(False)