Coder Social home page Coder Social logo

mensa_aachen's Introduction

mensa_aachen.py

Fetch and parse Studierendenwerk Aachen's canteen menu

This Python module allows to fetch and parse the current week's menu of the university canteens in Aachen from the Studierendenwerk Aachen's website. The module is build on top of the popular libraries Requests and Beautifulsoup4.

Typical usage:

import mensa_aachen
dishes = mensa_aachen.get_dishes(mensa_aachen.Canteens.MENSA_ACADEMICA)

Which will yield a result in a form like

{
    datetime.date(2020, 1, 20):
        Menu(
            main_dishes=[
                Dish(
                    menu_category='Tellergericht',
                    main_component=DishComponent(
                        title='Bulgureintopf',
                        flags=[]),
                    aux_components=[
                        DishComponent(
                            title='Kichererbsen, Gemüse',
                            flags=[<Flags.ANTIOXIDATIONSMITTEL: '3'>, <Flags.GLUTEN: 'A'>, <Flags.WEIZEN: 'A1'>])
                        ],
                    meat=[<MeatType.VEGAN: 4>, <MeatType.VEGETARIAN: 3>],
                    price=Decimal('1.80'),
                    nutritional_values=NutritionalValues(caloric_val=None, fat=None, carbs=None, protein=None)),
                Dish(
                    menu_category='Vegetarisch',
                    main_component=DishComponent(
                        title='Spätzlepfanne',
                        flags=[]),
                    aux_components=[
                        DishComponent(
                            title='Röstzwiebeln',
                            flags=[<Flags.GLUTEN: 'A'>, <Flags.SELLERIE: 'B'>, <Flags.EIER: 'D'>, <Flags.MILCH: 'H'>, <Flags.WEIZEN: 'A1'>, <Flags.DINKEL: 'A5'>]),
                        DishComponent(
                            title='Käsesauce',
                            flags=[<Flags.FARBSTOFF: '1'>, <Flags.MILCH: 'H'>])], meat=[<MeatType.VEGETARIAN: 3>],
                    price=Decimal('2.10'),
                    nutritional_values=NutritionalValues(caloric_val=3857.0, fat=44.6, carbs=97.1, protein=32.0)),
                ...],
            side_dishes=[
                Dish(
                    menu_category='Hauptbeilagen',
                    main_component=DishComponent(
                        title='Nudelreis',
                        flags=[<Flags.GLUTEN: 'A'>, <Flags.WEIZEN: 'A1'>]),
                    aux_components=[],
                    meat=[],
                    price=None,
                    nutritional_values=NutritionalValues(caloric_val=1859.0, fat=11.0, carbs=72.0, protein=12.0)),
                Dish(
                    menu_category='Nebenbeilage',
                    main_component=DishComponent(
                        title='Rosenkohl',
                        flags=[]),
                    aux_components=[],
                    meat=[],
                    price=None,
                    nutritional_values=NutritionalValues(caloric_val=502.0, fat=8.0, carbs=6.6, protein=5.5)),
                ...]
            ),
    datetime.date(2020, 1, 21):
        Menu(...),
    ...
}

The types Menu, Dish, DishComponent, and NutritionalValues, used in the result, are NamedTuples. Flags and MeatType are Enums. The value of each member of Flags corresponds to the abbreviation used in the menu. For more information about the fields and available enum options, please take a look at the module's source code.

Installing

The module can be installed from its git repository via pip: pip install git+https://github.com/mhthies/mensa_aachen.git@master

License

This neat library is published under the terms of the MIT license.

mensa_aachen's People

Contributors

mhthies avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

tituskirch

mensa_aachen's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.