尝试在python 3.8中使用硒打开我的个人资料上的Chrome

问题描述

每次chrome打开时,它都不在我的个人资料中,因此我并没有将所有保存的密码都作为扩展名使用。 我搜索了一段时间,这就是结果。 Chrome仍会打开,但不在我的个人资料中。 谁能告诉我我做错了什么?

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.common.keys import Keys
from selenium.webdriver.common.by import By
from selenium.webdriver.support.ui import webdriverwait
from selenium.webdriver.support import expected_conditions as EC
import time

options = webdriver.ChromeOptions()
options.add_argument(r"user-data-dir=C:\Users\Utente\AppData\Local\Google\Chrome\User Data\Profile 1")

PATH = "C:\Program Files (x86)\chromedriver.exe"
driver = webdriver.Chrome(PATH)

driver.get("https://www.nike.com/it/launch?s=upcoming")

解决方法

我认为您需要在路径后加逗号,然后定义chrome_options,如下所示:

driver = webdriver.Chrome(executable_path='C:\\path\\to\\chromedriver',chrome_options=options)