2024-06-08 17:39:10 发布
网友
我正在尝试使用python selenium启动特定于chrome的配置文件
我试试这个代码
option.add_argument("user-data-dir=C:\\Users\\Gamer\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2")
但它是作为客人开放的
您可以尝试以下选项:
from selenium import webdriver options = webdriver.ChromeOptions() options.add_argument("user-data-dir=C:\\Users\\Gamer\\AppData\\Local\\Google\\Chrome\\User Data\\Profile 2") driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', options=options) driver.get("https://www.google.co.in")
您可以按如下方式尝试,在URL栏中选择配置文件位置类型chrome://version,并检查Profile Path
chrome://version
Profile Path
from selenium import webdriver from selenium.webdriver.chrome.options import Options options = webdriver.ChromeOptions() options.add_argument(r"user-data-dir=C:\\Users\\Gamer\\AppData\\Local\\Google\\Chrome\\User Data") options.add_argument(r' profile-directory=Profile 2') driver = webdriver.Chrome(executable_path=r'C:\path\to\chromedriver.exe', chrome_options=options) driver.get("https://www.google.co.in")
此外,尝试在多次运行主浏览器实例时关闭它,否则它可能会显示异常
您可以尝试以下选项:
您可以按如下方式尝试,在URL栏中选择配置文件位置类型
chrome://version
,并检查Profile Path
此外,尝试在多次运行主浏览器实例时关闭它,否则它可能会显示异常
相关问题 更多 >
编程相关推荐