selenium - 如何将 chromedriver 添加到我的 github 存储库
问题描述
基本上我想学习如何将我的 chromedriver 添加到我的 github 存储库中,以便人们可以在他们的应用程序上运行我的 python 脚本。
我已经下载了 chromedriver for linux 并通过本地路径执行它。
我看到人们将 chromedriver_installer 添加到他们的 requirements.txt 中,但用户必须手动更改脚本以添加安装 chromedriver 的路径。有没有办法自动做到这一点?
那么将它添加到我的项目并使其能够在每台机器上运行的最佳方法是什么?
解决方案
我喜欢使用chromedriver-autoinstaller。这非常简单,只需使用 pip 安装,您就可以像这样在代码中使用它,而无需实际安装/推送到您的仓库中的 chromedriver。
from selenium import webdriver
import chromedriver_autoinstaller
chromedriver_autoinstaller.install()
#Chrome options
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument("--disable-infobars")
chrome_options.add_argument('--disable-dev-shm-usage')
#Run chrome
driver = webdriver.Chrome(options=chrome_options)
# do the code for your test
推荐阅读
- python - 加快 statsmodels.nonparametric.kernel_regression.KernelReg 初始化的任何方式
- r - R:ggplot自定义变换轴标签以减少零
- java - JDBC BigDecimal - 精度问题
- .net-core - 在 Visual Studio 2019 中搜索拥有程序集的 NuGet 包
- rust - 返回 Box<[Box<[JsValue]>]> 不起作用,因为 IntoWasmAbi 未实现
- python - 将 .zip 存档中的大文件写入 Pandas 数据框
- hugo - Hugo 无法将 page.PagesGroup 类型转换为 Pages
- javascript - 使用 MongoDB 在 Express 中填充相关下拉框
- bit-manipulation - 是否有标准,如何以大端方式打包非字节对齐的位?
- java - E/RecyclerView:没有附加适配器;跳过布局。AsyncTask 中的问题