有没有一种方法可以自动为 Selenium 项目下载最新的 Chrome 驱动程序?
Is there a method of automating the process of downloading the latest Chrome Driver for a Selenium project?
我目前正在自学 Python 并且我选择将我的第一个项目设为 Selenium 项目,它可以使我的网上购物自动化。
我的项目 运行 相当顺利,但我可以在不久的将来看到一些潜在的陷阱。
一旦 Chrome 更新到较新的版本,我的项目是否会因为安装了较旧的 Chrome 驱动程序而无法运行?
如果是这种情况(我假设是),是否有方法检查是否安装了正确的 Chrome 驱动程序,如果没有,请安装正确的驱动程序?
请找到以下答案:
使用以下命令安装 webdriver 管理器
pip install webdriver_manager
**Use with Chrome:**
from webdriver_manager.chrome import ChromeDriverManager
webdriver.Chrome(ChromeDriverManager().install())
有关详细信息,请在下面找到 link::
https://github.com/SergeyPirogov/webdriver_manager
webdriver-自动更新
PyPI 和 GitHub 中有一个名为 webdriver-auto-update
的包。它将检测您计算机上的驱动程序版本并自动下载最新的 chrome 驱动程序 version/release。
安装:
确保您的系统中安装了 Python。
运行 在您的终端中安装以下内容:
pip install webdriver-auto-update
例子
from selenium import webdriver
from webdriver_auto_update import check_driver
# Pass in the folder used for storing/downloading chromedriver
check_driver('folder/path/of/your/chromedriver')
driver = webdriver.Chrome()
driver.get("http://www.python.org")
引用link:
https://pypi.org/project/webdriver-auto-update/
https://github.com/competencytestlvl/webdriver_auto_update
我目前正在自学 Python 并且我选择将我的第一个项目设为 Selenium 项目,它可以使我的网上购物自动化。
我的项目 运行 相当顺利,但我可以在不久的将来看到一些潜在的陷阱。
一旦 Chrome 更新到较新的版本,我的项目是否会因为安装了较旧的 Chrome 驱动程序而无法运行?
如果是这种情况(我假设是),是否有方法检查是否安装了正确的 Chrome 驱动程序,如果没有,请安装正确的驱动程序?
请找到以下答案:
使用以下命令安装 webdriver 管理器
pip install webdriver_manager
**Use with Chrome:**
from webdriver_manager.chrome import ChromeDriverManager
webdriver.Chrome(ChromeDriverManager().install())
有关详细信息,请在下面找到 link:: https://github.com/SergeyPirogov/webdriver_manager
webdriver-自动更新
PyPI 和 GitHub 中有一个名为 webdriver-auto-update
的包。它将检测您计算机上的驱动程序版本并自动下载最新的 chrome 驱动程序 version/release。
安装:
确保您的系统中安装了 Python。 运行 在您的终端中安装以下内容:
pip install webdriver-auto-update
例子
from selenium import webdriver
from webdriver_auto_update import check_driver
# Pass in the folder used for storing/downloading chromedriver
check_driver('folder/path/of/your/chromedriver')
driver = webdriver.Chrome()
driver.get("http://www.python.org")
引用link:
https://pypi.org/project/webdriver-auto-update/ https://github.com/competencytestlvl/webdriver_auto_update