Labels

Java (10) Spring (10) Spring MVC (6) Web Services (5) Rest (4) Javascript (3) Nodejs (3) Spring Batch (3) Angular (2) Angular2 (2) Angular6 (2) Expressjs (2) Passportjs (2) SOAP (2) SOAPUI (2) Spring Boot (2) AJAX (1) H2 (1) JQuery (1) JUnit (1) Npm (1) Puppeteer (1) Python (1) RaspberryPi (1) Raspbian (1) SQL (1) SQLite (1) Scripts (1) html (1)

Tuesday, November 13, 2018

Make puppeteer work with raspbian (vers. octover 2018)

Recently I have many problems installing puppeteer on my Raspberry pi 3 B. After a hard struggle I was able to configure it.
Let us see how this can be done.

1. Install the last version of node


Raspbian comes with an old version of node, you will need a more recent one (10 for instance):

# https://medium.com/google-cloud/node-to-google-cloud-compute-engine-in-25-minutes-7188830d884e
curl -sL https://deb.nodesource.com/setup_10.x | sudo bash -
sudo apt install nodejs


2. Install the necessary debian dependencies


here you have a gist with all the necessary ones.
#install dependencies
#https://github.com/GoogleChrome/puppeteer/issues/290#issuecomment-322838700
sudo apt-get install gconf-service libasound2 libatk1.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget


3. Install chromium-browser 65 and its codecs


you will need to run:
wget http://launchpadlibrarian.net/361669485/chromium-browser_65.0.3325.181-0ubuntu0.14.04.1_armhf.deb; sudo dpkg -i chromium-browser_65.0.3325.181-0ubuntu0.14.04.1_armhf.deb
wget http://launchpadlibrarian.net/361689926/chromium-codecs-ffmpeg_65.0.3325.181-0ubuntu0.16.04.1_armhf.deb; sudo dpkg -i chromium-codecs-ffmpeg_65.0.3325.181-0ubuntu0.16.04.1_armhf.deb


you may need to run also this command to fix broken packages:


sudo apt-get --fix-broken install

4. Use the param executablePath when you launch puppeteer


When you launch puppeteer you will need to specify the path for your chrome-browser. You need to use the parameter executablePath for that. See this minimal example:

const puppeteer = require('puppeteer');
(async () => {
const browser = await puppeteer.launch({executablePath: '/usr/bin/chromium-browser'});
const page = await browser.newPage();
await page.goto('https://example.com');
await page.screenshot({path: 'example.png'});
await browser.close();
})();







3 comments:

  1. Thanks for sharing this information! I've converted all this logic sucessfully in a Dockerfile, and i'm running puppeteer succesfully (finally) on my rPi2! :-)

    ReplyDelete
  2. Hi Brecht,

    could you please share your dockerfile or push the docker image to dockerhub?
    Thanks.

    ReplyDelete
  3. Hi Unknown,

    I'm sorry for the late response.
    Recently I had some troubles though using page.Click()

    Meanwhile I rewrote the Dockerfile, which seems to be 100% functional right now (including page.Click() functionality)
    You can find the Dockerfile @
    https://github.com/brechtvm/puppeteer/blob/master/Dockerfile

    Hope this helps!

    ReplyDelete