📖 简介
WebDriverManager CN 是一个基于 阿里云镜像源
和 华为云镜像源 的 WebDriver 自动下载管理工具,是 webdriver_manager 的国内镜像版本。
✨ 特性
- 🚀 自动下载 - 自动匹配浏览器版本并下载对应的 WebDriver
- 🇨🇳 国内加速 - 支持阿里云、华为云镜像源,下载速度快
- 💾 智能缓存 - 自动缓存已下载的驱动,避免重复下载
- 🧹 自动清理 - 可配置自动清理过期的驱动文件
- 🔄 灵活切换 - 支持多镜像源切换,保证可用性
- 🎯 跨平台 - 支持 Windows、MacOS、Linux
📦 安装
使用 pip 安装
pip install webdrivermanager_cn
升级到最新版本
pip install -U webdrivermanager_cn
🚀 快速开始
ChromeDriver 使用示例
方式一:使用阿里云镜像源(推荐)
from webdrivermanager_cn import ChromeDriverManagerAliMirror
driver_path = ChromeDriverManagerAliMirror().install()
方式二:使用华为云镜像源
from webdrivermanager_cn import ChromeDriverManagerHuaweiMirror
driver_path = ChromeDriverManagerHuaweiMirror().install()
方式三:手动切换镜像源
from webdrivermanager_cn import ChromeDriverManager
driver = ChromeDriverManager()
driver.set_ali_mirror() # 切换为阿里源(默认)
# driver.set_huawei_mirror() # 切换为华为源
driver_path = driver.install()
Geckodriver (Firefox) 使用示例
使用阿里云镜像源
from webdrivermanager_cn import GeckodriverManagerAliMirror
driver_path = GeckodriverManagerAliMirror().install()
使用华为云镜像源
from webdrivermanager_cn import GeckodriverManagerHuaweiMirror
driver_path = GeckodriverManagerHuaweiMirror().install()
手动切换镜像源
from webdrivermanager_cn import GeckodriverManager
driver = GeckodriverManager()
driver.set_ali_mirror() # 切换为阿里源(默认)
# driver.set_huawei_mirror() # 切换为华为源
driver_path = driver.install()
🛠️ 配置选项
日志配置
import os
import logging
# 开启日志功能(默认关闭)
os.environ['WDM_LOG'] = 'true'
# 设置日志级别(默认为 INFO)
os.environ['WDM_LOG_LEVEL'] = str(logging.INFO)
自定义 Logger
from webdrivermanager_cn.core.log_manager import set_logger
import logging
# 使用自定义 logger
my_logger = logging.getLogger('my_custom_logger')
set_logger(my_logger)
缓存管理
import os
# 设置缓存清理时间(单位:天,默认为 5 天)
# 会自动删除 5 天前下载的旧版本 WebDriver
os.environ['WDM_CACHE_TIME'] = '5'
📊 支持的浏览器
| 浏览器 | Windows | MacOS | Linux |
|---|---|---|---|
| Chrome | ✅ | ✅ | ✅ |
| Firefox | ✅ | ✅ | ✅ |
💡 如需支持其他浏览器,欢迎提交 Issue
🤝 贡献
欢迎贡献代码、提出建议或报告问题!
- Fork 本仓库
- 创建您的特性分支 (
git checkout -b feature/AmazingFeature) - 提交您的更改 (
git commit -m 'Add some AmazingFeature') - 推送到分支 (
git push origin feature/AmazingFeature) - 提交 Pull Request
如果您发现了新的国内镜像源,欢迎提交 Issue 或 PR!
📄 许可证
本项目基于 Apache-2.0 协议开源。
⚠️ 免责声明
本项目仅供自动化测试工具使用,请勿用于非法用途。对于任何使用者的行为,本项目及作者不承担任何责任。
本项目依赖以下第三方服务,如有相关问题,会积极推进解决,但无法保证完全解决:
📮 联系方式
- 作者: 御风
- Email: eternallyyf@163.com
- 项目地址: Gitee
如果在使用过程中遇到任何问题,欢迎提交 Issue!
如果这个项目对您有帮助,请给一个 ⭐️ Star!
Metadata
Release files for webdrivermanager-cn 2.5.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| webdrivermanager_cn-2.5.0-py3-none-any.whl | Python 3 | none | any | Details |
Release files / webdrivermanager_cn-2.5.0-py3-none-any.whl
| Download URL | webdrivermanager_cn-2.5.0-py3-none-any.whl |
|---|---|
| Size | 26.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
45c4170b7170d41ba2377782cec1309ffaaa1b74c6b50836a8d85f8439317d63
|
|
BLAKE2b-256 checksum How to use checksums |
a31d0b9c11c80bb742fbcf55432983d6d3973e75ee7ce9356aa09b44717d5517
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.0.0 CPython/3.9.0
|
Security for webdrivermanager-cn 2.5.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.