Chrome Cli
About
chrome in headless mode can be used as a CLI
Example
Taking screenshot
Size of a standard letterhead 1)
chrome --headless --disable-gpu --screenshot --window-size=1280,1696 https://datacadamia.com/
Printing the DOM
The –dump-dom flag prints document.body.innerHTML to stdout:
chrome --headless --disable-gpu --dump-dom https://www.chromestatus.com/
Create a PDF
The –print-to-pdf flag creates a PDF of the page:
chrome --headless --disable-gpu --print-to-pdf https://www.chromestatus.com/
REPL mode (read-eval-print loop)
The –repl flag runs Headless in a Javascript engine in REPL mode
chrome --headless --disable-gpu --repl --crash-dumps-dir=./tmp https://www.chromestatus.com/
[0608/112805.245285:INFO:headless_shell.cc(278)] Type a Javascript expression to evaluate or "quit" to exit.
>>> location.href
{"result":{"type":"string","value":"https://www.chromestatus.com/features"}}
>>> quit