当前位置:首页 > Python笔记 > 正文内容

Python里面用SELENIUM接管已经打开的火狐浏览器的方式代码

import subprocess
import time
from selenium import webdriver
from selenium.webdriver.firefox.service import Service
from selenium.webdriver.firefox.options import Options
from selenium import webdriver
# 命令
command = '"C:/Program Files/Mozilla Firefox/firefox.exe" -marionette -start-debugger-server 2828'
# 执行命令
subprocess.Popen(command, shell=True)
time.sleep(2)
driver = webdriver.Firefox(executable_path = "C:/Program Files/Mozilla Firefox/geckodriver.exe", service_args = ['--marionette-port', '2828', '--connect-existing'] )
time.sleep(2)
driver.get('https://www.baidu.com/')
time.sleep(2)
driver.get('https://www.xiaohongshu.com/')


微信截图_20240414232959.png

发表评论

(必填)
(必填)
(选填)

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

最新留言

标签列表