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):
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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:
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | |
})(); |
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! :-)
ReplyDeleteHi Brecht,
ReplyDeletecould you please share your dockerfile or push the docker image to dockerhub?
Thanks.
Hi Unknown,
ReplyDeleteI'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!