Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/PaulKinlan/puppeteer-go
Simple utility to help quickly script puppeteer programs
https://github.com/PaulKinlan/puppeteer-go
Last synced: 3 months ago
JSON representation
Simple utility to help quickly script puppeteer programs
- Host: GitHub
- URL: https://github.com/PaulKinlan/puppeteer-go
- Owner: PaulKinlan
- Created: 2019-11-29T10:19:09.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2022-07-21T19:32:54.000Z (over 2 years ago)
- Last Synced: 2024-07-07T22:23:25.974Z (4 months ago)
- Language: JavaScript
- Homepage: https://paul.kinlan.me/puppeteer-go/
- Size: 22.5 KB
- Stars: 86
- Watchers: 3
- Forks: 5
- Open Issues: 3
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
- awesome-list - puppeteer-go
README
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`
2. Include
`const {go} = require('puppeteer-go');`
3. Use
``` JavaScript
/*
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
```JavaScript
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);
}
}
});
```