Code Monkey home page Code Monkey logo

docker-puppeteer-full-noto's Introduction

puppeteer docker image

docker image with Google Puppeteer installed

and screenshots scripts

and noto fonts, noto CJK fonts, and noto emoji

nodesource/node

this is a fork

Forked from alekzonder/docker-puppeteer.

docker tags

  • latest

install

docker pull starlocke/puppeteer-full-noto:latest

before usage

  1. you should pass --no-sandbox, --disable-setuid-sandbox args when launch browser
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://www.google.com/', {waitUntil: 'networkidle2'});

    browser.close();

})();
  1. if you got page crash with BUS_ADRERR (chromium issue), increase shm-size on docker run with --shm-size argument
docker run --shm-size 1G --rm -v <path_to_script>:/app/index.js starlocke/puppeteer-full-noto:latest
  1. If you're seeing random navigation errors (unreachable url) it's likely due to ipv6 being enabled in docker. Navigation errors are caused by ERR_NETWORK_CHANGED (-21) in chromium. Disable ipv6 in your container using --sysctl net.ipv6.conf.all.disable_ipv6=1 to fix:
docker run --shm-size 1G --sysctl net.ipv6.conf.all.disable_ipv6=1 --rm -v <path_to_script>:/app/index.js starlocke/puppeteer-full-noto:latest
  1. add --enable-logging for chrome debug logging http://www.chromium.org/for-testers/enable-logging
const puppeteer = require('puppeteer');

(async() => {

    const browser = await puppeteer.launch({args: [
        '--no-sandbox',
        '--disable-setuid-sandbox',

        // debug logging
        '--enable-logging', '--v=1'
    ]});

usage

mount your script to /app/index.js

docker run --shm-size 1G --rm -v <path_to_script>:/app/index.js starlocke/puppeteer-full-noto:latest

custom script from dir

docker run --shm-size 1G --rm \
 -v <path_to_dir>:/app \
 starlocke/puppeteer-full-noto:latest \
 node my_script.js

screenshots tools

simple screenshot tools in image

docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
 starlocke/puppeteer-full-noto:latest \
 <screenshot,full_screenshot,screenshot_series,full_screenshot_series> 'https://www.google.com' 1366x768

screenshot tools syntax

<tool> <url> <width>x<height> [<delay_in_ms>]

  • delay_in_ms: is optional (defaults to 0)
    • Waits for delay_in_ms milliseconds before taking the screenshot

screenshot

docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
 starlocke/puppeteer-full-noto:latest \
 screenshot 'https://www.google.com' 1366x768

output: one line json

{
    "date":"2017-09-01T05:03:27.464Z",
    "timestamp":1504242207,
    "filename":"screenshot_1366_768.png",
    "width":1366,
    "height":768
}

got screenshot in /tmp/screenshots/screenshot_1366_768.png

full_screenshot

save full screenshot of page

docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
 starlocke/puppeteer-full-noto:latest \
 full_screenshot 'https://www.google.com' 1366x768

screenshot_series, full_screenshot_series

adds datetime in ISO format into filename

useful for cron screenshots

docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
 starlocke/puppeteer-full-noto:latest \
 screenshot_series 'https://www.google.com' 1366x768
docker run --shm-size 1G --rm -v /tmp/screenshots:/screenshots \
 starlocke/puppeteer-full-noto:latest \
 full_screenshot_series 'https://www.google.com' 1366x768
2017-09-01T05:08:55.027Z_screenshot_1366_768.png
# OR
2017-09-01T05:08:55.027Z_full_screenshot_1366_768.png

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.