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)
相关推荐
我家大宝最可爱1 分钟前
linux编译基础知识-编译时路径和运行时路径
linux·运维·服务器
寅时码8 分钟前
从“一键部署”到“可观测、可定制的发布流”:我如何打造一个企业级部署工具
运维·开源·node.js
某某1 小时前
在Centos7中安装gitlab
linux·运维·gitlab
IT成长日记2 小时前
【自动化运维神器Ansible】Ansible常用模块之user模块详解
运维·自动化·ansible·user·常用模块
cici158742 小时前
linux中HADOOP_HOME和JAVA_HOME删除后依然指向旧目录
java·linux·hadoop
卍郝凝卍3 小时前
云服务器数据库
运维·服务器·数据库
先鱼鲨生3 小时前
【Linux】System V - 责任链模式与消息队列
linux·责任链模式
钢铁男儿3 小时前
使用 asyncio 与 aiohttp 编写异步 Unicode 字符查找服务器_2025-07-30
运维·服务器
所念皆为东辞3 小时前
gitlab+jenkins的ci/cd部署
运维·ci/cd·gitlab·jenkins
AIZHINAN4 小时前
性能测试篇 :Jmeter监控服务器性能
运维·服务器·jmeter