Skip to content
Simple utility to help quickly script puppeteer programs
JavaScript
Branch: master
Clone or download
Latest commit 7770952 Dec 2, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.gitignore First commit and launch of Puppeteer Go Nov 29, 2019
README.md First commit and launch of Puppeteer Go Nov 29, 2019
index.js First commit and launch of Puppeteer Go Nov 29, 2019
package-lock.json First commit and launch of Puppeteer Go Nov 29, 2019
package.json Fixing deps Dec 2, 2019

README.md

Puppeteer Go

Just a simple API to script puppeteer, all it does is load a URL and then let you run a function against the page once it has loaded.

That is all.

Usage

  1. Install

npm i puppeteer-go

  1. Include

const {go} = require('puppeteer-go');

  1. Use
/*
 page - the Page instance returned from puppeteer
 browser - the Browser instance returned from puppeteer

*/
const callback = (page, browser) { ... };

go(url, callback)

Why does this exist?

I like building little scripts to automate actions on the we with puppeeteer but I kept forgetting the stanza to start a session, browser to a page ... that and my fingers kept getting tired.

Examples

  1. Screenshotting elements on a page
const {go} = require('puppeteer-go');

go('https://paul.kinlan.me', async (page) => {
    const elements = await page.$$("h1");
    let count = 0;
    for(let element of elements) {
      try {
        await element.screenshot({ path: `${count++}.png`});
      } catch (err) {
        console.log(count, err);
      }
    }
});
You can’t perform that action at this time.