SeleniumBasic操作运行中的Chrome浏览器

今天用免费云服务器,三丰云,做操作浏览器自动化的VB程序。

如何自动化已经打开的浏览器?

http://chromedriver.storage.googleapis.com/index.html

首先寻找驱动,最新的驱动只支持到浏览器114,我在网上下载的浏览器是94.0.4606.81(64位版本),selenium驱动下载的是94.0.4606.61/chromedriver_win32.zip,位数不一致竟然也可以。

浏览器和驱动都解压或安装到I:\install\Chrome94\ 文件夹下。

命令行中输入以下命令:

"I:\install\Chrome94\Google94.exe" --remote-debugging-port=9999 --user-data-dir="C:\Windows\Temp"

输入以上命令,打开了浏览器。

bash 复制代码
Private WD As SeleniumBasic.IWebDriver
'"I:\install\Chrome94\Google94.exe" --remote-debugging-port=9999 --user-data-dir="C:\Windows\Temp"
Sub Baidu()
    'On Error GoTo Err1
    Dim Service As SeleniumBasic.ChromeDriverService
    Dim Options As SeleniumBasic.ChromeOptions
    Set WD = New SeleniumBasic.IWebDriver
    Set Service = New SeleniumBasic.ChromeDriverService
    With Service
        .CreateDefaultService driverPath:="I:\install\Chrome94\"
        .HideCommandPromptWindow = True
    End With
    Set Options = New SeleniumBasic.ChromeOptions
    With Options
        .BinaryLocation = "I:\install\Chrome94\Google94.exe"
        .DebuggerAddress = "127.0.0.1:9999"
    End With
    WD.New_ChromeDriver Service:=Service, Options:=Options
    WD.url = "https://www.baidu.com"
End Sub
Private Sub Form_Load()
Baidu
End Sub

运行以上代码,在打开的浏览器,打开了百度。

相关推荐
我要升天!1 天前
Linux中《环境变量》详细介绍
linux·运维·chrome
muzidigbig3 天前
Chrome(Google) 浏览器安装Vue2、Vue3 Devtools插件方法
chrome·vue.js devtools·google vue插件方法
pitt19974 天前
Chrome 开发环境快速屏蔽 CORS 跨域限制!
chrome·跨域·cors·解决跨越技巧
skywalk81634 天前
自动化浏览器的测试框架playwright 支持多种浏览器Chromium、Firefox 和 WebKit
前端·chrome·自动化·测试·playwright
亿牛云爬虫专家5 天前
Headless Chrome 优化:减少内存占用与提速技巧
前端·chrome·内存·爬虫代理·代理ip·headless·大规模数据采集
小白学大数据6 天前
Python + Chrome 爬虫:如何抓取 AJAX 动态加载数据?
开发语言·chrome·爬虫·python
头发尚存的猿小二6 天前
Linux--环境变量
前端·javascript·chrome
Ustinian_3106 天前
【HTML】KaTeX 常用公式字符
前端·chrome·html
守城小轩7 天前
使用 Go Colly 更改用户代理以进行网络抓取
chrome·网络爬虫·浏览器开发·浏览器爬虫
2401_897930067 天前
docker 启动ElasticSearch
linux·前端·chrome