我还可以在Python中使用ChromeOptions指定chromedriver的路径吗?

我收到此错误:“WebDriverException:消息:’chromedriver’可执行文件需要在PATH中.”
我能够解决它的唯一方法是手动添加chromedriver的一个位置,如下所示:

driver = webdriver.Chrome("/Users/anncolvin/.rvm/bin/chromedriver")

Chrome启动后,我收到此错误:“您正在使用不受支持的命令行标记:–ignore-certifcate-errors.稳定性和安全性将受到影响.”

我想尝试使用以下代码解决这个新错误,但我不知道如何将它与手动指定chromedriver的位置结合起来?

options = webdriver.ChromeOptions()
options.add_experimental_option("excludeSwitches",["ignore-
certificate-errors"])
browser = webdriver.Chrome(chrome_options=options)
browser.get("http://google.com/")
最佳答案
您所要做的就是在调用Chrome webdriver时将webdriver位置指定为参数:

chrome_path = r"/Users/anncolvin/.rvm/bin/chromedriver"
browser = webdriver.Chrome(chrome_path,chrome_options=options)

相关文章

功能概要:(目前已实现功能)公共展示部分:1.网站首页展示...
大体上把Python中的数据类型分为如下几类: Number(数字) ...
开发之前第一步,就是构造整个的项目结构。这就好比作一幅画...
源码编译方式安装Apache首先下载Apache源码压缩包,地址为ht...
前面说完了此项目的创建及数据模型设计的过程。如果未看过,...
python中常用的写爬虫的库有urllib2、requests,对于大多数比...