Skip to main content

项目描述

这是基于 webdriver-manager 的项目,本项目使用 淘宝 npm 镜像 来加速下载浏览器驱动,仅适用于 Chrome、Firefox 和 Opera。

依赖

安装

pip install cnpm-webdriver-manager

用法

使用 Chrome

# selenium 3
from selenium import webdriver
from cnpm_webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(ChromeDriverManager().install())
# selenium 4
from selenium import webdriver
from selenium.webdriver.chrome.service import Service as ChromeService
from cnpm_webdriver_manager.chrome import ChromeDriverManager

driver = webdriver.Chrome(service=ChromeService(ChromeDriverManager().install()))

使用 Firefox

# selenium 3
from selenium import webdriver
from cnpm_webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(executable_path=GeckoDriverManager().install())
# selenium 4
from selenium import webdriver
from selenium.webdriver.firefox.service import Service as FirefoxService
from cnpm_webdriver_manager.firefox import GeckoDriverManager

driver = webdriver.Firefox(service=FirefoxService(GeckoDriverManager().install()))

使用 Opera

# selenium 3

from selenium import webdriver
from selenium.webdriver.chrome import service
from cnpm_webdriver_manager.opera import OperaDriverManager

webdriver_service = service.Service(OperaDriverManager().install())
webdriver_service.start()

driver = webdriver.Remote(webdriver_service.service_url, webdriver.DesiredCapabilities.OPERA)
# selenium 4
from selenium import webdriver
from selenium.webdriver.chrome import service
from cnpm_webdriver_manager.opera import OperaDriverManager

webdriver_service = service.Service(OperaDriverManager().install())
webdriver_service.start()

options = webdriver.ChromeOptions()
options.add_experimental_option('w3c', True)

driver = webdriver.Remote(webdriver_service.service_url, options=options)

如果 Opera 浏览器安装在 Windows 系统中,且位置处于 C:/Program Files 或 C:/Program Files (x86) 之外;同时,在所有类 Unix 系统变体以及 Mac 系统中,其安装位置处于 /usr/bin/opera 之外,那么请使用以下代码,

options = webdriver.ChromeOptions()
options.binary_location = "opera.exe 的路径"
driver = webdriver.Remote(webdriver_service.service_url, options=options)

Metadata

Release files for cnpm-webdriver-manager 4.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for cnpm-webdriver-manager 4.0.3
File Size Uploaded Provenance
cnpm_webdriver_manager-4.0.3.tar.gz 12.1 MB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for cnpm-webdriver-manager 4.0.3
File Interpreter ABI Platform
cnpm_webdriver_manager-4.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 12.1 MB

Release files / cnpm_webdriver_manager-4.0.3.tar.gz

Download URL cnpm_webdriver_manager-4.0.3.tar.gz
Size 12.1 MB
Tags Source
SHA-256 checksum
How to use checksums
8e2f1ef10a2d701af0c3f87a7afeb628697196f29a3935817ba779f5575b434d
BLAKE2b-256 checksum
How to use checksums
a26c7d81e9985146f9aa498e9bd4b7c8725e94ae9218f517796c08c518532996
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Release files / cnpm_webdriver_manager-4.0.3-py3-none-any.whl

Download URL cnpm_webdriver_manager-4.0.3-py3-none-any.whl
Size 15.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
f68b54b133966d0b78bfc1a51e778f2389c0aae73c0e878b6e7ffad6d5db4ba4
BLAKE2b-256 checksum
How to use checksums
ab662f4dfa65b72ebd74d9c0752de2e24b226cf8525a347ba105a42647f0b61a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.7.9

Security for cnpm-webdriver-manager 4.0.3

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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page