Chrome Cli


chrome in headless mode can be used as a CLI


Taking screenshot

Size of a standard letterhead 1)

chrome --headless --disable-gpu --screenshot --window-size=1280,1696

Printing the DOM

The –dump-dom flag prints document.body.innerHTML to stdout:

chrome --headless --disable-gpu --dump-dom

Create a PDF

The –print-to-pdf flag creates a PDF of the page:

chrome --headless --disable-gpu --print-to-pdf

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
[0608/] Type a Javascript expression to evaluate or "quit" to exit.
>>> location.href
>>> quit

Powered by ComboStrap