轉載地址:https://www.jianshu.com/p/39716ea15d99?utm_source=oschina-app
安裝 selenium
☁ ~ pip3 install selenium
☁ ~ pip3 list selenium
Package Version
---------- -------
pip 18.0
selenium 3.14.0
setuptools 40.2.0
urllib3 1.23
wheel 0.31.1
安裝 ChromeDriver
到官網查看最新版本
查看最新版本與chrome的匹配

ChromeDriver 2.41
查看chrome版本

chrome版本
根據自己的操作系統下載相應安裝包
可以選擇到淘寶鏡像下載
下載后,將安裝包加入到環境變量。以mac系統為例,將chromedriver移至/usr/bin目錄下即可
驗證安裝
☁ ~ chromedriver
Starting ChromeDriver 2.41.578706 (5f725d1b4f0a4acbf5259df887244095596231db) on port 9515
Only local connections are allowed.
測試能否調用chrome
☁ ~ ipython
Python 3.7.0 (default, Aug 22 2018, 15:22:33)
Type 'copyright', 'credits' or 'license' for more information IPython 6.5.0 -- An enhanced Interactive Python. Type '?' for help. In [1]: from selenium import webdriver In [2]: browser = webdriver.Chrome() In [3]: