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