使用selenium调用webdriver的时候报错。

from selenium import webdriver

browser = webdriver.Chrome()
browser.get("http://www.baidu.com")
print(browser.page_source)
browser.close()

output:

WebDriverException: Message: 'chromedriver' executable needs to be in PATH. Please see https://sites.google.com/a/chromium.org/chromedriver/home

提示chromedriver需要加入环境变量。

查找chromedriver.exe未果,遂下载。

下载地址:http://npm.taobao.org/mirrors/chromedriver/

注:chromedriver需要与chrome版本对应

排异方式:

1.将chrome.exe直接放入chrome目录下。

2.将chrome.exe所在路径加入环境变量。

版权声明:本文为locke-hu原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/locke-hu/p/9211187.html