复制一个chrome快捷方式,修改启动选项:
chrome.exe --remote-debugging-port=9527 --user-data-dir=“D:\selenium-chrome”
from selenium import webdriver
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
options = Options()
options.add_experimental_option("debuggerAddress", "127.0.0.1:9527")
chromedriver_path = r"X:\chromedriver.exe"
service = Service(chromedriver_path)
driver = webdriver.Chrome(service=service,options=options)