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 = '!')
|
prikols = commands.Bot(intents=intents, command_prefix = '!')
|
||||||
|
|
||||||
# consts
|
# consts
|
||||||
|
weekdays = ("Понедельник", "Вторник", "Среда", "Четверг", "Пятница", "Суббота", "Воскресенье")
|
||||||
options.headless = True
|
options.headless = True
|
||||||
intents.message_content = True
|
intents.message_content = True
|
||||||
intents.messages = True
|
intents.messages = True
|
||||||
@@ -28,7 +29,7 @@ url = "https://amursu.ru/obrazovanie/timetable/timetable-group/?id_group=1891"
|
|||||||
# 3. приводим в читаемый вид | fail
|
# 3. приводим в читаемый вид | fail
|
||||||
# 4. отправляем в дс | ок
|
# 4. отправляем в дс | ок
|
||||||
|
|
||||||
def get_element_from_driver(url, instruction : list) -> list:
|
def get_element_from_driver(url : str, instruction : list) -> list:
|
||||||
driver = webdriver.Firefox()
|
driver = webdriver.Firefox()
|
||||||
driver.implicitly_wait(10)
|
driver.implicitly_wait(10)
|
||||||
driver.get(url)
|
driver.get(url)
|
||||||
@@ -55,6 +56,12 @@ def get_day_info(html : str) -> list:
|
|||||||
|
|
||||||
return soupa
|
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()
|
@prikols.command()
|
||||||
async def day(ctx, arg):
|
async def day(ctx, arg):
|
||||||
@@ -70,17 +77,14 @@ async def week(ctx):
|
|||||||
for day in range(3,9):
|
for day in range(3,9):
|
||||||
arr.append(f'/html/body/main/div[2]/div/div/div[3]/div[4]/div[{day}]')
|
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)
|
html = get_element_from_driver(url=url, instruction=arr)
|
||||||
|
|
||||||
for i in html:
|
for i in range(len(html)):
|
||||||
await ctx.send(get_day_info(i))
|
await ctx.send(weekdays[i] + f" {html[len(arr)-1]}" + "\n" + get_day_info(html[i]))
|
||||||
except BaseException as err:
|
except BaseException as err:
|
||||||
await ctx.send(err)
|
await ctx.send(err)
|
||||||
|
|
||||||
# @prikols.command()
|
|
||||||
# async def week(ctx, arg):
|
|
||||||
# await ctx.send(get_day_info(arg, url=url))
|
|
||||||
|
|
||||||
@prikols.event
|
@prikols.event
|
||||||
async def on_ready():
|
async def on_ready():
|
||||||
print('yolo')
|
print('yolo')
|
||||||
|
|||||||
Reference in New Issue
Block a user