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)
相关推荐
Kookoos1 小时前
Dynamics 365 Finance + Power Automate 自动化凭证审核
运维·自动化·dynamics 365·power automate
apocelipes3 小时前
Linux c 运行时获取动态库所在路径
linux·c语言·linux编程
努力学习的小廉4 小时前
深入了解linux系统—— 进程池
linux·运维·服务器
秃头菜狗5 小时前
各个主要目录的功能 / Linux 常见指令
linux·运维·服务器
2301_793102495 小时前
Linux——MySql数据库
linux·数据库
jiunian_cn6 小时前
【Linux】centos软件安装
linux·运维·centos
藥瓿亭6 小时前
K8S认证|CKS题库+答案| 6. 创建 Secret
运维·ubuntu·docker·云原生·容器·kubernetes·cks
程序员JerrySUN6 小时前
[特殊字符] 深入理解 Linux 内核进程管理:架构、核心函数与调度机制
java·linux·架构
孤寂大仙v6 小时前
【计算机网络】非阻塞IO——select实现多路转接
linux·计算机网络
2302_809798326 小时前
【JavaWeb】Docker项目部署
java·运维·后端·青少年编程·docker·容器