微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

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)

不报错即说明安装成功

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。

相关推荐