commit ec4492bfa82e79a32bc0cc0c8b6e215f29b2b300 Author: starnakin Date: Sun Oct 29 23:38:04 2023 +0100 init scrapper diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..fab2a79 --- /dev/null +++ b/src/main.py @@ -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)