centos 7 中Selenium安装最新版Chrome WebDriver

centos 7 中Selenium安装最新版Chrome WebDriver

需求: 需要使用 selenium 对某个网页进行截图 参考:https://blog.csdn.net/weixin_43411585/article/details/140486775 https://www.cnblogs.com/nuccch/p/15063165.html (要vpn打开)


2a8a458834262a7044742345c9a42.png)

一、安装google chrome

1.1 下载地址

linux版本google rmp包下载地址:http://dist.control.lth.se/public/CentOS-7/x86_64/google.x86_64/
在这里插入图片描述
测试版地址

https://googlechromelabs.github.io/chrome-for-testing/known-good-versions-with-downloads.json

这里包含了chrome 和 driver的地址
在这里插入图片描述

最新版地址 ChromeDriver Latest Releases Versions Downloads - Chrome for Testing availability:

https://googlechromelabs.github.io/chrome-for-testing/

1.2 注意事项

在这里不要下载最新版本的,不然会报错
在这里插入图片描述
下载并安装了 glibc_2.25 版本也是没有用的,centos 7 不支持,哭死,我非要尝试
报错解决方案参考:https://blog.csdn.net/ycsdn10/article/details/122224632

1.3 下载版本

最后下载了 124 版本,版本更高的可能会有问题

wget http://dist.control.lth.se/public/CentOS-7/x86_64/google.x86_64/google-chrome-stable-124.0.6367.118-1.x86_64.rpm

1.4 安装

安装命令

sudo yum install google-chrome-stable-128.0.6613.119-1.x86_64.rpm

可能会出现yum源报错,参考:Centos 7.9 配置yum源失败,报错 x86_64/repodata/repomd.xml: [Errno 14] HTTP Error 403

1.5 安装成功测试

测试命令

google-chrome --version

在这里插入图片描述

1.6 创建软连接

sudo ln -s /usr/bin/google-chrome /usr/bin/chrome
#测试
chrome --version

结果:Google Chrome 124.0.6367.118

二、安装 Chrome Driver

2.1 驱动地址:

114版本及之前的浏览器驱动chromedriver:

官方:https://chromedriver.storage.googleapis.com/index.html
淘宝镜像:https://registry.npmmirror.com/binary.html?path=chromedriver/

115及之后的新版本的浏览器chromedriver驱动:

115以后chromedriver驱动版本
官网:https://googlechromelabs.github.io/chrome-for-testing/#stable
国内镜像:https://registry.npmmirror.com/binary.html?path=chrome-for-testing/

根据自己浏览器的版本来选择驱动

2.2 安装Chrome Driver

若没有unzip,请先安装

sudo yum install -y unzip

解决到 /usr/local/bin/ 目录

sudo unzip chromedriver-linux64.zip -d /usr/local/bin/

移动到 /usr/local/bin/ 目录下

cd /usr/local/bin/
sudo mv chromedriver-linux64/* ./

为 chromedriver 添加执行权限

sudo chmod +x ./chromedriver

执行

chromedriver --version

结果

ChromeDriver 124.0.6367.155 (df4f029328b2d50a2a4c02c8952b75245983a0ed-refs/branch-heads/6367@{#1097})
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

ysksolution

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值