Selenium (Chrom 136): "Fehler beim Entschlüsseln" Fehler mit kopiertem Profil verhindernPython

Python-Programme
Anonymous
 Selenium (Chrom 136): "Fehler beim Entschlüsseln" Fehler mit kopiertem Profil verhindern

Post by Anonymous »

Ich versuche, Google Chrome 136 mit Selenium 4.25.0 in Python zu automatisieren, um auf https://aistudio.google.com zuzugreifen, indem ich mein vorhandenes, protokolliertes "Standard" -Standard-Profil "Standard" -Profil ". driver.get () wurde genannt. Neues Verzeichnis (z. B. C: \ seleniumchromeProfiles \ MyautomationProfile). C: \ seleniumchromeProfiles \ MyautomationProfile \ Standard ...).

Code: Select all

chrome_options.add_argument(f"--user-data-dir=C:\\SeleniumChromeProfiles\\MyAutomationProfile")
# And importantly, I OMITTED chrome_options.add_argument("--profile-directory=Default")
Aktuelle Situation und neues Problem:
Wenn ich das Skript mit diesem kopierten Profil-Setup ausführe:
Chrom-Starts, und es scheint die kopierten Profildaten zu erkennen (z. B. geht es zunächst zu meinem "neuen Tab". /> Die Chromkonsole (und die Ausgabe meines Skripts) ist jetzt jedoch mit Fehlern wie: < /p>
überflutet[
::MMDD/HHMMSS.XXX:ERROR:components\os_crypt\sync\os_crypt_win.cc:105] Failed to decrypt: 鞈?銝迤蝣箝?(0xD)
< /code>
(Der Kauderstext könnte variieren, aber der os_crypt_win.cc:105] ist nicht konsistent. Wenn ich dann versuche, zu https://aistudio.google.com zu navigieren, muss ich mich erneut anmelden. Dies besiegt mein Ziel, eine bereits vorhandene, bereits authentifizierte Sitzung ohne manuelles Re-Login für jeden Automatisierungslauf zu verwenden. /> Chrombrowserversion: 136.0.7103.93 (offizieller Build) (64-Bit) < /p>
Chromedriver-Version: 136.0.7103.xx (für Win64) < /p>
vereinfachtes Code für den Start mit kopiertem Start. Chrome_Profile_User_Data_dir zeigt auf das übergeordnete Verzeichnis Ihres neuen kopierten Profils, z. B. C: \ seleniumchromeProfiles \ myautomationProfile, und dass das Argument der Profile-Verzeichnis in Chrome_Options weggelassen wird.) < /P>
import time
import os
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium.common.exceptions import WebDriverException

# --- Configuration ---
CHROME_DRIVER_PATH = r'C:\Users\stat\Downloads\chromedriver-win64\chromedriver-win64\chromedriver.exe' # My actual path
# Path to the PARENT of the COPIED "Default" profile
CHROME_COPIED_PROFILE_PARENT_DIR = r'C:\SeleniumChromeProfiles\MyAutomationProfile' # Example - I created this and xcopied ...\User Data\Default into ...\MyAutomationProfile\Default

TARGET_URL = "https://aistudio.google.com/prompts/new_chat"

def setup_driver():
print(f"Driver Path: {CHROME_DRIVER_PATH}")
print(f"User Data Dir (for copied profile): {CHROME_COPIED_PROFILE_PARENT_DIR}")

if not os.path.exists(CHROME_DRIVER_PATH):
print(f"FATAL: ChromeDriver not found: '{CHROME_DRIVER_PATH}'.")
return None
if not os.path.isdir(CHROME_COPIED_PROFILE_PARENT_DIR):
print(f"FATAL: Copied profile parent dir not found: '{CHROME_COPIED_PROFILE_PARENT_DIR}'.")
return None
if not os.path.isdir(os.path.join(CHROME_COPIED_PROFILE_PARENT_DIR, "Default")):
print(f"FATAL: 'Default' subfolder NOT found inside '{CHROME_COPIED_PROFILE_PARENT_DIR}'. Profile copy likely incorrect.")
return None

chrome_options = Options()
# Key part for copied profile method: point to the new parent directory
chrome_options.add_argument(f"--user-data-dir={CHROME_COPIED_PROFILE_PARENT_DIR}")
# DO NOT use --profile-directory, Chrome will look for "Default" inside the user-data-dir

chrome_options.add_experimental_option("excludeSwitches", ["enable-automation", "load-extension"])
chrome_options.add_experimental_option('useAutomationExtension', False)
prefs = {
"credentials_enable_service": False,
"profile.password_manager_enabled": False
}
chrome_options.add_experimental_option("prefs", prefs)
chrome_options.add_argument("--disable-extensions")
chrome_options.add_argument("--start-maximized")

try:
service = Service(executable_path=CHROME_DRIVER_PATH)
driver = webdriver.Chrome(service=service, options=chrome_options)
print("WebDriver initialized with copied profile settings.")
return driver
except WebDriverException as e:
print(f"FATAL WebDriverException during setup: {e}")
return None
except Exception as e_setup:
print(f"Unexpected FATAL error during setup: {e_setup}")
return None

def main():
print("IMPORTANT: Ensure ALL Google Chrome instances are FULLY CLOSED before running this script.")
input("Press Enter to confirm and continue...")

driver = setup_driver()
if not driver:
print("Driver setup failed. Exiting.")
return

try:
print(f"Browser launched. Waiting a moment...")
print(f"Initial URL: '{driver.current_url}', Initial Title: '{driver.title}'")
time.sleep(4)

print(f"Attempting to navigate to: {TARGET_URL}")
driver.get(TARGET_URL)
print(f"Called driver.get(). Waiting for navigation...")
time.sleep(7) # Allow time for navigation / login redirect

current_url_after_get = driver.current_url
print(f"After 7s wait - Current URL: '{current_url_after_get}', Title: '{driver.title}'")

if "accounts.google.com" in current_url_after_get:
print("RESULT: Navigated to a Google login/account page. Copied session was not active/decrypted.")
elif TARGET_URL in current_url_after_get:
print("RESULT: Potentially successful navigation to AI Studio (but still check if login is required on page).")
else:
print(f"RESULT: Navigation FAILED. Browser is on '{current_url_after_get}'.")

except Exception as e:
print(f"An error occurred: {e}")
finally:
print("Script finished or errored.")
input("Browser will remain open. Press Enter to close...")
if driver:
driver.quit()

if __name__ == "__main__":
if not os.path.exists(CHROME_COPIED_PROFILE_PARENT_DIR) or \
not os.path.isdir(os.path.join(CHROME_COPIED_PROFILE_PARENT_DIR, "Default")):
print("ERROR: The copied profile directory setup seems incorrect.")
print(f"Ensure '{CHROME_COPIED_PROFILE_PARENT_DIR}' exists AND contains a 'Default' subfolder with your copied profile data.")
else:
main()
< /code>
Meine Frage zum Stapelüberlauf: < /p>
Der Fehler: Komponenten \ os_crypt \ sync \ os_crypt_win.cc: 105] versäumt es, zu entschlüsseln, dass die kopierten Profile, die von der SELT -SELT -SELTED -SELTIERT -SELT -SELT -SELT -SELT, nicht auf Google gestartet sind. Dies führt dazu, dass sich erneut anmelden muss und den Zweck der Verwendung des kopierten Profils zur Aufrechterhaltung einer vorhandenen Sitzung besiegt wird. (Möglicherweise spezifische Chromflags oder eine Interaktion mit Windows -DPAPI, die Selen beeinflussen kann?)
Wenn die direkte Entschlüsselung eines kopierten Profils im Allgemeinen für Google -Konten aufgrund der Sicherheit im Allgemeinen nicht möglich ist. /> Machen Sie die anhaltenden "nicht entschlüsselt" Fehler, auch wenn anschließend eine Anmeldeseite behandelt wird, wobei anschließend eine zugrunde liegende Instabilität oder Unzuverlässigkeit für die Browser -Sitzung angezeigt wird, die Selen kontrolliert?>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post