Centos7 之安装 Headless Chrome

Headless Chrome

什么是Headless Chrome

Chrome59中开始搭载Headless Chrome。这是一种在无需显示headless的环境下运行Chrome 浏览器的方式。从本质上来说,就是不用Chrome浏览器来运行Chrome的功能!它将ChromiumBlink渲染引擎提供的所有现代Web平台的功能都带入了命令行。

intoli

开始安装之前我们来了解一下这家公司

我们(intoli)是一家在数据采集,处理和分析方面具有深厚专业知识的咨询机构。

安装

intoli在其博客上介绍了几种安装Headless Chrome的方式,我们采用如下方式安装:

1
curl https://intoli.com/install-google-chrome.sh | bash

安装完成提示:

1
Successfully installed Google Chrome!

intoli 安装文档

运行 chrome

我们可以通过如下命令来启动Chrome,同时将博客截图保存

1
google-chrome-stable --no-sandbox --headless --disable-gpu --screenshot https://www.jakehu.me

Chromedriver

chromedriver可以前往淘宝镜像下载,同时通过下面命令进行验证:

1
2
3
4
./chromedriver
Starting ChromeDriver 73.0.3683.68 (47787ec04b6e38e22703e856e101e840b65afe72) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.

如果有如上输出则表示驱动正常运行