centos7安装chrome+chromeDriver+Xvfb
安装chrome
创建yum源
# cd /etc/yum.repos.d/
# vim google-chrome.repo
创建yum源信息
[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/$basearch
enabled=1
gpgcheck=1
gpgkey=https://dl-ssl.google.com/linux/linux_signing_key.pub
安装google-chrome
# yum -y install google-chrome-stable --nogpgcheck
chrome安装路径
使用上述步骤安装完成之后,chrome的安装路径在/opt/google/chrome目录下
安装chromeDriver
查看chrome版本
# google-chrome -version
下载对应版本的chromeDriver
从https://npm.taobao.org/mirrors/chromedriver/查询与chrome版本对应的chromeDriver版本,大版本对应即可,如当前chrome最新的版本是78.0.3904.97,只需要查找与78对应的chromeDriver版本即可。
找到对应的版本后,在linux上使用以下命令下载chromeDriver压缩包:
# mkdir /usr/chromedriver
# cd /usr/chromedriver
# wget https://npm.taobao.org/mirrors/chromedriver/version/chromedriver_linux64.zip
version为chromeDriver的完整版本号
下载之后解压压缩包:
# unzip chromedriver_linux64.zip
给chromeDriver文件夹赋予权限:
# chmod +x /usr/chromedriver/chromedriver
安装Xvfb
安装说明
安装此软件的原因是在centos上,chromeDriver必须使用无头模式,当有不使用无头模式的需求时就需要安装此软件,否则chromeDriver无法正确启动chrome
安装Xvfb
# yum install Xvfb -y
# yum install xorg-x11-fonts* -y
在/usr/bin/目录下创建xvfb-chrome文件
# vim /usr/bin/xvfb-chrome
在xvfb-chrome文件中输入以下内容
#!/bin/bash
_kill_procs() {
kill -TERM $chrome
wait $chrome
kill -TERM $xvfb
}
# Setup a trap to catch SIGTERM and relay it to child processes
trap _kill_procs SIGTERM
XVFB_WHD=${XVFB_WHD:-1280x720x16}
# Start Xvfb
Xvfb :99 -ac -screen 0 $XVFB_WHD -nolisten tcp &
xvfb=$!
export DISPLAY=:99
chrome --no-sandbox --disable-gpu$@ &
chrome=$!
wait $chrome
wait $xvfb
添加执行权限:
# chmod +x /usr/bin/xvfb-chrome
查看当前的映射关系:
# ll /usr/bin/ | grep chrom
映射关系如下所示:
lrwxrwxrwx 1 root root 31 Nov 18 14:25 chrome -> /etc/alternatives/google-chrome
lrwxrwxrwx 1 root root 20 Nov 18 14:25 google-chrome -> /usr/bin/xvfb-chrome
lrwxrwxrwx 1 root root 32 Jun 28 18:39 google-chrome-stable -> /opt/google/chrome/google-chrome
-rwxr-xr-x 1 root root 422 Nov 18 14:24 xvfb-chrome
更改chrome启动的软连接:
# ln -s /etc/alternatives/google-chrome /usr/bin/chrome
# rm -rf /usr/bin/google-chrome
# ln -s /usr/bin/xvfb-chrome /usr/bin/google-chrome
此时再次查看映射关系,如下所示:
lrwxrwxrwx 1 root root 31 Nov 18 14:36 chrome -> /etc/alternatives/google-chrome
lrwxrwxrwx 1 root root 20 Nov 18 14:36 google-chrome -> /usr/bin/xvfb-chrome
lrwxrwxrwx 1 root root 32 Jun 28 18:21 google-chrome-stable -> /opt/google/chrome/google-chrome
-rwxr-xr-x 1 root root 422 Nov 18 14:36 xvfb-chrome
以上步骤操作完成后即可在centos环境下使用非无头浏览器,此时chromeDriver创建时不能再添加以下参数:
options.addArguments("--headless")
centos7安装chrome+chromeDriver+Xvfb的更多相关文章
- CentOS-yum安装chrome+chromeDriver+xvfb
安装chrome 创建yum源文件 $ vim /etc/yum.repos.d/google-chrome.repo [google-chrome] name=google-chrome baseu ...
- centos7安装chrome及加载poatman开发插件
为什么要安装chrome?因为centos7的默认浏览器firefox的实在是不习惯,上面占了太多,本来显示器就不大... 好了,首先下载chome的rpm安装包(如果需要的可以留言,我有备份) 然后 ...
- CentOS7 安装chrome浏览器
本篇文章主要记录如何在CentOS7.0上安装chrome. 1.配置yum下载源: 在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repo, 并且在该文件中添加 ...
- 【转载】CentOS7 安装Chrome浏览器
本篇文章主要记录如何在CentOS7.0上安装Chrome浏览器. 方法1: Google官方源在国内可能无法正常访问,故而添加Fedora中文社区提供的镜像源: sudo wget http://r ...
- CentOS7 安装Chrome
1. 下载Chrome浏览器的rpm包 https://www.chrome64bit.com/index.php/google-chrome-64-bit-for-linux 2. 安装Chrome ...
- centos7安装chrome的历程(fedora同)
安装 首先是下载,地址奉上:http://www.google.cn/chrome/browser/desktop/index.html,选择64 bit .rpm (适用于 Fedora/openS ...
- Linux Centos7安装chrome浏览器
参考:https://blog.csdn.net/u010472499/article/details/72327963 1. 配置yum源 在目录 /etc/yum.repos.d/ 下新建文件 g ...
- centos7安装chrome浏览器
1.配置yum下载源: 在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repo, 并且在该文件中添加如下内容: [google-chrome]name=googl ...
- CentOS7安装Chrome
1. 进入官网:https://www.google.cn/intl/zh-CN/chrome/2. 点击下载3. 直接安装:sudo yum localinstall google-chrome-s ...
随机推荐
- Fedora镜像下载地址
Fedora镜像下载地址 Fedora 7核心源码包在: http://archives.fedoraproject.org/pub/archive/fedora/linux/releases/7/F ...
- 精确报告Linux内存使用情况实用脚本:ps_mem
精确报告Linux内存使用情况实用脚本:ps_mem 2019-09-06 12:45 ps_mem内存工具 ps_mem 是一个可以帮助我们精确获取 Linux 中各个程序核心内存使用情况的简单 p ...
- GO学习-(21) Go语言基础之Go性能调优
Go性能调优 在计算机性能调试领域里,profiling 是指对应用程序的画像,画像就是应用程序使用 CPU 和内存的情况. Go语言是一个对性能特别看重的语言,因此语言中自带了 profiling ...
- GO语言异常处理01---恐慌的报出与处理
package main import ( "fmt" "math" ) /*自己报出恐慌的语法*/ func main021() { fmt.Println( ...
- 给powershell增加类似于linux的alias功能
给powershell增加类似于快捷方式的功能(类似于linux的alias) 首先执行 set-executionpolicy remotesigned 允许powershell执行脚本 然后执行e ...
- 在NVIDIA A100 GPU中使用DALI和新的硬件JPEG解码器快速加载数据
在NVIDIA A100 GPU中使用DALI和新的硬件JPEG解码器快速加载数据 如今,最流行的拍照设备智能手机可以捕获高达4K UHD的图像(3840×2160图像),原始数据超过25 MB.即使 ...
- CVPR2020:4D点云语义分割网络(SpSequenceNet)
CVPR2020:4D点云语义分割网络(SpSequenceNet) SpSequenceNet: Semantic Segmentation Network on 4D Point Clouds 论 ...
- vulhub-struct2-s2-005
0x00 漏洞原理 s2-005漏洞的起源源于S2-003(受影响版本: 低于Struts 2.0.12),struts2会将http的每个参数名解析为OGNL语句执行(可理解为java代码).O ...
- Java swing JFrame用repaint出现闪烁的问题解决
这几天用swing写登录页面背景动图的时候发现一直会有闪烁(我的类是继承JFrame),就来搜原因后发现好像是因为repaint会调用update()方法中的清屏操作导致闪烁. 我当时看的是这个文章 ...
- halcon——缺陷检测常用方法总结(特征训练)
引言 机器视觉中缺陷检测分为一下几种: blob分析+特征 模板匹配(定位)+差分:halcon--缺陷检测常用方法总结(模板匹配(定位)+差分) - 唯有自己强大 - 博客园 (cnblogs.co ...