I\'ve been looking at the following article about Headless Chrome:
https://developers.google.com/web/updates/2017/04/headless-chrome
I just upgraded Chrome on Wi
Current versions (68-70) seem to require --no-sandbox
in order to run, without it they do absolutely nothing and hang in the background.
The full commands I use are:
chrome --headless --user-data-dir=tmp --no-sandbox --enable-logging --dump-dom https://www.google.com/ > file.html
chrome --headless --user-data-dir=tmp --no-sandbox --print-to-pdf=whatever.pdf https://www.google.com/
Using --no-sandbox
is a pretty bad idea and you should use this only for websites you trust, but sadly it's the only way of making it work at all.
--user-data-dir=...
uses the specified directory instead of the default one, which is likely already in use by your regular browser.
However, if you're trying to make a PDF from HTML, then this is fairly useless, since you can't remove header and footer (containing text like file:///...
) and the only viable solution is to use Puppeteer.