介绍
浏览器的更新和driver文件的版本异常,经常是影响代码稳定性的一个原因,而每次driver文件的更新也是比较繁杂的工作,此次的safe-driver意在帮助维护driver的稳定性
作用
safe-driver导入后,可替换selenium的webdriver,使用方式和方法同selenium的webdriver 当启动浏览器driver文件出错时,程序将自动下载并更新浏览器驱动,并重新返回driver,提高代码的稳定性
导入
from SafeDriver.drivers import driver
from SafeDriver.drivers import option
使用
此操作同selenium的webdriver.Chrome()
driver = driver()
driver.get("https://www.baidu.com")
放入options参数
首先确定导入option配置参数 使用同selenium的ChromeOptions,可直接添加,添加后,无需再次写入到driver中
from SafeDriver.drivers import option
option.add_argument('--headless')
路径和系统配置
路径和系统保存在option中,配置需要导入option
from SafeDriver.drivers import option
option.pypath = 'xxx' # python的根目录路径
option.os_ = 'xxx' # 当前使用的操作系统
option.chromedriver_path = 'xxx' # 设置chromedriver保存路径,只写到文件夹
注意事项:
1、option.os_:参数不赋值,则视为自动查找当前操作系统 2、option.pypath:参数不赋值,则视为自动查到python路径(目前自动查找操作系统仅支持windows系统,linux和mac用户请手动配置option.pypath属性) 3、option.chromedriver_path:参数不赋值,则选择option.pypath作为保存路径
目前仅支持chrome浏览器,暂未更新其他浏览器
使用问题快查
在mac和linux上,SafeDriver不好使
SafeDriver自动查找的路径是python的路径,这个查找,在linux和mac上面并不一定能正常进行,linux和mac的用户,最好是手动配置好option.os_和option.pypath
如果更好保持稳定性?
建议代码中,指定driver的保存路径,此时的option.pypath则需要是你保存driver的路径
mac用户不能移动文件
这属于mac系统的限制,某些路径需要进行授权才能访问和显示,所以可以将driver文件放在可直接访问的目录,在代码中设置好driver路径,并将这个路径赋值给option.pypath
Metadata
Release files for SafeDriver 1.3.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| SafeDriver-1.3.1.tar.gz | 7.3 kB | Without provenance | Details for SafeDriver-1.3.1.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| SafeDriver-1.3.1-py3-none-any.whl | Python 3 | none | any | Details for SafeDriver-1.3.1-py3-none-any.whl |
Total release size: 14.9 kB
Release files / SafeDriver-1.3.1.tar.gz
| Download URL | SafeDriver-1.3.1.tar.gz |
|---|---|
| Size | 7.3 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
26959be8d75773c5450cc0ff02f2a599040a620a7ac832fa74e47770b2acc916
|
|
BLAKE2b-256 checksum How to use checksums |
494e61627f2d6a271c68f67573a09ea7351e7ac85872d6d5232cd5b73aead26e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.2
|
Release files / SafeDriver-1.3.1-py3-none-any.whl
| Download URL | SafeDriver-1.3.1-py3-none-any.whl |
|---|---|
| Size | 7.6 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
bfb4cff83e631224dce7f97009fe31306119e5942b2c630c8fc5590309be11da
|
|
BLAKE2b-256 checksum How to use checksums |
31a0234a045f7e0827e92d7d4e527d26b2cccfa3cedd5b912c60036e499018a6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.0 CPython/3.9.2
|
Security for SafeDriver 1.3.1
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.