Selenium接管已打开的浏览器

启动谷歌浏览器远程调试

chrome.exe --remote-debugging-port=9222 --user-data-dir="某个存在的文件夹地址"

新建python文件

from selenium import webdriver
from selenium.webdriver.chrome.options import Options
 
chrome_options = Options()
chrome_options.add_experimental_option("debuggerAddress", "127.0.0.1:9222") # 端口即远程调试定义的端口
chrome_driver = "C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe" # webdriver路径
driver = webdriver.Chrome(chrome_driver, chrome_options=chrome_options)
print(driver.title)
posted @ 2022-04-15 13:47  Jruing  阅读(343)  评论(0编辑  收藏  举报