Headless Chrome

Installing on Fedora

Create a file /etc/yum.repos.d/google-chrome.repo

[google-chrome]
name=google-chrome
baseurl=http://dl.google.com/linux/chrome/rpm/stable/x86_64
enabled=1
gpgcheck=1
gpgkey=https://dl.google.com/linux/linux_signing_key.pub
EOF

then

yum install google-chrome-stable

or

yum install google-chrome-beta

or

yum install google-chrome-unstable

(you can also you dnf of course)

Running

Mac

alias chrome="/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome"

chrome --headless --disable-gpu --fullPage --window-size=1200,8080 --screenshot=filename.png https://www.rennetti.com

chrome --headless --disable-gpu --fullPage --window-size=1200,8080 --screenshot=filename.png "https://username:password@beta.rennetti.com"

chrome --headless --disable-gpu --print-to-pdf --screenshot=filename.pdf https://www.rennetti.com

Linux (Fedora)

/usr/bin/google-chrome --headless --screenshot="/home/martin/chrome-ss1.png" "https://www.theguardian.co.uk"

 PDF

google-chrome --headless --disable-gpu --print-to-pdf --screenshot=filename.pdf https://www.guardian.co.uk

Full page

/usr/bin/google-chrome --headless --disable-gpu --fullPage --screenshot=fullpage.png https://www.guardian.co.uk

Window

/usr/bin/google-chrome --headless --disable-gpu --window-size=1280,800 --screenshot=filename.png https://www.guardian.co.uk

Dom

/usr/bin/google-chrome --headless --dump-dom "https://www.theguardian.co.uk"

Gotchas

Centos 7

check the signature

goto /var/cache/yum/x86_64/7/google-chrome/packages

rpm -Uvh --nosignature google-chrome-stable-114.0.5735.106-1.x86_64.rpm

still not working?

install these first:

  • yum install liberation-fonts
  • yum install vulkan

check here for more info