kaerukun
v1.2.1
Published
kaerukun 🐸 will associate urls and tasks for puppeteer.
Downloads
12
Readme
kaerukun 🐸
kaerukun 🐸 will associate urls and tasks for puppeteer.
Example
kaerukun.config.js
module.exports = () => {
return {
tasks: './tasks',
urls: [
'http://example.com/foo',
'http://example.com/bar'
]
};
};
tasks/example.js
module.exports = async (page) => {
const titleAndUrl = await page.evaluate(() => [document.title, location.href])
console.log(...titleAndUrl)
}
will output
Example Domain http://example.com/foo
Example Domain http://example.com/bar
1st argument is class: Page of puppeteer.
Usage
- Install 🐸 to your project.
$ npm i -D puppeteer kaerukun
- Require
puppeteer@^1.0.0
as peerDependencies.
- Require
- Put config file
kaerukun.config.js
on your project root. $ ./node_modules/.bin/kaerukun
Node API
require('kaerukun')({config: './kaerukun.config.js'});
Options
config
: Config file path.silent
: Disable output.
Configuration
Options
tasks <String>
: Directory path includes tasks js file.urls <String[] | Object>
: URLs to execute tasks.- You can make group of tasks, for example you make task-groups
a
andb
then groupa
will execute onhttps://example.com/foo
andhttps://example.com/bar
, groupb
will execute onhttps://example.com/bar
.Group a tasks
is./tasks/a/*.js
Group b tasks
is./tasks/b/*.js
./tasks/*.js
will execute on all urls.
- You can make group of tasks, for example you make task-groups
puppeteer <Object>
(optional): Object passed topuppeteer.launch
- default value is
{args: ['--no-sandbox', '--disable-setuid-sandbox']}
- default value is
concurrent <Number>
(optional): Number of opening tab concurrently.- default:
5
- default:
{
tasks: './tasks',
urls: {
'a': [
'https://example.com/foo',
'https://example.com/bar'
],
'b': [
'https://example.com/bar'
]
}
}