一、最新版RPM安装
1、安装依赖
yum install liberation-fonts -y
yum install vulkan -y
yum -y install redhat-lsb*
yum -y install libXss*
yum -y install libappindicator*
yum -y install libgbm
2、下载google-chrome RPM
wget https://dl.google.com/linux/direct/google-chrome-stable_current_x86_64.rpm
3、安装google-chrome
rpm -ivh google-chrome-stable_current_x86_64.rpm
4、查看google-chrome版本
google-chrome --version
二、历史版本安装
1、下载指定版本安装包
以105版本为例,一般存在以下三个通道版本,可按照需要点击Get downloads下载:
dev:开发版
beta:测试版
stable:稳定版
2、使用unzip解压
unzip Linux_x64_1027022_chrome-linux.zip
3、查看版本
进入解压缩目录,输入命令
./chrome --version
三、下载chromedriver
1、根据google-chrome版本号下载对应的驱动
下载链接:CNPM Binaries Mirror
2、使用unzip解压
unzip chromedriver_linux64.zip
3、设置可执行权限
chmod +x chromedriver
4、设置参数(Java)
ChromeOptions options = new ChromeOptions();
options.addArguments("--headless");
options.addArguments("--ignore-certificate-errors");
options.addArguments("--window-size=1920,1080");
options.addArguments("--user-agent=Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/105.0.0.0 Safari/537.36");
更多参数,请查看:List of Chromium Command Line Switches « Peter Beverloo