試了把chromedriver.exe放到chrome安裝文件下,python安裝文件下,然后把路徑配到path里,均無用。
最后是修改函數調用得以解決:
from selenium import webdriver
browser = webdriver.Chrome(executable_path = 'C:\Program Files (x86)\Google\Chrome\Application\chromedriver_X64.exe')
browser.get('http://www.baidu.com')
executable_path指定了chromedriver所在的路徑,程序運行時就會到該路徑下啟動chrome瀏覽器