complete mensa async
This commit is contained in:
@ -1,4 +1,3 @@
|
|||||||
import requests
|
|
||||||
import urllib.parse
|
import urllib.parse
|
||||||
import time
|
import time
|
||||||
from bs4 import BeautifulSoup
|
from bs4 import BeautifulSoup
|
||||||
@ -59,7 +58,7 @@ async def getKurs(token: int, cookie: str):
|
|||||||
headers=headers)
|
headers=headers)
|
||||||
html = BeautifulSoup(response.text, 'lxml')
|
html = BeautifulSoup(response.text, 'lxml')
|
||||||
link = html.body.find('a', attrs={'id': "Popup_details0001"})['href']
|
link = html.body.find('a', attrs={'id': "Popup_details0001"})['href']
|
||||||
response = requests.request("GET", url + link[21:], headers=headers, data={})
|
response = await s.get(url=f"{url}{link[21:]}", headers=headers)
|
||||||
html = BeautifulSoup(response.text, 'lxml')
|
html = BeautifulSoup(response.text, 'lxml')
|
||||||
content = html.body.find('td', attrs={'class': 'level02'}).text
|
content = html.body.find('td', attrs={'class': 'level02'}).text
|
||||||
start = content.find(" ") + 4
|
start = content.find(" ") + 4
|
||||||
|
|||||||
@ -1,8 +1,8 @@
|
|||||||
import json
|
import json
|
||||||
from init import db, Meals#, scheduler
|
from init import db, Meals#, scheduler
|
||||||
import datetime
|
import datetime
|
||||||
import requests
|
|
||||||
import time
|
import time
|
||||||
|
import httpx
|
||||||
|
|
||||||
nomeal = 'Essen nicht (mehr) verfügbar'
|
nomeal = 'Essen nicht (mehr) verfügbar'
|
||||||
|
|
||||||
@ -26,7 +26,7 @@ def getMeals(day: datetime):
|
|||||||
return getMealsFromAPI(day, dbentry=True)
|
return getMealsFromAPI(day, dbentry=True)
|
||||||
|
|
||||||
|
|
||||||
def getMealsFromAPI(day: str, dbentry: bool = False):
|
async def getMealsFromAPI(day: str, dbentry: bool = False):
|
||||||
"""
|
"""
|
||||||
Fragt die Mensa-API nach den Mahlzeiten eines Tages ab. \n
|
Fragt die Mensa-API nach den Mahlzeiten eines Tages ab. \n
|
||||||
Wenn dbentry: Schreibt die Ergebnisse in die Datenbank. \n
|
Wenn dbentry: Schreibt die Ergebnisse in die Datenbank. \n
|
||||||
@ -35,8 +35,8 @@ def getMealsFromAPI(day: str, dbentry: bool = False):
|
|||||||
:param dbentry:
|
:param dbentry:
|
||||||
:return [Name1, Name2, ...]:
|
:return [Name1, Name2, ...]:
|
||||||
"""
|
"""
|
||||||
url = "https://dh-api.paulmartin.cloud/plans/" + day + "?canteens=erzberger"
|
async with httpx.AsyncClient() as s:
|
||||||
response = requests.request("GET", url)
|
response = await s.get(url=f"https://dh-api.paulmartin.cloud/plans/{day}?canteens=erzberger")
|
||||||
response = response.content
|
response = response.content
|
||||||
jres = json.loads(response.decode("utf-8"))
|
jres = json.loads(response.decode("utf-8"))
|
||||||
essen = []
|
essen = []
|
||||||
|
|||||||
Reference in New Issue
Block a user