Финальные штрихи
This commit is contained in:
parent
25f65f7680
commit
909cd91c2b
51
main.py
51
main.py
@ -9,14 +9,19 @@
|
||||
from bs4 import BeautifulSoup
|
||||
import re
|
||||
import requests
|
||||
import sys
|
||||
|
||||
useragent = "Mozilla/5.0 (X11; Linux x86_64; rv:109.0) Gecko/20100101 Firefox/112.0"
|
||||
|
||||
stud_group = "3131"
|
||||
|
||||
if __name__ == '__main__':
|
||||
print("Hello, fucker")
|
||||
|
||||
fucker_name = "Тебя"
|
||||
print("Hello, fucker, what is ur name?")
|
||||
fucker_name = input()
|
||||
print("Your group?")
|
||||
stud_group = input()
|
||||
if stud_group == '':
|
||||
print("Введи группу")
|
||||
sys.exit(1)
|
||||
init_url = "https://guap.ru/rasp/"
|
||||
init_headers = {
|
||||
'User-Agent': useragent
|
||||
@ -24,12 +29,6 @@ if __name__ == '__main__':
|
||||
init_html = requests.get(init_url, headers=init_headers)
|
||||
|
||||
soup = BeautifulSoup(init_html.text.strip(), 'html.parser')
|
||||
# print(soup.prettify())
|
||||
|
||||
|
||||
# print(soup.findAll('группа:'))
|
||||
# print(soup.getText())
|
||||
# crypted_shit = soup.find('div', class_="aspNetHidden")
|
||||
|
||||
# Реверс инжиринг __doPostBack
|
||||
#
|
||||
@ -82,8 +81,6 @@ if __name__ == '__main__':
|
||||
val = soup.find('input', {"id": i['name']})
|
||||
i['value'] = val.get('value')
|
||||
|
||||
# print(cryptshits)
|
||||
|
||||
# Теперь нам надо распарсить список групп и найти нужную
|
||||
|
||||
rasp = soup.find('div', {"class": "rasp"})
|
||||
@ -99,7 +96,6 @@ if __name__ == '__main__':
|
||||
break
|
||||
else:
|
||||
for group in group_html_block.parent.findAll('option'):
|
||||
# print(group.contents, group.get('value'))
|
||||
if group.get('value') != "-1":
|
||||
groups.append({
|
||||
"name": group.contents[0],
|
||||
@ -119,7 +115,6 @@ if __name__ == '__main__':
|
||||
post_data["&ctl00%24cphMain%24ctl06"] = -1
|
||||
post_data["&ctl00%24cphMain%24ctl07"] = -1
|
||||
post_data["&ctl00%24cphMain%24ctl08"] = -1
|
||||
# print(post_data)
|
||||
|
||||
post_headers = {"Content-Type": "application/x-www-form-urlencoded", 'User-Agent': useragent}
|
||||
post_url = "https://guap.ru/rasp/?g={}".format(post_data['ctl00%24cphMain%24ctl05'])
|
||||
@ -131,8 +126,6 @@ if __name__ == '__main__':
|
||||
# В переменную записываем само расписание, без остальной страницы
|
||||
rasp_html = soup_result.find('div', {'class', 'result'})
|
||||
|
||||
# print(result_html.prettify())
|
||||
|
||||
rasp_summary = list()
|
||||
# Пример rasp_summary
|
||||
# (
|
||||
@ -151,16 +144,15 @@ if __name__ == '__main__':
|
||||
# 1012
|
||||
# ),
|
||||
# "place": "– Б.Морская 67, ауд. спортзал*",
|
||||
# "up_or_down": None
|
||||
# "up_or_down": 'none'
|
||||
# }
|
||||
# )
|
||||
# }
|
||||
# )
|
||||
# Верхняя - нечетная неделя
|
||||
# Нижняя - четная неделя
|
||||
# Верстка сайта на высоте. Придется использовать next_siblings. Хвататься не за что.
|
||||
|
||||
|
||||
|
||||
# print(rasp_html.prettify())
|
||||
rasp_html_inside = rasp_html.find('div')
|
||||
# Это будет ужасно...
|
||||
cur_day = ""
|
||||
@ -191,9 +183,9 @@ if __name__ == '__main__':
|
||||
|
||||
# Верхняя или нижняя?
|
||||
up_or_down = 'none'
|
||||
if cur_sibl.find('b', {'class':'up'}):
|
||||
if cur_sibl.find('b', {'class': 'up'}):
|
||||
up_or_down = 'up'
|
||||
if cur_sibl.find('b', {'class':'dn'}):
|
||||
if cur_sibl.find('b', {'class': 'dn'}):
|
||||
up_or_down = 'down'
|
||||
|
||||
# Тип пары (лекция)
|
||||
@ -209,14 +201,12 @@ if __name__ == '__main__':
|
||||
for prep in preps_block.findAll('a'):
|
||||
preps.append(prep.text)
|
||||
|
||||
|
||||
# Группы
|
||||
groups = list()
|
||||
group_block = cur_sibl.find('span', {'class': 'groups'})
|
||||
for group in group_block.findAll('a'):
|
||||
groups.append(group.text)
|
||||
|
||||
|
||||
# место, аудитория
|
||||
place = cur_sibl.find('em')
|
||||
|
||||
@ -239,13 +229,18 @@ if __name__ == '__main__':
|
||||
case _:
|
||||
print('wtf')
|
||||
|
||||
# print(rasp_summary)
|
||||
|
||||
from datetime import date
|
||||
import locale
|
||||
|
||||
locale.setlocale(locale.LC_TIME, "ru_RU.UTF-8")
|
||||
today_weekday = date.today().strftime('%A')
|
||||
print("Сегодня {}".format(today_weekday))
|
||||
today_week = date.today().strftime('%U')
|
||||
print("Сегодня {}, {} ебали на:".format(today_weekday, fucker_name))
|
||||
for para in rasp_summary:
|
||||
if para['date'] == today_weekday:
|
||||
print(para['value']['name'])
|
||||
if para['value']['up_or_down'] == 'up' and today_week % 2 != 0:
|
||||
print(para['value']['type'], para['value']['name'])
|
||||
elif para['value']['up_or_down'] == 'down' and today_week % 2 == 0:
|
||||
print(para['value']['type'], para['value']['name'])
|
||||
elif para['value']['up_or_down'] == 'none':
|
||||
print(para['value']['type'], para['value']['name'])
|
||||
|
Loading…
Reference in New Issue
Block a user