新換了電腦,從新配置下環境,備忘下html
=============================================================== python
1.python2環境安裝web
https://www.python.org/downloads/release/python-2714/chrome
下載64位Windows x86-64 MSI installer雙擊安裝api
配置環境變量,將對應的目錄添加pathgoogle
C:\Python27和C:\Python27\Scripts(pip的路徑)url
驗證cmd輸入python 3d
2.selenium安裝,使用pip安裝htm
C:\Windows\system32>pip install seleniumblog
這樣下載的是selenium3 「 Successfully installed selenium-3.141.0 urllib3-1.24.1」
驗證
python環境import selenium
3.chromedriver安裝
http://chromedriver.storage.googleapis.com/index.html,惋惜沒有我要的64位driver啊
版本 70.0.3538.110(正式版本) (64 位)
下載個win32試試,
解壓後將exe文件拷貝到chrome的目錄下C:\......l\Google\Chrome\Application
將C:\......l\Google\Chrome\Application這個目錄添加到環境變量path中
4驗證環境
>>> from selenium import webdriver
>>> dr=webdriver.Chrome()
DevTools listening on ws://127.0.0.1:62805/devtools/browser/7c83c3a9-7fe7-43be-9fdc-02c824a59290
>>> dr.get('https://www.baidu.com/')
>>>
成功
=====================================================
python3環境安裝
1.安裝python3
下載雙擊安裝目錄選擇d:/python3,配置環境變量,將D:\python3\Scripts添加道path中
2.使用pip安裝seleni
cd D:\python3\Scripts
python3 -m pip install selenium
3.chromedriver
由於上個python2已經安裝配置了driver,因此掠過這一步
4.驗證是否成功