# Headless
官网列出了很多有意思的工具:链接 (opens new window)
实现了Remote debugging protocol的node的库:
- chrome-debug-protocol (opens new window) 使用了ES6和TypeScript
- chrome-remote-interface (opens new window) 官网推荐的
- chrome-har-capturer (opens new window) 传入url,直接获取har format文件
// 新建一个标签页
http://localhost:9222/json/new
http://localhost:9222/json/new?http://www.baidu.com
// 关闭一个标签页
http://localhost:9222/json/close/477810FF-323E-44C5-997C-89B7FAC7B158
// 激活标签页
http://localhost:9222/json/activate/477810FF-323E-44C5-997C-89B7FAC7B158
// 查看chrome和协议的版本信息
http://localhost:9222/json/version
network-settings (opens new window)
google-chrome --headless --disable-gpu --remote-debugging-port=9222 http://www.m45e.com
# 获取屏幕截图:
google-chrome --headless --disable-gpu --screenshot --window-size=1280,1696 https://github.com
# 获取页面为PDF:
google-chrome --headless --disable-gpu --print-to-pdf https://github.com
# 打印页面DOM:
google-chrome --headless --disable-gpu --dump-dom https://github.com/
# 使用代理
google-chrome --proxy-server="socks5://192.168.11.25:1081"
%ProgramFiles%\Google\Chrome\Application\chrome.exe --save-page-as-mhtml
# download
最新稳定版:https://www.google.com/intl/zh-CN/chrome/browser/?standalone=1 最新测试版:https://www.google.com/intl/zh-CN/chrome/browser/?standalone=1&extra=betachannel 最新开发版:https://www.google.com/intl/zh-CN/chrome/browser/?standalone=1&extra=devchannel