-
Notifications
You must be signed in to change notification settings - Fork 0
/
mensa.py
25 lines (20 loc) · 1.04 KB
/
mensa.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
import requests
from bs4 import BeautifulSoup as bs
from datetime import date
URL = "https://www.imensa.de/freiburg/mensa-rempartstrasse/{}.html"
def printMeals(days):
print("\n" + "-" * 50)
print("Speiseplan für Mensa Flugplatz:\n")
for i in range(days):
day = ["montag", "dienstag", "mittwoch", "donnerstag", "freitag", "samstag", "sonntag"][(date.today().weekday() + i) % 7]
r = requests.get(URL.format(day))
soup = bs(r.content, 'html.parser')
meals = soup.find_all("p", class_ = "aw-meal-description")
print(["Montag", "Dienstag", "Mittwoch", "Donnerstag", "Freitag", "Samstag", "Sonntag"][(date.today().weekday() + i) % 7] + (" (heute):" if i == 0 else ":"))
if len(meals) == 0: print(" Heute keine Essensausgabe")
for j, meal in enumerate(meals):
if (meal.text != "Heute keine Essensausgabe"): print(" Essen " + str(j + 1) + ":")
print(" " + meal.get_text(separator="\n "))
print("-" * 50, "\n", sep="")
if __name__ == "__main__":
printMeals(3)