-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwork_with_api.py
More file actions
30 lines (24 loc) · 1.31 KB
/
Copy pathwork_with_api.py
File metadata and controls
30 lines (24 loc) · 1.31 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
"""Need for parsing"""
import requests
def get_providers() -> dict[str]:
"""
Ничего не принимает. \n
Возвращает все универы/структурные подразделения кфу, \n
если может получить доступ к api иначе возвращает None
"""
req = requests.get("http://sanyapilot.ru:10010/providers", timeout=1000)
return req.json() if req.status_code == 200 else None
def get_groups(provider: str) -> dict[str]:
"""
Возвращает все группы в данном структурном подразделении кфу.\n
Если такого подразделения не найденно возвращает None.
"""
req = requests.get(f"http://sanyapilot.ru:10010/{provider}/groups", timeout=1000)
return req.json() if req.status_code == 200 else None
def get_group(provider: str, group_id: int) -> dict[str]:
"""
Возвращает расписание для данной конкретной группы. \n
Если ничего не нашел или запрос не удался возвращает None
"""
req = requests.get(f"http://sanyapilot.ru:10010/{provider}/{group_id}", timeout=1000)
return req.json() if req.status_code == 200 else None