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 网页开发
172 每月下载量
用于 2 crates
66KB
1.5K SLoC
webdriver-downloader
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