import requests import json import datetime from datetime import datetime as dt from bs4 import BeautifulSoup try: from load import config except: config = None from .utils import * headers = { 'user-agent':( "Mozilla/5.0 (Windows NT 10.0; WOW64) " "AppleWebKit/537.36 (KHTML, like Gecko) " "Chrome/62.0.3202.9 Safari/537.36" ) } def date_parser_helper(days:int, parse:str="%d.%m.20%y"): return dt.strftime( dt.now() + datetime.timedelta(days=days), parse ) def docs_parse(): output = { "data":{}, "another_teacher":None } page = requests.get(config.bot("link"), headers=headers) page.encoding = 'utf-8' soup = BeautifulSoup(page.text, "html.parser") # Это в идеале нужно переписать... try: output = table_parser(soup, output); #print(output) except Exception: pass try: output = one_parser(soup, output); #print(output) except Exception: pass try: output = parser_two(soup, output); print(output) except Exception as e: raise(e) #try: output = parser3(soup, output); print(output) #except Exception as e: raise(e) with open(config.data_file, 'w') as f: json.dump(output, f, ensure_ascii=False) f.close() def get_about_replacements() -> dict: with open(config.data_file, 'r') as f: data = json.loads(f.read()) f.close() return data