コード例 #1
0
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
コード例 #2
0
ファイル: keg.py プロジェクト: Zolikon/ebedke
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
コード例 #3
0
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))
コード例 #4
0
ファイル: vigvarju.py プロジェクト: Zolikon/ebedke
def getMenu(today):
    dom = get_dom(URL)
    date = f"{months_hu_capitalized[today.month - 1]} {today.day}"
    menu = dom.xpath(
        f'/html/body//p[contains(preceding-sibling::p, "{date}")]/text()')
    menu = list(dish.strip() for dish in menu)

    return menu
コード例 #5
0
def getMenu(today):
    dom = get_dom(URL, force_utf8=True)
    weekday = today.isoweekday()
    items = dom.xpath(f"//blockquote[{weekday}]//text()")[1:]
    for stopword in ["LEVES", "FŐÉTEL", "DESSZERT", "ELŐÉTEL", ":"] + days_upper:
        items = [re.sub(f'({stopword}):? ?', '', i).strip() for i in items]
    menu = list(line.strip() for line in items if line)
    return menu
コード例 #6
0
ファイル: opus.py プロジェクト: Zolikon/ebedke
def getMenu(today):
    dom = get_dom(URL)
    date = f"{today.year}.{hungarian_month[today.month]}.{today.day:02}"
    menu = dom.xpath(
        f"//div[contains(@class, 'dailymenudish') and contains(preceding-sibling::div, '{ date }')]//text()"
    )
    menu = list(dish.strip() for dish in menu)

    return menu
コード例 #7
0
ファイル: joasszony.py プロジェクト: Zolikon/ebedke
def getMenu(today):
    dom = get_dom(URL, force_utf8=True)
    date = dom.xpath("/html/body//div[@class='maidatum']/text()")
    date = date.pop().strip() if date else None
    if date == today.strftime("%Y-%m-%d"):
        menu = dom.xpath("/html/body//div[@class='napimenu']/p/text()")
        menu = list(menu)
    else:
        menu = ''
    return menu
コード例 #8
0
ファイル: jegkert.py プロジェクト: Zolikon/ebedke
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
コード例 #9
0
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
コード例 #10
0
ファイル: intenzo.py プロジェクト: Zolikon/ebedke
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
コード例 #11
0
def getMenu(today):
    day = today.weekday()
    dom = get_dom(URL)
    menu = dom.xpath('/html/body//div[@class="sppb-menu-text"]')
    if len(menu) < 4:
        menu = []
    else:
        menu = menu[day].xpath("text()")

    return menu
コード例 #12
0
ファイル: jedermann.py プロジェクト: Zolikon/ebedke
def get_menu(today):
    dom = get_dom(URL, force_utf8=True)
    menudate = ''.join(dom.xpath('/html/body//div[@id="datum"]//text()'))
    start_month, start_day, *_ = split(" |-", menudate)
    menu_start_date = date(today.year, parse_hungarian_month(start_month), int(start_day))
    if menu_start_date <= today.date() < menu_start_date + timedelta(days=7):
        menu = dom.xpath('/html/body//div[preceding-sibling::div[@id="datum"]]//article[@class="lmenu"]//text()')
        menu = pattern_slice(menu, [days_lower[today.weekday()]], days_lower)
    else:
        menu = []
    return menu
コード例 #13
0
def get_menu(today):
    dom = get_dom(URL)
    weeklymenu = dom.xpath("/html/body//div[contains(@class, 'hetimenupluginbox')]")
    clean = lambda text: '\n'.join(n.strip() for n in text)
    weeklymenu = {
        clean(day.xpath("./div[@class='datum']//text()")): clean(day.xpath("./div[@class='hetimenulist']//text()"))
        for day in weeklymenu
    }

    date = f"{months_hu_capitalized[today.month - 1]} {today.day:02}."
    return weeklymenu[date.lower()].splitlines()
コード例 #14
0
def getMenu(today):
    dom = get_dom(URL)
    date = today.strftime("%Y. %m. %d.")
    menu = dom.xpath(
        f'//section[@id="weekly_menu"]/ul/li[.//time[contains(text(), "{ date }")]]'
        '//div[@class="weeklyMenuPreview-content"]')
    if menu:
        menu = list(menu[0].xpath("./p/text()"))
    else:
        menu = []

    return menu
コード例 #15
0
def getMenu(today):
    day = today.weekday() + 3
    dom = get_dom(URL)
    menu_date = dom.xpath('/html/body//div[@id="content-area"]/p/text()').pop()
    menu_date = dt.strptime(menu_date.split()[0], "%Y-%m-%d")
    if menu_date >= today - timedelta(days=6):
        tds = dom.xpath(f'(//div[@id="main-content"]//table)[1]//tr[position() > 0 and position() < 5]/td[{ day }]')
        menu = list(td.text_content().strip() for td in tds)
    else:
        menu = []

    return menu
コード例 #16
0
def getMenu(today):
    day = today.weekday()
    dom = get_dom(URL)
    date = dom.xpath('//div[@class="content-right"]//h2/text()')
    date = date[0].strip().split('|')[1].strip()[:5]
    date = datetime.strptime(f'{ today.year }.{ date }', '%Y.%m.%d').date()
    if date > today.date() - timedelta(days=7):
        menu = dom.xpath('//div[@class="content-right"]//div/p[not(span)]')
        menu = menu[day].text_content().splitlines()
    else:
        menu = []

    return menu
コード例 #17
0
ファイル: magyarqtr.py プロジェクト: Zolikon/ebedke
def get_menu(today):
    dom = get_dom(URL)
    menu_week_number = dom.xpath("/html/body//div[@class='itemBody']//h2[@class='itemTitle']//text()")
    menu_week_number =  ''.join(char for char  in ''.join(menu_week_number) if char.isnumeric())
    _, current_week_number, _ = today.date().isocalendar()

    if menu_week_number == str(current_week_number):
        week_menu = dom.xpath("/html/body//div[@class='itemBody']//div[@class='heti-menu']//text()")
        lower = lambda line: remove_accents(line).lower()
        menu = pattern_slice(week_menu, [days_lower_ascii[today.weekday()]], days_lower_ascii, modifier=lower)
    else:
        menu = []

    return menu
コード例 #18
0
ファイル: monks.py プロジェクト: Zolikon/ebedke
def get_menu(today):
    dom = get_dom(URL)
    week_date = dom.xpath(
        "/html/body//div//li//a[contains(text(), 'MENÜ')]/text()")
    from_date, to_date = re.split(r" |-", week_date.pop())[-2:]
    from_date = datetime.strptime(f"{today.year}.{from_date}", "%Y.%m.%d.")
    to_date = datetime.strptime(f"{today.year}.{to_date}", "%Y.%m.%d.")

    menu = []
    if from_date.date() <= today.date() <= to_date.date():
        rows = dom.xpath("/html/body//tr[count(td)=2]")
        for row in rows:
            if days_lower[today.weekday()] in row.text_content().lower():
                menu = row.xpath(".//td[2]//text()")
    return menu
コード例 #19
0
def get_menu(today):
    dom = get_dom(URL)
    page = dom.xpath("/html/body//div[@id='heti-men-page']//text()")
    looks_like_a_date = lambda text: text.count(".") > 2 and str(today.year
                                                                 ) in text
    date = next(filter(looks_like_a_date, page))
    date = datetime.strptime(date.split("-")[0].strip(" ."), "%Y.%m.%d")

    if date <= today < date + timedelta(days=6):
        menu = page
    else:
        menu = []

    menu = pattern_slice(menu, ["levesek"],
                         ["étlap", "function", "getElementById"])
    return menu
コード例 #20
0
def getMenu(today):
    today = today.strftime("%Y-%m-%d")
    dom = get_dom(PQS_MENU)
    column = 0
    for i, th in enumerate(dom.xpath('//table[@id="menu"]/thead//th')):
        text = ''.join(th.xpath('text()'))
        if today in text:
            column = i + 1
    texts = dom.xpath('//*[@id="menu"]//tr[th[contains(text(),"enü") '
                      'or contains(text(),"őztje") '
                      'or contains(text(),"eves")]]'
                      f'/following-sibling::tr[1]/td[{ column }]/ul//text()')
    menu = ''.join(texts)
    menu = menu.replace("Választott leves", "")
    menu = menu.replace("\t", "")
    menu = list(i for i in menu.splitlines() if i)

    return menu
コード例 #21
0
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
コード例 #22
0
ファイル: marcello.py プロジェクト: Zolikon/ebedke
def getMenu(today):
    dom = get_dom(URL)
    date = f"{today.month:02}.{today.day:02}"
    menu = dom.xpath(f"/html/body//div[.//a[contains(text(), '{date}')]]/p//text()")
    menu = [m.capitalize() for m in menu[:3]]
    return menu
コード例 #23
0
ファイル: divinporcello.py プロジェクト: Zolikon/ebedke
def getMenu(today):
    dom = get_dom(URL)
    #date = f"{months_hu_capitalized[today.month - 1]} {today.day:02}"
    menu = dom.xpath("/html/body//img[contains(@src, 'heti')]/@src")

    return menu
コード例 #24
0
ファイル: emi.py プロジェクト: Zolikon/ebedke
def getMenu(_):
    dom = get_dom(URL)
    menu = dom.xpath('/html/body//tr[@class="menutablasor"]/td[3]')
    menu = [e.text_content().strip('(, )') for e in menu]

    return menu