1.2.1 • Published 8 years ago
kaerukun v1.2.1
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/bar1st argument is class: Page of puppeteer.
Usage
- Install 🐸 to your project.
$ npm i -D puppeteer kaerukun- Require
puppeteer@^1.0.0as peerDependencies.
- Require
- Put config file
kaerukun.config.json 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
aandbthen groupawill execute onhttps://example.com/fooandhttps://example.com/bar, groupbwill execute onhttps://example.com/bar.Group a tasksis./tasks/a/*.jsGroup b tasksis./tasks/b/*.js./tasks/*.jswill 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'
]
}
}