wulkanowy-web/app/API/dashboard.py

37 lines
1.4 KiB
Python
Raw Normal View History

2021-01-13 23:39:08 +01:00
import json
import requests
import re
from bs4 import BeautifulSoup
2021-02-05 20:22:24 +01:00
from .generate_cookies import autogenerate_cookies
2021-01-13 23:39:08 +01:00
2021-02-05 20:12:07 +01:00
def get_dashboard(register_id, students, s, diary_url, symbol):
2021-06-08 19:23:31 +02:00
if diary_url != 'http://cufs.fakelog.tk/':
diary_url = 'http://uonetplus.vulcan.net.pl/'
else:
2021-06-08 19:23:31 +02:00
diary_url = 'http://uonetplus.fakelog.tk/'
2021-02-05 20:22:24 +01:00
cookies = autogenerate_cookies(students, s)
2021-01-13 23:39:08 +01:00
2021-02-05 20:22:24 +01:00
with open('app/API/headers.json') as f:
headers = json.load(f)
2021-01-13 23:39:08 +01:00
index = requests.get(f'{diary_url}{symbol}/Start.mvc/Index', headers=headers, cookies=cookies)
2021-01-14 22:13:06 +01:00
permissions_value = re.search("permissions: '(.)*'", index.text)
permissions_value = permissions_value.group()
permissions_value = permissions_value.replace('permissions: ', '').replace("'", "")
2021-01-13 23:39:08 +01:00
2021-02-02 23:56:38 +01:00
permissions = {
2021-01-14 22:13:06 +01:00
"permissions": permissions_value
}
2021-02-02 23:56:38 +01:00
last_notes = requests.post(f'{diary_url}{symbol}/Start.mvc/GetLastNotes', headers=headers, cookies=cookies, json=permissions)
free_days = requests.post(f'{diary_url}{symbol}/Start.mvc/GetFreeDays', headers=headers, cookies=cookies, json=permissions)
lucky_number = requests.post(f'{diary_url}{symbol}/Start.mvc/GetKidsLuckyNumbers', headers=headers, cookies=cookies, json=permissions)
2021-01-14 22:13:06 +01:00
return_data = {
"last_notes": last_notes.json(),
"free_days": free_days.json(),
"lucky_number": lucky_number.json()
}
return return_data