Created
March 10, 2017 21:29
-
-
Save mperlet/5080a2c7c15343b5ee4f4876906a33cd to your computer and use it in GitHub Desktop.
Aktuelle Speisepläne der Mensen in Rostock
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" 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