예제 #1
0
파일: opus.py 프로젝트: wafle/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
예제 #2
0
파일: input.py 프로젝트: wafle/ebedke
def get_menu(today):
    dom = get_dom(URL)
    menus = dom.xpath(f'/html/body//div[@class="_serviceContainer"]')
    menu = menus[-1].xpath(".//p/text()")
    menu = list(skip_empty_lines(line for line in menu if "menü" not in line.lower()))

    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
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
예제 #5
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
예제 #6
0
def getMenu(today):
    day = today.weekday()
    dom = get_dom(URL)
    menu = dom.xpath(
        '//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
예제 #7
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
예제 #8
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
예제 #9
0
파일: joasszony.py 프로젝트: wafle/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
예제 #10
0
파일: dezso.py 프로젝트: wafle/ebedke
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
예제 #11
0
def getMenu(today):
    try:
        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"]')
        menu = '<br>'.join(menu[0].xpath("./p/text()"))
    except:
        menu = ''

    return {'name': 'Manga', 'url': URL, 'menu': menu}
예제 #12
0
파일: manga.py 프로젝트: wafle/ebedke
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
예제 #13
0
파일: jegkert.py 프로젝트: wafle/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
예제 #14
0
def getMenu(today):
    day = today.weekday()
    menu = ''
    try:
        if day < 5:
            dom = get_dom(URL)
            menu = dom.xpath(
                '//section[@id="hetimenu"]//div[contains(@class, "text_box")]')
            menu = '<br>'.join(menu[day].xpath("p/text()"))
    except:
        pass

    return {'name': 'Intenzo', 'url': URL, 'menu': menu}
예제 #15
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
예제 #16
0
파일: veranda.py 프로젝트: wafle/ebedke
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
예제 #17
0
def getMenu(today):
    day = today.weekday() + 3
    try:
        dom = get_dom(URL)
        tds = dom.xpath(f'(//div[@id="main-content"]//table)[1]//tr[position() > 0 and position() < 5]/td[{ day }]')
        menu = "<br>".join(td.text_content().strip() for td in tds)
    except:
        menu = '-'

    return {
        'name': 'Veranda',
        'url': URL,
        'menu': menu
    }
예제 #18
0
def getMenu(today):
    day = today.weekday()
    try:
        dom = get_dom(URL)
        menu = dom.xpath('//div[@class="sppb-menu-text"]')
        menu = '<br>'.join(menu[day].xpath("text()"))
    except:
        menu = ''

    return {
        'name': 'Dezső bá',
        'url': URL,
        'menu': menu
    }
예제 #19
0
def getMenu(today):
    menu = ''
    try:
        dom = get_dom(URL)
        locale.setlocale(locale.LC_TIME, "hu_HU.UTF-8")
        date = today.strftime("%Y.%b.%d.").lower()
        menu = dom.xpath(
            f"//div[contains(@class, 'dailymenudish') and contains(preceding-sibling::div, '{ date }')]//text()"
        )
        menu = "<br>".join(dish.strip() for dish in menu)
    except:
        pass

    return {'name': 'Opus', 'url': URL, 'menu': menu}
예제 #20
0
def getMenu(today):
    day = today.weekday()
    menu = ''
    try:
        dom = get_dom(URL)
        weekly_menu = dom.xpath('//div[@class="content-right"]//p[not(span)]')
        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) and day < 5:
            menu = weekly_menu[day].text_content().replace('\n', '<br>')
    except:
        pass

    return {'name': 'Muzikum', 'url': URL, 'menu': menu}
예제 #21
0
def getMenu(today):
    day = today.weekday()
    try:
        dom = get_dom(URL)
        weeklymenu = dom.xpath('//*[@id="tabs-0"]/div[7]/div/p[5]//text()')
        weeklymenu = [
            item.strip() for item in weeklymenu if not item.isspace()
        ]
        add_separator = lambda s: "||" + s if ':' in s and not 'Hétfő' in s else s
        menu = ' '.join([add_separator(i)
                         for i in weeklymenu]).split('||')[day]
    except:
        menu = ''

    return {'name': 'Burger King', 'url': URL, 'menu': menu}
예제 #22
0
def getMenu(today):
    day = today.weekday()
    try:
        dom = get_dom(URL)
        days = dom.xpath('//div[@class="fck"]//h3')
        for i, dayname in enumerate([h3.text_content() for h3 in days]):
            if days_lower[day] in str.lower(dayname):
                select = i + 1
        menu = dom.xpath(
            f'//div[@class="fck"]//h3[{ select }]/'
            'following-sibling::p[position() >= 1 and position() < 3]//text()')
        menu = [m.strip() for m in menu if m.strip()]
        menu = '<br>'.join(menu)
    except:
        menu = ''

    return {'name': 'Gólvonal', 'url': URL, 'menu': menu}
예제 #23
0
def getMenu(today):
    day = today.weekday() + 1
    menu = ''
    try:
        dom = get_dom(URL)
        weekly_menu = dom.xpath('//section[@id="heti-menu"]//p')
        date = weekly_menu[0].text_content().strip()[0:10]
        this_week = lambda date: datetime.strptime(date, '%Y.%m.%d').date(
        ) > today.date() - timedelta(days=6)
        if this_week(date) and today.weekday() < 5:
            menu = weekly_menu[day].text_content()
            menu = menu.replace('1.', '<br>1.')
            menu = menu.replace('2.', '<br>2.')
            menu = menu + '<br>' + weekly_menu[6].text_content()
    except:
        pass

    return {'name': 'Bridges', 'url': URL, 'menu': menu}
예제 #24
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
예제 #25
0
def getMenu(today):
    today = today.strftime("%Y-%m-%d")
    try:
        dom = get_dom(PQS_MENU)
        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 = '<br>'.join((i for i in menu.split('\n') if i))
    except:
        menu = ''

    return {
        'name': 'PQS Skypark',
        'url': PQS_MENU,
        'menu': menu
    }
예제 #26
0
파일: emi.py 프로젝트: wafle/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