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)
相关推荐
倔强的胖蚂蚁16 分钟前
x2openEuler 辅助机完整部署教程
运维·云原生
原来是猿26 分钟前
Linux进程信号详解(二):信号产生
linux·运维·服务器
chxii28 分钟前
Nginx性能优化-压缩(返回头报文介绍)
运维·nginx·性能优化
Bert.Cai42 分钟前
Linux cd命令详解
linux·运维
扑火的小飞蛾1 小时前
Kali Linux 安装 OpenClaw 详细教程
linux·运维·服务器
PrDf22Iw81 小时前
CPU ↔ DRAM(内存总线)的可持续数据传输带宽
java·运维·网络
王琦03182 小时前
第二次作业
linux·运维·服务器
Bert.Cai2 小时前
Linux mkdir命令详解
linux·运维
超绝振刀怪2 小时前
【Linux进程状态:僵尸进程、孤儿进程和调度基础】
linux·僵尸进程·孤儿进程·进程状态
chenglin0162 小时前
AI服务的可观测性与运维
运维·人工智能