fix handler errors

This commit is contained in:
Aron Petau 2026-01-02 12:25:27 +01:00
parent e6b0f844fe
commit c68ee12d4e
3 changed files with 70 additions and 20 deletions

View file

@ -19,11 +19,18 @@ class GewobagHandler(BaseHandler):
logger.info("[GEWOBAG] Page loaded")
await asyncio.sleep(2)
# Detect 404 by status or page title
# Detect 404 by status, page title, or "nicht gefunden" message
status = response.status if response else None
page_title = await page.title()
if status == 404 or (page_title and "404" in page_title):
logger.warning(f"[GEWOBAG] Listing is down (404): {listing['link']}")
page_content = await page.content()
is_404 = (
status == 404 or
(page_title and "404" in page_title) or
(page_title and "nicht gefunden" in page_title.lower()) or
("Mietangebot nicht gefunden" in page_content)
)
if is_404:
logger.warning(f"[GEWOBAG] Listing is down (404 or unavailable): {listing['link']}")
result["success"] = False
result["message"] = "Listing is no longer available (404). Application impossible. Will not retry."
result["deactivated"] = True