方法一:
step1:下载谷歌驱动程序:下载地址
step2:把“chromedriver.exe”复制到 谷歌浏览器(C:Program FilesGoogleChromeApplication)和python(C:Python27)的安装目录
step3:将谷歌浏览器目录(C:UsersHD003AppDataLocalGoogleChromeApplication)添加到path环境变量
方法二:
如果方法一不行,直接使用 executable_path="C:Program Files (x86)GoogleChromeApplicationchromedriver.exe" 赋值
1 from selenium import webdriver 2 3 driver = webdriver.Chrome(executable_path="C:Program Files (x86)GoogleChromeApplicationchromedriver.exe") 4 driver.get("http://www.baidu.com/")