Skip to content

Instantly share code, notes, and snippets.

@Evgenyx82
Last active December 11, 2018 12:20
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Evgenyx82/69f9639ede5fdbea0d9fd201f0eb4b9d to your computer and use it in GitHub Desktop.
Save Evgenyx82/69f9639ede5fdbea0d9fd201f0eb4b9d to your computer and use it in GitHub Desktop.
Ubuntu Server 18 & Puppeteer - headless

Ubuntu Server 18 & node js setup can be found here: https://gist.github.com/Evgenyx82/a4cda429ff3318d350efaaef99c3bfbe

const fs = require('fs')
const path = require('path')
const puppeteer = require('puppeteer')
  (async () => {
    const browser = await puppeteer.launch({
      args: [
        "--no-sandbox",
        "--disable-setuid-sandbox"
      ]
    })
    const page = await browser.newPage()
    await page.goto('https://ya.ru/')
    await page.screenshot({ path: 'ya.png' })
    const html = await page.content()
    fs.writeFileSync(path.join(__dirname, 'ya.html'), html, 'utf8')
    await browser.close()
  })()

By default it give error: libx11-xcb.so.1 cannot open shared object file...

I have found this post: puppeteer/puppeteer#290 (comment)

I'll duplicate content of this post here:

sudo apt-get install -y 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

then everything is working as expected

That's all %)

11.12.2018

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