fix: split profile card wait into container + email; add diagnostic output
This commit is contained in:
parent
a7835c3057
commit
2caffab1fa
@ -61,19 +61,40 @@ class Resolver:
|
||||
return None
|
||||
|
||||
try:
|
||||
# Wait for profile card, then extract email from mailto link
|
||||
self._page.wait_for_selector(_PROFILE_EMAIL_SELECTOR, timeout=5000)
|
||||
email_el = self._page.query_selector(_PROFILE_EMAIL_SELECTOR)
|
||||
# Step 1: wait for the profile card container to appear
|
||||
self._page.wait_for_selector(".lpc_ip_root_class", timeout=5000)
|
||||
except Exception:
|
||||
print(f" Profilkarte für '{display_name}' öffnet sich nicht (Klick hat nicht gewirkt).")
|
||||
self._page.keyboard.press("Escape")
|
||||
return None
|
||||
|
||||
try:
|
||||
# Step 2: extract email — try mailto link first, then plain text fallbacks
|
||||
email = None
|
||||
if email_el:
|
||||
email = email_el.inner_text().strip()
|
||||
if not email or "@" not in email:
|
||||
href = email_el.get_attribute("href") or ""
|
||||
email = href.replace("mailto:", "").strip() or None
|
||||
for selector in [
|
||||
".lpc_ip_root_class a[href*='mailto:']",
|
||||
".lpc_ip_root_class [class*='email']",
|
||||
".lpc_ip_root_class [data-tid*='email']",
|
||||
]:
|
||||
el = self._page.query_selector(selector)
|
||||
if el:
|
||||
text = el.inner_text().strip()
|
||||
href = el.get_attribute("href") or ""
|
||||
email = (href.replace("mailto:", "").strip()
|
||||
or (text if "@" in text else None))
|
||||
if email:
|
||||
break
|
||||
|
||||
if not email:
|
||||
# Diagnose: show card text content
|
||||
card = self._page.query_selector(".lpc_ip_root_class")
|
||||
card_text = card.inner_text().strip()[:200] if card else "(leer)"
|
||||
print(f" Karte geöffnet, E-Mail nicht gefunden. Karteninhalt: {card_text!r}")
|
||||
|
||||
self._page.keyboard.press("Escape")
|
||||
time.sleep(0.5)
|
||||
return email
|
||||
except Exception as e:
|
||||
print(f" Profilkarte für '{display_name}' nicht ladbar: {e}")
|
||||
print(f" Fehler beim Lesen der Profilkarte: {e}")
|
||||
self._page.keyboard.press("Escape")
|
||||
return None
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user