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 分钟前
ubuntu 22.04 wifi网卡配置地址上网
linux·运维·ubuntu
码农新猿类10 分钟前
Ubuntu摄像头打开失败
linux·运维·ubuntu
PWRJOY34 分钟前
Ubuntu磁盘空间分析:du命令及常用组合
linux·运维·ubuntu
ASDyushui44 分钟前
Shell 编程之正则表达式与文本处理器
linux·正则表达式
Looooking1 小时前
Python 之 selenium 打开浏览器指定端口进行接续操作
python·selenium
wanhengidc1 小时前
SCDN能够运用在物联网加速当中吗?
运维·服务器·网络
zuozewei1 小时前
安全扫描之 Linux 杀毒软件 Clamav 安装
linux·运维·安全
wangchen_01 小时前
linux-信号保存和处理
linux·运维·服务器
Eric.Lee20211 小时前
conda 输出指定python环境的库 输出为 yaml文件
linux·python·conda
z人间防沉迷k2 小时前
互联网协议的多路复用、Linux系统的I/O模式
linux·网络·http