From 5d169ba517a6a91865e7788fc1da81f4ef1de8fe Mon Sep 17 00:00:00 2001 From: Claude Project Manager Date: Sun, 10 Aug 2025 19:03:44 +0200 Subject: [PATCH] Cookie-Consent-Seite --- database/accounts.db | Bin 356352 -> 356352 bytes database/accounts.db-journal | Bin 12824 -> 0 bytes social_networks/instagram/instagram_login.py | 88 +++++++++++++++++++ 3 files changed, 88 insertions(+) delete mode 100644 database/accounts.db-journal diff --git a/database/accounts.db b/database/accounts.db index 0cf36e0440a89488d5158c42e89ad40eb529a619..963148f18e41607c1c6a97a1a854628bedb140b2 100644 GIT binary patch delta 123 zcmZp8AlmRibb>Tv;Y1l{#=^#g)&$1Z1g6#m=A{WNAGr+;6b#L*OwFxK4Yp^0WGM>c zgo{is&|uY_J}-_XaQeG-EEe16c(CpfTv?nD`9#@xn))&$1Z1g6#m=A{WNAGr+-6$~w{Obo0H&9-NMWGMAK6t=L`J z2{$@z2ii+N0H2_rp|{@qMYt3Wz4X#2*;4Gu$}w#(?W`taOS|vAef!(rzW20oCUbnf zdb9a6JUz%{&cN5@;|_WEe@5WJC77Kux1NDNc}WB$0uljdL)dy-+nidLv< zg`!$2tyNan%C|Y4RyiQS-&6&LqviVL;f#W3$AF^i-ER=x)PNHXH zxRi!TG2%Ay4CEo_h}$MJis^k9zx(=pF2A&-{9tl);9!ctsAIcuUWI!Ym~o=v!bVfC zwRE*rTi@2z6W!{<1yyj_mbz7M>38*}y4&2^sWl&}_w|QrZNJsns)NNHz23SZ)a15{ z;W*9p)z;RIzSpYl?5g!fORev3Z>x9o&D#EUOWoLSHo=0Ch=^?=GeU+R`B-h~UxAUK zA+fj>!1O{WU6y!1S%U?pi5XMZ8;xzfRzJl)#mpxj!-h#L9FHJ&g@M)36TmTaTr3n& zXF@M_unQ|{Ft{-}p_4=@CDZ`i8R`s>5)Vi*r$^vDgpk<%WJwBQ6&G`4A&w@DzS(H% zTX*XbK^BfDzNj|!O&ykbL*G*mDCsjeSsiw>1>0IYL7&C%ujF$1N=5k*1_W})N^RTg zVCqvF_$_KXH%4)hL^{hOT8&U#jDm^09%6<^>}d79w%v&UIfXENm;yHe@M#s=1g1ER z&+Z@~lHpV0Pc;ho-*F6xE7nB%4a6vjVTvd56a|(|LYFx{O zQ4d4ObK*^6bSz?!cAMdZ)na?T6LjFLe*%@GV2mvTa%mEpk~L1Y%9PQ|L5v%ea0t;5 z1>#_s<{IK*5;vHSO}lNIk&`EP$lY_<{G&=*P7zVxD2iIozx@1cF0X0IPukd4i}z=& z6F+B#TP*JVr`u~}gU1mwL0ycONyt+hPeo#fn8-005Px!T98P8mN!UM!VHizzUW$)l zX8%{o6tGbyB@n$YF}pbY=aj)rLNNsC+Hqbk-b_gYaYZsYpM?<~K!)s+p7eS)?)!vt zqiZce=?|PbOb1R8uq~1`I2RxB|ImVeO87O}uh(R2f9#L`4rE zaN?zPOdZ=xQ4LF$9!?61Shpx12uF$gy%O@UWC8lUM;0GT(c`;Kn5IWWQd0F7*=&AK zJ1r2!0pd6a#VxrPAJ63S^Yh9#Gf@D7;LRb;v-o>E)%!X8isaf1eq%61S$H^!ICe-x*}50mw0MVoF1dqM`fK$ohz} zKB0peISFTCyVyncq;lEsPOcQ%f#Vp7W8yJJ)BowO8&Q6D2$U4jT*W3m!iQ-}+&`Mg g#1il_#e+en1F8bcKDi1XAASTMm(IU>bN|!70Mn8N 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.