安裝selenium
selenium可以直接可以用pip安裝。
pip install selenium
安裝chromedriver
下載
chromedriver的版本一定要與Chrome的版本一致,不然就不起作用。
有兩個下載地址:
1、http://chromedriver.storage.googleapis.com/index.html
2、https://npm.taobao.org/mirrors/chromedriver/
當然,你首先需要查看你的Chrome版本,在瀏覽器中輸入chrome://version/
例如我的版本是72.0.3626,所以下載
配置
解壓壓縮包,找到chromedriver.exe復制到chrome的安裝目錄(其實也可以隨便放一個文件夾)。復制chromedriver.exe文件的路徑並加入到電腦的環境變量中去。具體的:
進入環境變量編輯界面,添加到用戶變量即可,雙擊PATH,將你的文件位置(C:\Program Files (x86)\Google\Chrome\Application\)添加到后面。
完成后在cmd下輸入chromedriver驗證是否安裝成功:




