fix degewo
This commit is contained in:
parent
4ea437e3e6
commit
0f2f842e04
3 changed files with 39 additions and 0 deletions
|
|
@ -147,6 +147,18 @@ class ApplicationHandler:
|
||||||
for listing in listings:
|
for listing in listings:
|
||||||
if self.has_applied(listing["id"]):
|
if self.has_applied(listing["id"]):
|
||||||
logger.debug(f"Skip (applied): {listing['address']}")
|
logger.debug(f"Skip (applied): {listing['address']}")
|
||||||
|
# Add to results so notify_new_listings can handle it
|
||||||
|
results[listing["id"]] = {
|
||||||
|
"listing_id": listing["id"],
|
||||||
|
"company": self._detect_company(listing.get("link", "")),
|
||||||
|
"link": listing.get("link", ""),
|
||||||
|
"timestamp": listing.get("timestamp", ""),
|
||||||
|
"success": True,
|
||||||
|
"message": "Already applied successfully",
|
||||||
|
"address": listing.get("address", ""),
|
||||||
|
"rooms": listing.get("rooms", ""),
|
||||||
|
"price": listing.get("price", ""),
|
||||||
|
}
|
||||||
continue
|
continue
|
||||||
result = await self.apply(listing)
|
result = await self.apply(listing)
|
||||||
results[listing["id"]] = result
|
results[listing["id"]] = result
|
||||||
|
|
|
||||||
|
|
@ -52,6 +52,25 @@ class DegewoHandler(BaseHandler):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.debug(f"[DEGEWO] Cookie banner dismiss failed: {e}")
|
logger.debug(f"[DEGEWO] Cookie banner dismiss failed: {e}")
|
||||||
|
|
||||||
|
# Save debug HTML and screenshot before checking button
|
||||||
|
try:
|
||||||
|
html_content = await page.content()
|
||||||
|
html_path = DATA_DIR / f"degewo_page_{listing['id']}.html"
|
||||||
|
with open(html_path, 'w', encoding='utf-8') as f:
|
||||||
|
f.write(html_content)
|
||||||
|
logger.info(f"[DEGEWO] Saved page HTML to {html_path}")
|
||||||
|
|
||||||
|
# Check if listing is no longer available
|
||||||
|
if "nicht mehr verfügbar" in html_content or "Objekt nicht mehr verfügbar" in html_content:
|
||||||
|
logger.warning(f"[DEGEWO] Listing no longer available")
|
||||||
|
result["success"] = False
|
||||||
|
result["message"] = "Listing no longer available"
|
||||||
|
result["deactivated"] = True
|
||||||
|
await page.close()
|
||||||
|
return result
|
||||||
|
except Exception as e:
|
||||||
|
logger.warning(f"[DEGEWO] Could not save HTML: {e}")
|
||||||
|
|
||||||
logger.info("[DEGEWO] Looking for kontaktieren button...")
|
logger.info("[DEGEWO] Looking for kontaktieren button...")
|
||||||
apply_btn = await page.query_selector('a:has-text("kontaktieren"), button:has-text("kontaktieren"), a:has-text("Kontaktieren"), button:has-text("Kontaktieren")')
|
apply_btn = await page.query_selector('a:has-text("kontaktieren"), button:has-text("kontaktieren"), a:has-text("Kontaktieren"), button:has-text("Kontaktieren")')
|
||||||
if apply_btn and await apply_btn.is_visible():
|
if apply_btn and await apply_btn.is_visible():
|
||||||
|
|
|
||||||
|
|
@ -72,6 +72,14 @@ class GewobagHandler(BaseHandler):
|
||||||
html_content = await iframe_page.content()
|
html_content = await iframe_page.content()
|
||||||
with open(DATA_DIR / f"gewobag_wohnungshelden_{listing['id']}.html", "w", encoding="utf-8") as f:
|
with open(DATA_DIR / f"gewobag_wohnungshelden_{listing['id']}.html", "w", encoding="utf-8") as f:
|
||||||
f.write(html_content)
|
f.write(html_content)
|
||||||
|
|
||||||
|
# Check for Wohnungshelden error messages
|
||||||
|
if "Fehler beim Laden" in html_content or "Beim Laden der Gesuchsdaten ist ein Fehler aufgetreten" in html_content:
|
||||||
|
logger.warning("[GEWOBAG] Wohnungshelden iframe shows error - may be transient, will retry")
|
||||||
|
result["success"] = False
|
||||||
|
result["message"] = "Wohnungshelden application form error - will retry later"
|
||||||
|
await iframe_page.close()
|
||||||
|
return result
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning(f"[GEWOBAG] Could not save HTML: {e}")
|
logger.warning(f"[GEWOBAG] Could not save HTML: {e}")
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue