/headless-chrome

how to install headless chrome

For MAC OX

=====================

how to install

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

  • alias canary="/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary"

chrome parameters:

  • background mode --headless
  • block image --blink-settings=imagesEnabled=false
  • print dom --dump-dom
canary --headless --disable-gpu --blink-settings=imagesEnabled=false --print-to-pdf https://www.baidu.com/

For Linux Server

=====================

how to install headless google-chrome

$ wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
$ sudo dpkg -i google-chrome*
  • eg. i download a named 60.0.3112.90_amd64.deb of google-chrome
$ sudo dpkg -i 60.0.3112.90_amd64.deb

how to find where is the chome app

$ which google-chrome-stable 
  • then i got /usr/bin/google-chrome-stable, for convenience you can make a alias
$ alias chrome=/usr/bin/google-chrome-stable
  • then
chome --headless --disable-gpu --blink-settings=imagesEnabled=false --print-to-pdf https://google.com

refer doc

https://developers.google.com/web/updates/2017/04/headless-chrome