Search code examples
bashgoogle-chromegoogle-chrome-headless

How do I download a website with Chrome Headless from the command line?


Can I use Headless Chrome/Chromium as a substitute for curl or wget from Bash?


Solution

  • Use the --dump-dom flag:

    chrome --headless --dump-dom <url>
    

    or if you're using Chromium on Linux

    chromium-browser --headless --dump-dom <url>
    

    will dump the HTML contents of the page to your terminal (ie. to stdout), just like curl.

    See the official post Getting Started with Headless Chrome.

    On Windows you might also need to pass --disable-gpu to those commands.