#web-driver #geckodriver #chromedriver

webdriver-downloader

webdriver 下载库

45 个版本

0.16.0 2024 年 6 月 13 日
0.14.3 2024 年 2 月 15 日
0.14.0 2023 年 9 月 29 日
0.13.6 2023 年 7 月 26 日
0.5.1 2023 年 3 月 31 日

#509 in 网页开发

Download history • Rust 包仓库 444/week @ 2024-04-19 • Rust 包仓库 31/week @ 2024-04-26 • Rust 包仓库 2/week @ 2024-05-24 • Rust 包仓库 9/week @ 2024-05-31 • Rust 包仓库 139/week @ 2024-06-07 • Rust 包仓库 77/week @ 2024-06-14 • Rust 包仓库 2/week @ 2024-06-28 • Rust 包仓库 17/week @ 2024-07-05 • Rust 包仓库 161/week @ 2024-07-26 • Rust 包仓库 11/week @ 2024-08-02 • Rust 包仓库

172 每月下载量
用于 2 crates

MIT 许可证

66KB
1.5K SLoC

webdriver-downloader

Crates.io

webdriver 下载库。支持 chromedriver(Chrome 和 Chrome for Testing),以及 Windows、Linux 和 macOS 的 geckodriver。

用法

使用库提供的驱动下载器

use webdriver_downloader::prelude::*;

#[tokio::main]
async fn main() {
    let driver_info = ChromedriverInfo::new_default().unwrap();

    // Tries up to 5 versions of webdrivers if it is not installed.
    if !driver_info.is_installed() {
        driver_info.download_verify_install(5).await.unwrap();
    }

    // webdriver is installed.
    // Default installation path is %USERPROFILE%/bin/chromedriver.exe ($HOME/bin/chromedriver for unix family)
}

实现自定义驱动的下载器

通过实现 WebdriverUrlInfo, WebdriverInstallationInfo, WebdriverVerificationInfo,会自动为 struct CustomDriverInfo 实现 WebdriverDownloadInfo 特性。

然后你可以调用 custom_driver_info.download_verify_install(max_attempts)

运行时说明

该库对 WebdriverVerificationInfo::verify_driver 的实现使用了 fantoccini 验证已安装的驱动。由于 fantoccini 需要 tokio 作为运行时,因此你需要使用 tokio 作为运行时来使用库提供的驱动下载器。

依赖项

~19–36MB
~605K SLoC