CentOS Python3 Selenium+ChromeDriver 安装步骤
1、安装Chrome
yum install https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
	
2、安装Selenium
pip3 install selenium
	
3、下载ChromeDriver (注意:chromedriver 的大版本,要与Chrome 的大版本一致)
wget http://npm.taobao.org/mirrors/chromedriver/80.0.3987.16/chromedriver_linux64.zip
	
4、解压chromedriver
unzip chromedriver_linux64.zip
	
5、将解压后的chromedriver 复制到 /user/bin 下
cp /root/chromedriver /usr/bin/chromedriver
	
6、给文件,增加可执行权限
	
chmod +x /usr/bin/chromedriver
	
7、安装xvfb
yum install Xvfb -y
	
8、yum install xorg-x11-fonts* -y
	
内容为
	
	#!/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
	
10、给刚创建的文件,增加可执行权限
chmod +x /usr/bin/xvfb-chrome
	
11、查看当前,映射关系
ll /usr/bin/ | grep chrom
	
12、建立软链
	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
	
13、查看 修改后的映射关系
ll /usr/bin/ | grep chrom
	
14、安装完成
	
15、代码 test
------------------------------
	
from selenium import webdriver
	
 
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox') # [MARK]This argument must be exist.
driver = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options=options)
driver.get('http://py2app.readthedocs.io/en/latest/examples.html')
print(driver.title)
	
<a href="http://r4.com.cn/art135.aspx">CentOS Python3 Selenium+ChromeDriver 安装步骤</a>