erste gute version
This commit is contained in:
68
speiseplan.py
Normal file
68
speiseplan.py
Normal file
@@ -0,0 +1,68 @@
|
||||
#!/usr/bin/python
|
||||
import urllib.request
|
||||
from bs4 import BeautifulSoup
|
||||
import datetime
|
||||
|
||||
def suppe(url):
|
||||
page = urllib.request.urlopen(url).read()
|
||||
return BeautifulSoup(page, "html.parser")
|
||||
|
||||
# bistros
|
||||
def sbar():
|
||||
return suppe("https://sbar-greifswald.de").find('table').text
|
||||
|
||||
def grangusto():
|
||||
return f'<img width=100% src={suppe("https://gran-gusto.de/wochenmenue-kiga/").find("img", class_="img-with-animation")["src"]}>'
|
||||
|
||||
def sternwarte():
|
||||
return suppe("https://www.pommerscher-diakonieverein.de/produkte-dienstleistungen/gastronomie-hotellerie/bio-bistro-alte-sternwarte/").find("div", class_="ce-week-menu").text
|
||||
|
||||
def lichtblick():
|
||||
return suppe("https://www.pommerscher-diakonieverein.de/produkte-dienstleistungen/gastronomie-hotellerie/lichtblick-cafe-und-restaurant").find("div", class_="ce-week-menu").text
|
||||
|
||||
def cafekarsten():
|
||||
return suppe("https://cafekarsten.de/").find("div", class_="lg:grid-cols-2").text
|
||||
|
||||
def tierpark():
|
||||
seite = suppe("https://www.tierpark-greifswald.de/tierpark-cafe.html").find("div", id="tierpark-cafe")
|
||||
return list(seite.children)[9].text
|
||||
|
||||
def ipp():
|
||||
return suppe("https://www.ipp-kantine.de/").find("div", class_="row").text
|
||||
|
||||
def malanders():
|
||||
return suppe("https://mal-anders-greifswald.dipago.de/").find("div", id="module_303538").text
|
||||
|
||||
bistros = {
|
||||
"S-Sbar": {"f": sbar, "url": "https://sbar-greifswald.de"},
|
||||
"Gran Gusto": {"f": grangusto, "url": "https://sbar-greifswald.de"},
|
||||
"Bio-Bistro Alte Sternwarte": {"f": sternwarte, "url": "https://sbar-greifswald.de"},
|
||||
"Bistro Lichtblick": {"f": lichtblick, "url": "https://sbar-greifswald.de"},
|
||||
"Cafe Karsten": {"f": cafekarsten, "url": "https://sbar-greifswald.de"},
|
||||
"Tierparkcafe": {"f": tierpark, "url": ""},
|
||||
"IPP-Kantine": {"f": ipp, "url": "https://ipp-kantine.de"},
|
||||
"Mal Anders": {"f": malanders, "url": "https://sbar-greifswald.de"},
|
||||
}
|
||||
|
||||
with open("index.html", "w") as f:
|
||||
f.write("""<html>
|
||||
<head>
|
||||
</head>
|
||||
<body>
|
||||
""")
|
||||
|
||||
f.write(f"zuletzt aktualisiert: {datetime.datetime.now().strftime('%d.%m.%Y %H:%M')}<br>")
|
||||
|
||||
|
||||
for b in bistros:
|
||||
f.write(f"<h2>{b}</h2>\n")
|
||||
try:
|
||||
f.write(bistros[b]['f']())
|
||||
f.write("\n")
|
||||
except Exception as e:
|
||||
print(f"Speiseplan: Aktualisierung von {b} fehlgeschlagen mit {e}")
|
||||
f.write("fehlgeschlagen<br>\n")
|
||||
f.write("<br><br>\n")
|
||||
|
||||
|
||||
f.write("""</body></html>\n""")
|
||||
Reference in New Issue
Block a user