Linux环境下安装selenium 和 chromedriver

安装selenium模块

bash 复制代码
pip3 install selenium

安装谷歌浏览器

bash 复制代码
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm -y

安装chromedriver

1)运行下面命令查看浏览器版本
bash 复制代码
google-chrome --version
# Google Chrome 123.0.6312.122
2) 根据谷歌浏览器版本下载对应的浏览器驱动版本

Chrome for Testing availability (这个页面里是高版本的驱动)

ChromeDriver - WebDriver for Chrome - Downloads (这个页面是低版本的驱动)

bash 复制代码
wget https://storage.googleapis.com/chrome-for-testing-public/123.0.6312.122/linux64/chromedriver-linux64.zip
3)解压安装
bash 复制代码
unzip chromedriver-linux64.zip
mv chromedriver-linux64/chromedriver /usr/bin/
chmod +x /usr/bin/chromedriver 
chromedriver -version
代码中添加配置
bash 复制代码
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
chrome_options.add_argument('--disable-extensions')
chrome_options.add_argument('--log-level=0')
chrome_options.add_argument('--remote-debugging-port=9222')
# GPU硬件加速
chrome_options.add_argument('---disable-gpu')
browser = webdriver.Chrome(options=chrome_options)
相关推荐
挥剑决浮云 -3 分钟前
Linux 之 安装软件、GCC编译器、Linux 操作系统基础
linux·服务器·c语言·c++·经验分享·笔记
小O_好好学1 小时前
CentOS 7文件系统
linux·运维·centos
哲伦贼稳妥1 小时前
一天认识一个硬件之机房地板
运维·网络·经验分享·其他
john_hjy2 小时前
11. 异步编程
运维·服务器·javascript
x晕x2 小时前
Linux dlsym符号查找疑惑分析
linux·运维·服务器
活跃的煤矿打工人2 小时前
【星海saul随笔】Ubuntu基础知识
linux·运维·ubuntu
北京智和信通3 小时前
云平台和虚拟化智慧运维监控,全面提升故障感知与处置能力
运维·虚拟化·云平台·虚拟机监控
fasewer3 小时前
第五章 linux实战-挖矿 二
linux·运维·服务器
楚灵魈3 小时前
[Linux]从零开始的网站搭建教程
linux·运维·服务器
小小不董3 小时前
《Linux从小白到高手》理论篇:深入理解Linux的网络管理
linux·运维·服务器·数据库·php·dba