From d66849b092de7c01be6085f90014556b4c007fa9 Mon Sep 17 00:00:00 2001 From: valoka Date: Sat, 21 Sep 2024 00:35:42 +0900 Subject: [PATCH] added raw week number --- main.py | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index 7c183fa..5f29094 100644 --- a/main.py +++ b/main.py @@ -16,6 +16,7 @@ intents = discord.Intents.default() prikols = commands.Bot(intents=intents, command_prefix = '!') # consts +weekdays = ("Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье") options.headless = True intents.message_content = True intents.messages = True @@ -28,7 +29,7 @@ url = "https://amursu.ru/obrazovanie/timetable/timetable-group/?id_group=1891" # 3. приводим в читаемый вид | fail # 4. отправляем в дс | ок -def get_element_from_driver(url, instruction : list) -> list: +def get_element_from_driver(url : str, instruction : list) -> list: driver = webdriver.Firefox() driver.implicitly_wait(10) driver.get(url) @@ -55,6 +56,12 @@ def get_day_info(html : str) -> list: return soupa +# надо будет вынести 80 строчку в эту функцию ок? +def get_current_week_number(html): + # /html/body/main/div[2]/div/div/div[3]/div[4]/div[2] + soup = BeautifulSoup(html, "lxml") + current_week = soup.find("div") + return current_week.text() @prikols.command() async def day(ctx, arg): @@ -70,17 +77,14 @@ async def week(ctx): for day in range(3,9): arr.append(f'/html/body/main/div[2]/div/div/div[3]/div[4]/div[{day}]') + arr.append('/html/body/main/div[2]/div/div/div[3]/div[4]/div[2]') html = get_element_from_driver(url=url, instruction=arr) - for i in html: - await ctx.send(get_day_info(i)) + for i in range(len(html)): + await ctx.send(weekdays[i] + f" {html[len(arr)-1]}" + "\n" + get_day_info(html[i])) except BaseException as err: await ctx.send(err) -# @prikols.command() -# async def week(ctx, arg): -# await ctx.send(get_day_info(arg, url=url)) - @prikols.event async def on_ready(): print('yolo')