安裝 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的匹配
- 查看chrome版本
下載后,將安裝包加入到環境變量。以mac系統為例,將chromedriver移至/usr/bin目錄下即可
☁ ~ sudo mv ~/Downloads/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]:
chrome測試頁
如果能調用chrome瀏覽器,即表示安裝成功