wbm error

This commit is contained in:
Aron Petau 2026-01-02 11:32:49 +01:00
parent 357dd32caa
commit 001b62c1c8

View file

@ -47,39 +47,45 @@ class WBMHandler(BaseHandler):
result["message"] = "Listing is no longer available (404 detected on WBM)." result["message"] = "Listing is no longer available (404 detected on WBM)."
logger.warning(f"[WBM] Permanent fail: {err}") logger.warning(f"[WBM] Permanent fail: {err}")
await page.close() await page.close()
await page.close()
return result return result
# Find and follow the 'Details' link to the detail page # Check if we're already on the detail page (URL contains '/details/')
logger.info("[WBM] Looking for 'Details' link to open detail page...") current_url = page.url
detail_link = None if '/details/' not in current_url:
detail_selectors = [ # Find and follow the 'Details' link to the detail page
'a.btn.sign[title="Details"]', logger.info("[WBM] Looking for 'Details' link to open detail page...")
'a.immo-button-cta[title="Details"]', detail_link = None
'a[title="Details"]', detail_selectors = [
] 'a.btn.sign[title="Details"]',
for sel in detail_selectors: 'a.immo-button-cta[title="Details"]',
links = await page.query_selector_all(sel) 'a[title="Details"]',
logger.info(f"[WBM] Selector '{sel}' found {len(links)} matches for details link") ]
for link in links: for sel in detail_selectors:
try: links = await page.query_selector_all(sel)
if await link.is_visible(): logger.info(f"[WBM] Selector '{sel}' found {len(links)} matches for details link")
detail_link = link for link in links:
break try:
except Exception as e: if await link.is_visible():
logger.warning(f"[WBM] Error checking details link visibility: {e}") detail_link = link
if detail_link: break
break except Exception as e:
logger.warning(f"[WBM] Error checking details link visibility: {e}")
if detail_link:
break
if not detail_link: if not detail_link:
result["message"] = "No details link found on overview page." result["message"] = "No details link found on overview page."
await page.close() await page.close()
return result return result
# Click the details link and wait for navigation # Click the details link and wait for navigation
logger.info("[WBM] Clicking details link to open detail page...") logger.info("[WBM] Clicking details link to open detail page...")
await detail_link.click() await detail_link.click()
await page.wait_for_load_state("networkidle") await page.wait_for_load_state("networkidle")
await asyncio.sleep(2) await asyncio.sleep(2)
else:
logger.info("[WBM] Already on detail page, skipping details link search")
# Save HTML of detail page for debugging # Save HTML of detail page for debugging
try: try: