Centos7 安裝selenium webdriver環境


最重要的是:webdriver及chrome-browser版本一致,否則啟動失敗

1. 安裝selenium

pip3 install selenium

2. 安裝chrome-browser

wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
 yum install ./google-chrome-stable_current_x86_64.rpm

安裝完成后會顯示當前版本。

我安裝的版本是81.0.4044.138

3. 安裝chromedriver(千萬與chrome-browser版本對應)

在 http://chromedriver.storage.googleapis.com/這個頁面找對應版本的下載地址

wget http://chromedriver.storage.googleapis.com/81.0.4044.138/chromedriver_linux64.zip

解壓unzip chromedriver_linux64.zip

mv chromedriver /usr/bin即可

4. 測試

from selenium import webdriver
option = webdriver.ChromeOptions()
option.add_argument('--no-sandbox')
option.add_argument('--headless')
driver = webdriver.Chrome(chrome_options=option)

不報錯即說明安裝成功


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM