def getMenu(today): dom = get_dom(URL) menu = dom.xpath( "/html/body//div[@id='heti-menu']//ul[@class='dotted']/li/text()") menu = list(skip_empty_lines(menu)) return menu
def get_menu(today): dom = get_dom(URL_ROOT) menu = dom.xpath("/html/body//article//text()") menu = pattern_slice(menu, [days_lower[today.weekday()]], days_lower + ['ára', 'előfizetés', 'ajánlat'], inclusive=False) return list(skip_empty_lines(menu))
def getMenu(today): day = today.weekday() dom = get_dom(URL) menu = dom.xpath( "/html/body//div[@class='fck']/*[self::h3 or self::p]//text()") menu = dropwhile(lambda line: days_lower[day] not in line.lower(), menu) menu = islice(skip_empty_lines(menu), 1, 3) menu = list(menu) return menu
def getMenu(today): is_this_week = lambda date: datetime.strptime( date, '%Y-%m-%dT%H:%M:%S%z').date() > today.date() - timedelta(days=7) menu_filter = lambda post: is_this_week(post['created_time']) and sum( day in post['message'].lower() for day in days_lower) >= 2 menu = get_filtered_fb_post(FB_ID, menu_filter) menu = pattern_slice(menu.splitlines(), [days_lower[today.weekday()]], days_lower + ["tel:", "797"]) return list(skip_empty_lines(menu))
def getMenu(today): day = today.weekday() dom = get_dom(URL) menu = dom.xpath( '/html/body//section[@id="hetimenu"]//div[contains(@class, "text_box")]' ) menu = filter(lambda l: "menü ára" not in l, menu[day].xpath("p//text()")) menu = list(skip_empty_lines(menu)) return menu
def get_menu(today): is_today = lambda date: datetime.strptime(date, '%Y-%m-%dT%H:%M:%S%z' ).date() == today.date() menu_filter = lambda post: is_today(post[ 'created_time']) and "mai menü" in post['message'].lower() menu = get_filtered_fb_post(FB_ID, menu_filter) drop_words = ["mai menünk", "jó étvágyat"] menu = skip_empty_lines( filter(lambda l: not any(word in l.lower() for word in drop_words), menu.splitlines())) return list(menu)
def get_menu(today): is_today = lambda date: datetime.strptime(date, '%Y-%m-%dT%H:%M:%S%z' ).date() == today.date() menu_filter = lambda post: is_today(post[ 'created_time']) and "menü" in post['message'].lower() menu = get_filtered_fb_post(FB_ID, menu_filter).splitlines() menu = list( skip_empty_lines(line.strip() for line in menu if "menü" not in line.lower())) return menu
def get_menu(today): is_today = lambda date: datetime.strptime(date, '%Y-%m-%dT%H:%M:%S%z' ).date() == today.date() menu_filter = lambda post: is_today(post['created_time']) and \ any(word in post['message'].lower() for word in ["ebédmenü", "ebéd menü", "mai menü", "déli menü", "mai ebéd", "ajánlat"]) menu = get_filtered_fb_post(FB_ID, menu_filter) drop_words = ["ajánlat", "tacskó", "ebéd", "menü", "="] menu = list( skip_empty_lines( filter(lambda l: not any(word in l.lower() for word in drop_words), menu.splitlines()))) return menu
def getMenu(today): dom = get_dom(URL) date = today.strftime("%Y-%m-%d") menu = dom.xpath( f'/html/body//div[@id="NapiEbedMenu"]//tr[.//div[contains(text(), "{ date }")]]/td[position()=2 or position()=3]//text()' ) if menu: menu = list(skip_empty_lines(menu)) else: menu = [] return menu
def getMenu(today): is_this_week = lambda date: datetime.strptime( date, '%Y-%m-%dT%H:%M:%S%z').date() > today.date() - timedelta(days=7) menu_filter = lambda post: is_this_week(post['created_time']) and \ any(word in post['message'].lower() for word in ["lunch menü ", "business lunch", "előételek", "déli menü", "heti menü", "menünk"]) menu = get_filtered_fb_post(FB_ID, menu_filter) drop_words = [ "előételek", "főételek", "desszer", "étvágy", "menü", "lunch" ] menu = skip_empty_lines( filter(lambda l: not any(word in l.lower() for word in drop_words), menu.splitlines())) menu = pattern_slice(menu, [""], ["---", "broth", "soup"], inclusive=True) return list(menu)
def getMenu(today): is_today = lambda date: datetime.strptime(date, '%Y-%m-%dT%H:%M:%S%z' ).date() == today.date() menu_keywords = ["mai menü", "napi menü", days_lower[today.weekday()]] menu_filter = lambda post: is_today(post['created_time']) and any( word in post['message'].lower() for word in menu_keywords) menu = get_filtered_fb_post(FB_ID, menu_filter) drop_words = [ "11:00", "1590", "mindenkit", "minden menü", "étlapunk", "csodás", days_lower[today.weekday()] ] menu = (line for line in menu.splitlines() if not any(word in line.lower() for word in drop_words)) return list(skip_empty_lines(menu))
def getMenu(today): dom = get_dom(URL) this_year = today.strftime("%Y") menu_date = dom.xpath(f"/html/body//span[contains(text(), '{this_year}')]/text()") menu_date = menu_date[0].split('-')[0] if len(menu_date) > 0 else -1 if menu_date is not -1 and dt.strptime(menu_date, "%Y.%m.%d").date() > today.date() - timedelta(days=6): menu = list(skip_empty_lines([p.text_content() for p in dom.xpath('/html/body//div[@id="comp-jhonyf7y"]//p')])) if any(days_lower[today.weekday()] in line for line in menu): menu = list(pattern_slice(menu, [days_lower[today.weekday()]], days_lower, inclusive=False)) else: menu = list(menu) menu = [item.replace('\xa0', ' ') for item in menu] else: menu = [] return menu
def get_menu(today): is_this_week = lambda date: datetime.strptime(date, '%Y-%m-%dT%H:%M:%S%z').date() >= today.date() - timedelta(days=7) menu_filter = lambda post: is_this_week(post['created_time']) and "heti menü" in post['message'].lower() image = get_fb_post_attached_image(FB_ID, menu_filter) if image: image = Image.open(BytesIO(image)).convert('L') f = BytesIO() image.save(f, format="png", optimize=True) menu = ocr_image(f).splitlines() if not menu: return [] menu = pattern_slice(menu, [days_lower[today.weekday()]], days_lower + ['desszert', "890"], inclusive=False) menu = list(skip_empty_lines(menu)) else: return [] return menu
def getMenu(today): is_this_week = lambda date: datetime.strptime( date, '%Y-%m-%dT%H:%M:%S%z').date() > today.date() - timedelta(days=7) is_today = lambda date: datetime.strptime(date, '%Y-%m-%dT%H:%M:%S%z' ).date() == today.date() menu_filter = lambda post: (is_this_week(post['created_time']) and days_lower[today.weekday()] in post['message'].lower() and "asztalfoglalás" not in post['message'].lower()) \ or ("menü" in post['message'].lower() and is_today(post['created_time']) and "asztalfoglalás" not in post['message'].lower()) menu = get_filtered_fb_post(FB_ID, menu_filter) menu = pattern_slice(menu.splitlines(), [days_lower[today.weekday()], "mai", "menü"], days_lower + ["ár:"]) return list(skip_empty_lines(menu))
def getMenu(today): dom = get_dom(URL) weekday = today.weekday() rows = iter(dom.xpath(f'/html/body//table//tr')) table = [] for row in rows: row = [col.text_content().strip() for col in row] table.append(row) table = list(map(list, zip(*table))) menu = [] for column in table: if days_lower[weekday] in column[0].lower(): menu = list(skip_empty_lines(column[1:])) break return menu