加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Python > 正文

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

发布时间:2020-12-16 22:39:06 所属栏目:Python 来源:网络整理
导读:我收到此错误:“WebDriverException:消息:chromedriver可执行文件需要在PATH中.” 我能够解决它的唯一方法是手动添加chromedriver的一个位置,如下所示: driver = webdriver.Chrome("/Users/anncolvin/.rvm/bin/chromedriver") Chrome启动后,我收到此错误

我收到此错误:“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)

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读