parent
a640834a99
commit
6ba1595719
@ -1,54 +1,54 @@ |
|||||||
|
import requests |
||||||
import requests |
import json |
||||||
import json |
from bs4 import BeautifulSoup |
||||||
from bs4 import BeautifulSoup |
from datetime import date |
||||||
from datetime import date |
|
||||||
|
# Variablen |
||||||
# Variablen |
errorMsg = ('HEUTE KEIN ESSEN') |
||||||
errorMsg = ('HEUTE KEIN ESSEN') |
menuMsg = ('Du hast bei Chemnitz.Kitchen bestellt! Heute gibt es:') |
||||||
menuMsg = ('Du hast bei Chemnitz.Kitchen bestellt! Heute gibt es:') |
today = date.today() |
||||||
today = date.today() |
today_url = today.strftime("%d.%m.%Y") |
||||||
#today_url = today.strftime("%d.%m.%Y") |
#today_url = ('05.12.22') |
||||||
today_url = ('30.11.22') |
|
||||||
|
# Login URL |
||||||
# Login URL |
loginurl = ('https://chemnitz.kitchen/login/') |
||||||
loginurl = ('https://chemnitz.kitchen/login/') |
|
||||||
|
# Bestellübersicht |
||||||
# Bestellübersicht |
menu_url = f'https://chemnitz.kitchen/kunden/bestelluebersicht/?date_from={today_url}&date_to={today_url}' |
||||||
menu_url = f'https://chemnitz.kitchen/kunden/bestelluebersicht/?date_from={today_url}&date_to={today_url}' |
|
||||||
|
#Logindaten |
||||||
#Logindaten |
login = { |
||||||
payload = { |
'username': 'email', |
||||||
'username': 'email', |
'password': 'password' |
||||||
'password': 'password' |
} |
||||||
} |
|
||||||
|
# Einloggen und auf Bestellübersicht springen |
||||||
# Einloggen und auf Bestellübersicht springen |
with requests.session() as s: |
||||||
with requests.session() as s: |
s.post(loginurl, data=login) |
||||||
s.post(loginurl, data=payload) |
p = s.get(menu_url) |
||||||
p = s.get(menu_url) |
soup = BeautifulSoup(p.content, 'html.parser') |
||||||
soup = BeautifulSoup(p.content, 'html.parser') |
table = soup.find('table' ,attrs={'class':'food-order'}) |
||||||
table = soup.find('table' ,attrs={'class':'food-order'}) |
rows = table.find_all('td') |
||||||
rows = table.find_all('td') |
description = rows[2].get_text() |
||||||
description = rows[2].get_text() |
menu = rows[1].get_text() |
||||||
menu = rows[1].get_text() |
|
||||||
|
|
||||||
|
#JSON |
||||||
#JSON |
JsonDictionary = { |
||||||
JsonDictionary = { |
f'date': today_url, |
||||||
f'date': today_url, |
f'menu': menu, |
||||||
f'menu': menu, |
f'description': description } |
||||||
f'description': description } |
dictionary_string = json.dumps(JsonDictionary, ensure_ascii=False,) |
||||||
dictionary_string = json.dumps(JsonDictionary, ensure_ascii=False,) |
dataString = dictionary_string |
||||||
dataString = dictionary_string |
|
||||||
|
|
||||||
|
|
||||||
|
textout = f' {menuMsg} {description}' |
||||||
textout = f' {menuMsg} {description}' |
|
||||||
|
datei = open("ck.json", "w", encoding="utf-8") |
||||||
datei = open("ck.json", "w", encoding="utf-8") |
datei.writelines(dictionary_string) |
||||||
datei.writelines(dictionary_string) |
datei.close() |
||||||
datei.close() |
print(textout) |
||||||
print(textout) |
print(dictionary_string) |
||||||
print(dictionary_string) |
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in new issue