一、下載Firefox瀏覽器或Google瀏覽器
下載渠道有很多,直接下載最新版的就可以了。
二、下載驅動
Firefox驅動
地址:https://github.com/mozilla/geckodriver/releases
Firefox對應版本驅動:
https://selenium-release.storage.googleapis.com/index.html
或Google驅動
Google對應版本驅動:-----需要用谷歌驅動的可以參照
谷歌驅動下載地址:
http://npm.taobao.org/mirrors/chromedriver/
http://chromedriver.storage.googleapis.com/index.html
【Selenium】Chromedriver版本(更新至v2.43)與Chrome版本(更新至70)映射關系
Chromedriver版本 支持的Chrome版本
v2.43 v69-71
v2.42 v68-70
v2.41 v67-69
v2.40 v66-68
v2.39 v66-68
v2.38 v65-67
v2.37 v64-66
v2.36 v63-65
v2.35 v62-64
v2.34 v61-63
v2.33 v60-62
v2.32 v59-61
v2.31 v58-60
v2.30 v58-60
v2.29 v56-58
v2.28 v55-57
v2.27 v54-56
v2.26 v53-55
v2.25 v53-55
v2.24 v52-54
v2.23 v51-53
v2.22 v49-52
v2.21 v46-50
v2.20 v43-48
v2.19 v43-47
v2.18 v43-46
v2.17 v42-43
v2.13 v42-45
v2.15 v40-43
v2.14 v39-42
v2.13 v38-41
v2.12 v36-40
v2.11 v36-40
v2.10 v33-36
v2.9 v31-34
v2.8 v30-33
v2.7 v30-33
v2.6 v29-32
v2.5 v29-32
v2.4 v29-32
chromedriver下載倉庫:
http://chromedriver.storage.googleapis.com/index.html
chromedriver下載倉庫如果無法訪問,可至百度網盤下載:
百度網盤:https://pan.baidu.com/s/1eSeuA7w
分享密碼:87pc
四、配置Firefox驅動的環境變量(如以配置過pycharm的環境變量,這里可以忽略)
在我的電腦-->屬性-->高級系統設置-->環境變量(N)-->path,加入pycharm Firefox驅動的路徑;
關於環境變量的配置,這里不做講解(百度)。
注:配置好后可用以下代碼實驗是否可用,如不行請檢查步驟,或重啟電腦試試。
代碼如下:
#復制可用
import time #時間控制
from selenium import webdriver #引用selenium 的 webdriver
wd = webdriver.Firefox() #引入Firefox瀏覽器驅動模塊
wd.get('https://www.12306.cn/index/') #訪問的網址12306購票網站
time.sleep(5) #暫停5秒(時間)
wd.quit() #關閉瀏覽器窗口
——————————————————————————————————————————————————————————————————————————————————————————————————
本文完
