参照https://cuiqingcai.com/4886.html

1
2
3
4
## 安装yum源
# sudo yum install -y epel-release
## 安装Chrome
# yum install -y chromium

 

 

去这个地方:https://sites.google.com/a/chromium.org/chromedriver/downloads 下载ChromeDriver驱动放在/usr/bin/目录下:

完成结果如下:

Shell
 
1
2
3
# ll /usr/bin/ | grep chrom
chromedriver
.sh

安装XVFB:

1
2
# yum install Xvfb -y
# yum install xorg-x11-fonts* -y

新建在/usr/bin/ 一个名叫 xvfb-chromium 的文件写入以下内容:

Shell
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# cat /usr/bin/xvfb-chromium
#!/bin/bash
 
{
$chromium
$chromium
$xvfb
}
 
# Setup a trap to catch SIGTERM and relay it to child processes
SIGTERM
 
}
 
# Start Xvfb
&
!
 
99
 
&
!
 
$chromium
$xvfb

更改软连接:

Shell
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
## 更改Chrome启动的软连接
# ln -s /usr/lib64/chromium-browser/chromium-browser.sh /usr/bin/chromium
 
 
# rm -rf /usr/bin/chromium-browser
 
# ln -s /usr/bin/xvfb-chromium /usr/bin/chromium-browser
 
# ln -s /usr/bin/xvfb-chromium /usr/bin/google-chrome
 
# ll /usr/bin/ | grep chrom*
chromedriver
.sh
chromium
chronyc
chromium
chromium
Shell
 
1
2
3
4
5
6
webdriver
)
)
)
)
.page_source

 

PS:

 

报错:location /usr/bin/google-chrome is no longer running

安装google-chrome-stable

wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
yum -y localinstall google-chrome-stable_current_x86_64.rpm

引入:https://blog.csdn.net/blueheart20/article/details/81566903?utm_source=copy 

相关文章:

  • 2021-11-26
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-11-07
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-21
  • 2021-11-13
  • 2022-02-26
  • 2021-11-29
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案