Skip to content

PaulKinlan/puppeteer-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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 web with puppeteer but I kept forgetting the stanza to start a session, browser to a page ... that and my fingers kept getting tired.

Examples

  1. Screen shotting 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);
      }
    }
});

About

Simple utility to help quickly script puppeteer programs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published