python+seleium 控制已打开的谷歌浏览器
1.谷歌浏览器目标位置 添加端口: --remote-debugging-port=9222

2.启动谷歌浏览器driver
#!/bin/env python #-*- coding:utf-8 -*- from selenium import webdriver import pyperclip import time import random import numpy as np from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.common.keys import Keys from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.debugger_address="127.0.0.1:9222" chrome_driver = "C:\Python36\chromedriver.exe"#driver路径 driver = webdriver.Chrome(chrome_driver,chrome_options=chrome_options) print(driver.title)
3.如果报错找不到端口,检查driver版本是否与浏览器版本一直
3.1检查任务管理器进程,需结束所有chrome进程后重进
浙公网安备 33010602011771号