Skip to content

Instantly share code, notes, and snippets.

@mperlet
Created March 10, 2017 21:29
Show Gist options
  • Save mperlet/5080a2c7c15343b5ee4f4876906a33cd to your computer and use it in GitHub Desktop.
Save mperlet/5080a2c7c15343b5ee4f4876906a33cd to your computer and use it in GitHub Desktop.
Aktuelle Speisepläne der Mensen in Rostock
""" Modul for the mensa in rostock"""
import datetime
from pyquery import PyQuery as pq
class CanteenHRO(object):
"""Class for parsing the canteen menus in rostock"""
# Project Metadata
__version__ = u'0.1.0'
__author__ = u'Mathias Perlet'
__author_email__ = u'[email protected]'
__description__ = u'Parses the menus of the canteens in Rostock.'
def get_response(self):
"""
Returns a list with canteen menus
"""
today = datetime.date.today().strftime("%Y-%m-%d")
doc = pq("https://www.studentenwerk-rostock.de/de/mensen/speiseplaene/{}.html".format(today))
response = []
for mensa in doc("#begin_content > div.col_xl > dl.color_style"):
query = pq(mensa)
response.append({
"name": query("dt > p").text(),
"menu": [_.text for _ in query("dd > div > div.canteen_table_wrapper > table > tr > td:nth-child(1) > b")]})
return response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment