init scrapper

This commit is contained in:
starnakin 2023-10-29 23:38:04 +01:00
commit ec4492bfa8

27
src/main.py Normal file
View File

@ -0,0 +1,27 @@
import bs4
import requests
import os
url: str = os.getenv('SITE_URL')
response: requests.models.Response = requests.get(url)
soup: bs4.BeautifulSoup = bs4.BeautifulSoup(response.content, 'html.parser')
menus = soup.findAll('ul', {'class': 'meal_foodies'})
dates = soup.findAll('time', {'class': 'menu_date_title'})
dictionnary: dict = {}
for date, menu in zip(dates, menus):
subdict: dict = {}
type_of: str = ""
elements = menu.findAll('li')
for element in elements:
if len(element.contents) > 1:
type_of = element.contents[0]
subdict.update({type_of: []})
else:
subdict[type_of].append(element.contents[0])
dictionnary.update({date.text: subdict})
print(dictionnary)