Skip to content

Commit

Permalink
Fix Bryggan menu parsing.
Browse files Browse the repository at this point in the history
  • Loading branch information
zozs committed Apr 24, 2019
1 parent 6717993 commit 4311da9
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions menus/bryggan.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
class Bryggan(Menu):

def __init__(self):
self.url = 'http://www.bryggancafe.se/veckans-lunch/'
self.url = 'https://www.bryggancafe.se/veckans-lunch/'
self.menu = collections.defaultdict(list)
# swedish day of week names
self.dow = {0: 'Måndag', 1: 'Tisdag', 2: 'Onsdag', 3: 'Torsdag', 4: 'Fredag'}
Expand Down Expand Up @@ -38,6 +38,7 @@ def get_week(self):
for p in menu_list.find_all('p', recursive=False):
# get data in each p-tag and ignore em and u tags.
data = p.text.strip()
#print('last_day:', last_day, 'got data:', data)
if len(data) == 0:
continue

Expand All @@ -51,9 +52,12 @@ def get_week(self):
last_day = data
continue

# if we reach here, it was probably food, anything that starts with
# the string "Dagens:" or "Veg:" is considered food.
if last_day and (data.startswith('Dagens:') or data.startswith('Veg:')):
# if we reach here, it was probably food, anything that isn't containing
# "eventuella allergier", "Med reservation", or "Öppet Måndag"
# is considered food
if last_day and ('eventuella allergier' not in data and
'Med reservation' not in data and
'Öppet Måndag' not in data):
self.menu[last_day].append(data.strip())

return self.menu
Expand Down

0 comments on commit 4311da9

Please sign in to comment.