Headless Chrome

作者:刘专,日期:2018 年 01 月 05 日

Headless Chrome 是 Chrome 浏览器的无界面形态,可以在不打开浏览器的前提下,使用所有 Chrome 支持的特性运行你的程序。相比于现代浏览器,Headless Chrome 更加方便测试 web 应用,获得网站的截图,做爬虫抓取信息等。

如何在终端使用

在 Mac 上使用前,建议先绑定 Chrome 别名

alias google-chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"

然后,在终端输入:

google-chrome --headless --disable-gpu --remote-debugging-port=9222  https://github.com

此时,Headless Chrome已经成功运行了。打开浏览器,输入 http://localhost:9222

To Be Continue

REF