当前位置: 首页 > news >正文

chromedriver可运行的docker环境

以常见的linux x86服务器为例

chrome driver

官网:https://googlechromelabs.github.io/chrome-for-testing/
下载chrome linux64位:https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/xxx
下载chrome driver linux64位:https://storage.googleapis.com/chrome-for-testing-public/131.0.6778.85/xxx

运行容器

docker run -itd \--name tophub \-v /root/miniconda3:/root/miniconda3 \-v /home/service/tophub:/app \-w /app \--network host \centos:8 /bin/bash

进入容器

docker exec -it tophub /bin/bash

在容器内设置环境变量

export PATH="/root/miniconda3/envs/tophub/bin:$PATH"
export CONDA_PREFIX="/root/miniconda3/envs/tophub"

首先备份原有的源

cd /etc/yum.repos.d/
mkdir backup
mv *.repo backup/

创建新的源文件

cat > /etc/yum.repos.d/CentOS-Base.repo << 'EOF'
[BaseOS]
name=CentOS-$releasever - Base
baseurl=https://mirrors.aliyun.com/centos-vault/8.5.2111/BaseOS/$basearch/os/
gpgcheck=0
enabled=1[AppStream]
name=CentOS-$releasever - AppStream
baseurl=https://mirrors.aliyun.com/centos-vault/8.5.2111/AppStream/$basearch/os/
gpgcheck=0
enabled=1[extras]
name=CentOS-$releasever - Extras
baseurl=https://mirrors.aliyun.com/centos-vault/8.5.2111/extras/$basearch/os/
gpgcheck=0
enabled=1[PowerTools]
name=CentOS-$releasever - PowerTools
baseurl=https://mirrors.aliyun.com/centos-vault/8.5.2111/PowerTools/$basearch/os/
gpgcheck=0
enabled=1
EOF

清理缓存并更新

dnf clean all
dnf makecache

现在可以安装软件包了

dnf install -y dnf-plugins-core

尝试不同的 PowerTools 仓库名称

dnf config-manager --set-enabled PowerTools || \
dnf config-manager --set-enabled power-tools || \
dnf config-manager --set-enabled centos-power-tools

安装需要的包

dnf install -y \nss \nss-tools \libX11 \libXcomposite \libXcursor \libXdamage \libXext \libXi \libXtst \cups-libs \libXrandr \libXScrnSaver \libXvMC \mesa-libgbm \alsa-lib \pango \atk \at-spi2-atk \gtk3

如果遇到找不到包的情况,我们可以启用 EPEL 仓库

dnf install -y epel-release

然后再次尝试安装

dnf install -y \nss \nss-tools \libX11 \libXcomposite \libXcursor \libXdamage \libXext \libXi \libXtst \cups-libs \libXrandr \libXss \libXvMC \mesa-libgbm \alsa-lib \pango \atk \at-spi2-atk \gtk3

验证chrome驱动

./chromedriver-linux64/chromedriver --version

# 正确回显如下
ChromeDriver 131.0.6778.87 (ce31cae9487357cfd3bd62984ed5250121a71a23-refs/branch-heads/6778@{#2287})
http://www.lryc.cn/news/504455.html

相关文章:

  • 【YashanDB知识库】如何将mysql含有group by的SQL转换成崖山支持的SQL
  • 希迪智驾持续亏损8.2亿:毛利率下滑,冲刺“自动驾驶矿卡第一股”
  • 部署GitLab服务器
  • 利用cnocr库完成中文扫描pdf文件的文字识别
  • pythonselenium自动化初始配置
  • 【C++】数的性质问题分析与优化
  • ASP.NET Core WebAPI中使用Jwt实现鉴权授权-System.IdentityModel.Tokens.Jwt
  • 【iOS】OC高级编程 iOS多线程与内存管理阅读笔记——自动引用计数(四)
  • 嵌入式软考学习笔记(1)超详细!!!
  • 【数据分享】2013-2023年我国省市县三级的逐年CO数据(免费获取\excel\shp格式)
  • C# 探险之旅:第十六节 - 整数类型:与八位数字精灵的奇幻舞会
  • Cleo文件传输软件存在任意文件读取漏洞(CVE-2024-50623)
  • Java 小抄|解析 JSON 并提取特定层级数据
  • 活动报名:Voice Agent 开发者分享会丨RTE Meetup
  • DOA估计算法——ESPRIT算法
  • CEF 数据加密与网络安全
  • go build command
  • 理解音频采样率和transformer模型:给Python小白的简单解释
  • 【RL Latest Tech】安全强化学习(Safe RL):理论、方法与应用
  • 大模型qiming面试内容整理-系统设计与架构
  • Mac/Windows端长期破解myBase8方法(无需安装火绒)
  • firewall
  • XSS(跨站攻击)
  • Tomcat添加各种响应头 X-Download-Options、Permissions-Policy等
  • 搭建Tomcat(一)---SocketServerSocket
  • ubuntu 使用 Times New Roman 字体在 Matplotlib 中绘图并调整字体大小
  • openGauss开源数据库实战二十三
  • MySQL 复合查询(重点)
  • ASP.NET |日常开发中连接Oracle数据库详解
  • java_连接数据库的方法_后端处理_前端调用_打通整体思路