selenium报错Message: unknown error: cannot find Chrome binary

原因是selenium找不到浏览器(注意,这里是浏览器的路径,不是webdriver的路径),所以需要指定一下浏览器的路径,具体操作如下:

 

from selenium import webdriver

url = 'https://www.baidu.com'
options = webdriver.ChromeOptions()

 

# 这里是关键
options.binary_location = "D:\Google\Chrome\Application\chrome.exe"


driver = webdriver.Chrome(executable_path="D:\chromedriver_win\chromedriver.exe", options=options)
driver.get(url)

posted @ 2021-11-09 21:23  乔儿  阅读(2441)  评论(0编辑  收藏  举报