fix: Google Flights Nach-Feld via active_element Fallback

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
Cursor 2026-02-25 21:22:10 +07:00
parent 27f78c9a40
commit aca9c7f431

View file

@ -247,15 +247,35 @@ def scrape_google_flights(von, nach, tage=30, aufenthalt_tage=60,
'input[placeholder*="Von"]',
'input[aria-label*="Where from"]',
], von_name, "Von")
sb.sleep(1.5) # Nach Von-Auswahl fokussiert Google das Nach-Feld automatisch
# ── 3. Nach-Feld befüllen ───────────────────────────────────────────
_gf_fill_field(sb, [
# Erst expliziten Selektor versuchen, dann aktivem Element direkt tippen
from selenium.webdriver.common.keys import Keys as _Keys
from selenium.webdriver.common.action_chains import ActionChains as _AC
nach_gesetzt = _gf_fill_field(sb, [
'input[aria-label*="Wohin"]',
'input[aria-label*="Zielort"]',
'input[aria-label*="Ziel"]',
'input[placeholder*="Wohin"]',
'input[aria-label*="Where to"]',
'input[aria-label*="Destination"]',
], nach_name, "Nach")
if not nach_gesetzt:
# Fallback: aktives Element (Nach-Feld sollte jetzt fokussiert sein)
try:
active = sb.driver.switch_to.active_element
active.send_keys(nach_name)
sb.sleep(2)
active.send_keys(_Keys.ARROW_DOWN)
sb.sleep(0.5)
active.send_keys(_Keys.RETURN)
sb.sleep(1)
print(f"[GF] Nach via active_element: {nach_name}")
except Exception as e:
print(f"[GF] Nach active_element Fehler: {e}")
# ── 4. Suchen-Button klicken ────────────────────────────────────────
from selenium.webdriver.common.keys import Keys
gesucht = False