From 8c6b672d9010a59e879206d60f9d03a1a7558c7b Mon Sep 17 00:00:00 2001 From: Johannes Rothe Date: Mon, 1 Aug 2022 22:17:31 +0200 Subject: [PATCH] Adapt to new error message thrown by the site --- scraperoog/scrape.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/scraperoog/scrape.py b/scraperoog/scrape.py index 83fa807..46fe185 100644 --- a/scraperoog/scrape.py +++ b/scraperoog/scrape.py @@ -81,7 +81,7 @@ def convert_to_datestring(day: str, month: str, year: str) -> datetime: async def request_data(index: int, client: AsyncClient) -> Optional[Entry]: response_data = await client.get(DATA_URL + str(index), timeout=20.0) - if "Fehler aufgetreten" not in response_data.text: + if "Die Darstellung ist derzeit deaktiviert" not in response_data.text: response_title = await client.get(MAIN_URL + str(index), timeout=20.0) title_soup = BeautifulSoup(response_title.text, "lxml") apartment = ( @@ -127,10 +127,12 @@ async def extract_results() -> None: file.write(result.json()) generate_csv(result) +def main() -> None: + if platform.system() == "Windows": + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + asyncio.run(extract_results()) if __name__ == "__main__": # with open("results.json", "r") as file: # result = Result(**json.load(file)) - if platform.system() == "Windows": - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) - asyncio.run(extract_results()) + main()