Skip to content

Instantly share code, notes, and snippets.

@Sp0ne
Created September 14, 2021 12:45
Show Gist options
  • Save Sp0ne/e547cd8b3afb64a278761e6c302eff0c to your computer and use it in GitHub Desktop.
Save Sp0ne/e547cd8b3afb64a278761e6c302eff0c to your computer and use it in GitHub Desktop.
Puppeteer Debian Headless Memo

System

Debian 10 Buster headless

Chromium dependencies

Shared Libraries needed

$ sudo apt install libnss3 libatk1.0-0 libatk-bridge2.0-0 libcups2 libgbm1 libasound2 libpangocairo-1.0-0 libxss1 libgtk-3-0

Install nvm

Local user

$ curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

Reconnect/Reload or load manually

Install NodeJS

nvm install node

Test Puppeteer

Create a new foler and install puppeteer

$ mkdir test && pushd test
$ npm i puppeteer # or yarn add puppeteer

Run a test program

Create a new file

$ nano test.js

Content

const puppeteer = require('puppeteer');

(async () => {
  const browser = await puppeteer.launch();
  const page = await browser.newPage();
  await page.goto('https://example.com');
  await page.screenshot({path: 'example.png'});

  await browser.close();
})();

If all went fine you will have a screenshot of the page on your current folder.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment