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
|
return None
|
||||||
|
|
||||||
try:
|
try:
|
||||||
# Wait for profile card, then extract email from mailto link
|
# Step 1: wait for the profile card container to appear
|
||||||
self._page.wait_for_selector(_PROFILE_EMAIL_SELECTOR, timeout=5000)
|
self._page.wait_for_selector(".lpc_ip_root_class", timeout=5000)
|
||||||
email_el = self._page.query_selector(_PROFILE_EMAIL_SELECTOR)
|
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
|
email = None
|
||||||
if email_el:
|
for selector in [
|
||||||
email = email_el.inner_text().strip()
|
".lpc_ip_root_class a[href*='mailto:']",
|
||||||
if not email or "@" not in email:
|
".lpc_ip_root_class [class*='email']",
|
||||||
href = email_el.get_attribute("href") or ""
|
".lpc_ip_root_class [data-tid*='email']",
|
||||||
email = href.replace("mailto:", "").strip() or None
|
]:
|
||||||
|
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")
|
self._page.keyboard.press("Escape")
|
||||||
time.sleep(0.5)
|
time.sleep(0.5)
|
||||||
return email
|
return email
|
||||||
except Exception as e:
|
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")
|
self._page.keyboard.press("Escape")
|
||||||
return None
|
return None
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user