added raw week number
This commit is contained in:
18
main.py
18
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')
|
||||
|
||||
Reference in New Issue
Block a user