配置yum源
在目录 /etc/yum.repos.d/ 下新建文件 google-chrome.repo
1 2
| cd /etc/yum.repos.d/ vim google-chrome.repo
|
写入如下内容:
1 2 3 4 5 6
| [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
|
更新yum
安装Chrome无头浏览器
1
| yum -y install google-chrome-stable --nogpgcheck
|
查看安装Chrome版本
1 2
| [root@iZ2ze1autlxng10rm79oi0Z ~]# google-chrome --version Google Chrome 99.0.4844.51
|
安装Chrome驱动Chrome driver
Chrome版本Google Chrome 99.0.4844.51
查看与之对应的驱动版本
下载chrome driver:https://registry.npmmirror.com/binary.html?path=chromedriver/
1
| https://registry.npmmirror.com/-/binary/chromedriver/99.0.4844.51/chromedriver_linux64.zip
|
解压
1
| unzip chromedriver_linux64.zip
|
将Chrome driver
移到/usr/local
下(这个随意,放哪儿都行)
1
| mv chromedriver /usr/local
|
添加环境变量
1 2 3
| sudo vim ~/.bash_profile PATH=$PATH:/usr/local export PATH
|
参考资料