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)

不报错即说明安装成功

原文地址:https://www.cnblogs.com/shining5/p/12917998.html