Skip to content

Commit

Permalink
Merge pull request #252 from Friendly-Banana/master
Browse files Browse the repository at this point in the history
fix dishes scraping path
  • Loading branch information
CommanderStorm authored Jul 26, 2024
2 parents e707741 + 2aec5a4 commit 2893893
Show file tree
Hide file tree
Showing 72 changed files with 62,883 additions and 66,096 deletions.
9 changes: 9 additions & 0 deletions scripts/download.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# get from entities.py
canteen_id='414'
month='08'
year='2024'

# url needs two digits
for day in {01..31}; do
wget "https://www.studierendenwerk-muenchen-oberbayern.de/mensa/speiseplan/speiseplan_${year}-${month}-${day}_${canteen_id}_-de.html" -O "${year}-${month}-${day}.html"
done
4 changes: 2 additions & 2 deletions src/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ def __init__(
def __repr__(self):
if self.price_per_unit and self.unit:
if isinstance(self.base_price, float):
return f"{self.base_price:.2f}€ + {self.price_per_unit:.2f} {self.unit}"
return f"{self.base_price: .2f}€ + {self.price_per_unit: .2f} {self.unit}"
return f"{self.base_price} + {self.price_per_unit} {self.unit}"
if isinstance(self.base_price, float):
return f"{self.base_price:.2f}€"
return f"{self.base_price: .2f}€"
return f"{self.base_price}"

def __eq__(self, other: Any) -> bool:
Expand Down
21 changes: 10 additions & 11 deletions src/menu_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -305,9 +305,7 @@ def __get_daily_menus_as_html(page):
@staticmethod
def __parse_dishes(menu_html: html.Element, canteen: Canteen) -> List[Dish]:
# obtain the names of all dishes in a passed menu
dish_names: List[str] = [
dish.rstrip() for dish in menu_html.xpath("//p[@class='js-schedule-dish-description']/text()")
]
dish_names: List[str] = [dish.rstrip() for dish in menu_html.xpath("//p[@class='c-menu-dish__title']/text()")]
# make duplicates unique by adding (2), (3) etc. to the names
dish_names = util.make_duplicates_unique(dish_names)
# obtain the types of the dishes (e.g. 'Tagesgericht 1')
Expand All @@ -319,19 +317,20 @@ def __parse_dishes(menu_html: html.Element, canteen: Canteen) -> List[Dish]:
dish_types += [current_type]
# obtain all labels
dish_markers_additional: List[str] = menu_html.xpath(
"//li[contains(@class, 'c-schedule__list-item u-clearfix clearfix "
"js-menu__list-item')]/@data-essen-zusatz",
"//li[contains(@class, 'c-menu-dish-list__item u-clearfix "
"clearfix js-menu__list-item')]/@data-essen-zusatz",
)
dish_markers_allergen: List[str] = menu_html.xpath(
"//li[contains(@class, 'c-schedule__list-item u-clearfix clearfix "
"js-menu__list-item')]/@data-essen-allergene",
"//li[contains(@class, 'c-menu-dish-list__item u-clearfix "
"clearfix js-menu__list-item')]/@data-essen-allergene",
)
dish_markers_type: List[str] = menu_html.xpath(
"//li[contains(@class, 'c-schedule__list-item u-clearfix clearfix js-menu__list-item')]/@data-essen-typ",
"//li[contains(@class, 'c-menu-dish-list__item u-clearfix "
"clearfix js-menu__list-item')]/@data-essen-typ",
)
dish_markers_meetless: List[str] = menu_html.xpath(
"//li[contains(@class, 'c-schedule__list-item u-clearfix clearfix "
"js-menu__list-item')]/@data-essen-fleischlos",
"//li[contains(@class, 'c-menu-dish-list__item u-clearfix "
"clearfix js-menu__list-item')]/@data-essen-fleischlos",
)

# create dictionary out of dish name and dish type
Expand Down Expand Up @@ -369,7 +368,7 @@ def __parse_dishes(menu_html: html.Element, canteen: Canteen) -> List[Dish]:
labels |= StudentenwerkMenuParser._parse_label(dishes_dict[name][2])
labels |= StudentenwerkMenuParser._parse_label(dishes_dict[name][3])
StudentenwerkMenuParser.__add_diet(labels, dishes_dict[name][4])
# do not prices side dishes
# do not price side dishes
prices: Prices
if dishes_dict[name][0] == "Beilagen":
# set classic prices without any base price
Expand Down
1,350 changes: 0 additions & 1,350 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-13.html

This file was deleted.

1,520 changes: 0 additions & 1,520 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-14.html

This file was deleted.

1,384 changes: 0 additions & 1,384 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-15.html

This file was deleted.

1,384 changes: 0 additions & 1,384 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-16.html

This file was deleted.

1,382 changes: 0 additions & 1,382 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-17.html

This file was deleted.

1,350 changes: 0 additions & 1,350 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-20.html

This file was deleted.

1,282 changes: 0 additions & 1,282 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-21.html

This file was deleted.

1,316 changes: 0 additions & 1,316 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-22.html

This file was deleted.

1,299 changes: 0 additions & 1,299 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-23.html

This file was deleted.

1,299 changes: 0 additions & 1,299 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2021-09-24.html

This file was deleted.

1,600 changes: 1,600 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-07-29.html

Large diffs are not rendered by default.

1,728 changes: 1,728 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-07-30.html

Large diffs are not rendered by default.

1,632 changes: 1,632 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-07-31.html

Large diffs are not rendered by default.

1,408 changes: 1,408 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-08-01.html

Large diffs are not rendered by default.

1,376 changes: 1,376 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-08-02.html

Large diffs are not rendered by default.

1,438 changes: 1,438 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-08-05.html

Large diffs are not rendered by default.

1,438 changes: 1,438 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-08-06.html

Large diffs are not rendered by default.

1,470 changes: 1,470 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-08-07.html

Large diffs are not rendered by default.

1,502 changes: 1,502 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-08-08.html

Large diffs are not rendered by default.

1,406 changes: 1,406 additions & 0 deletions src/test/assets/studentenwerk/mensa-arcisstr/for-generation/2024-08-09.html

Large diffs are not rendered by default.

Loading

0 comments on commit 2893893

Please sign in to comment.