Cookie-Consent-Seite
Dieser Commit ist enthalten in:
Binäre Datei nicht angezeigt.
Binäre Datei nicht angezeigt.
@ -140,6 +140,9 @@ class InstagramLogin:
|
||||
"stage": "login_check"
|
||||
}
|
||||
|
||||
# 9. Post-Login Cookie Consent behandeln (falls vorhanden)
|
||||
self._handle_post_login_consent()
|
||||
|
||||
# Login erfolgreich
|
||||
logger.info(f"Instagram-Login für {username_or_email} erfolgreich")
|
||||
self.automation._send_status_update("Login erfolgreich!")
|
||||
@ -1550,6 +1553,91 @@ class InstagramLogin:
|
||||
except Exception as e:
|
||||
logger.error(f"Fehler beim Entfernen von Instagram Click-Interceptors: {e}")
|
||||
|
||||
def _handle_post_login_consent(self) -> bool:
|
||||
"""
|
||||
Behandelt die Cookie-Consent-Seite, die nach erfolgreichem Login erscheinen kann.
|
||||
Diese Seite hat die URL: instagram.com/consent/?flow=user_cookie_choice_v2
|
||||
|
||||
Nutzt den existierenden CookieConsentHandler für konsistente Behandlung.
|
||||
|
||||
Returns:
|
||||
bool: True wenn Consent behandelt wurde, False wenn keine Consent-Seite vorhanden
|
||||
"""
|
||||
try:
|
||||
# Prüfe ob wir auf der Consent-Seite sind
|
||||
current_url = self.automation.browser.page.url
|
||||
logger.info(f"Prüfe auf Post-Login Cookie Consent - URL: {current_url}")
|
||||
|
||||
# Prüfe verschiedene Consent-URL-Patterns
|
||||
consent_patterns = [
|
||||
"/consent/",
|
||||
"flow=user_cookie_choice",
|
||||
"cookie_choice_v2",
|
||||
"/privacy/consent/"
|
||||
]
|
||||
|
||||
is_consent_page = any(pattern in current_url for pattern in consent_patterns)
|
||||
|
||||
if not is_consent_page:
|
||||
# Zusätzlich prüfen ob Consent-Elemente auf der Seite sind
|
||||
try:
|
||||
page_content = self.automation.browser.page.content().lower()
|
||||
consent_indicators = [
|
||||
"die verwendung von cookies",
|
||||
"cookie consent",
|
||||
"optionale cookies",
|
||||
"erforderliche cookies",
|
||||
"cookie-einstellungen",
|
||||
"allow optional cookies",
|
||||
"reject optional cookies"
|
||||
]
|
||||
|
||||
has_consent_content = any(indicator in page_content for indicator in consent_indicators)
|
||||
|
||||
if not has_consent_content:
|
||||
logger.debug("Keine Cookie-Consent-Seite erkannt")
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
logger.debug(f"Fehler bei Consent-Content-Prüfung: {e}")
|
||||
return False
|
||||
|
||||
logger.info("Post-Login Cookie Consent Seite erkannt")
|
||||
self.automation._send_status_update("Behandle Cookie-Einstellungen")
|
||||
self.automation._send_log_update("Lehne optionale Cookies ab...")
|
||||
|
||||
# Warte kurz, damit die Seite vollständig geladen ist
|
||||
self.automation.human_behavior.random_delay(1.5, 2.5)
|
||||
|
||||
# Screenshot für Debugging
|
||||
self.automation._take_screenshot("cookie_consent_page")
|
||||
|
||||
# Nutze den existierenden CookieConsentHandler für konsistente Behandlung
|
||||
from browser.cookie_consent_handler import CookieConsentHandler
|
||||
|
||||
# Der Handler nutzt bereits robuste Click-Strategien und LocalStorage-Manipulation
|
||||
consent_handled = CookieConsentHandler.handle_instagram_consent(self.automation.browser.page)
|
||||
|
||||
if consent_handled:
|
||||
logger.info("Cookie-Consent erfolgreich behandelt - Optionale Cookies abgelehnt")
|
||||
self.automation._send_log_update("Cookie-Einstellungen gespeichert")
|
||||
|
||||
# Warte auf Navigation nach Consent
|
||||
self.automation.human_behavior.random_delay(2.0, 3.0)
|
||||
|
||||
# Screenshot nach Consent
|
||||
self.automation._take_screenshot("after_cookie_consent")
|
||||
|
||||
return True
|
||||
else:
|
||||
logger.warning("Cookie-Consent Seite erkannt, aber konnte nicht behandelt werden")
|
||||
# Versuche trotzdem fortzufahren
|
||||
return False
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Fehler bei Post-Login Cookie Consent Behandlung: {e}")
|
||||
return False
|
||||
|
||||
def _has_cookie_preferences(self) -> bool:
|
||||
"""
|
||||
Prüft ob Cookie-Präferenzen bereits in der Session vorhanden sind.
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren