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