方法一:
step1:下載谷歌驅動程序:下載地址
step2:把“chromedriver.exe”復制到 谷歌瀏覽器(C:\Program Files\Google\Chrome\Application)和python(C:\Python27)的安裝目錄
step3:將谷歌瀏覽器目錄(C:\Users\HD003\AppData\Local\Google\Chrome\Application)添加到path環境變量
方法二:
如果方法一不行,直接使用 executable_path="C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe" 賦值
1 from selenium import webdriver 2 3 driver = webdriver.Chrome(executable_path="C:\Program Files (x86)\Google\Chrome\Application\chromedriver.exe") 4 driver.get("http://www.baidu.com/")