webdriver.Chrome()提示’chromedriver’ executable needs to be in PATH.
解决办法:
1、下载和你当前的chrome对应版本的chromedriver;
chrome和Chromedriver对应版本链接:
https://blog.csdn.net/huilan_same/article/details/51896672
2、解压chromedriver生成chromedriver.exe文件;
3、把chromedriver.exe文件放在和chrome.exe应用程序的同一个目录下
4、把chrome应用程序的目录配置在环境变量里面;
5、代码:
from selenium import webdriver
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
chrome_options = Options()
chrome_options.add_argument(‘–headless’)
chromedriver = “C:\ProgramFiles\Google\Chrome\Application\chromedriver.exe”
driver = webdriver.Chrome(chromedriver,chrome_options=chrome_options)
driver.get(“http://www.baidu.com“)
这样就运行成功啦~~
附录stackoverflow地址:
https://stackoverflow.com/questions/22130109/cant-use-chrome-driver-for-selenium