kaerukun

1.2.1 • Public • Published

kaerukun 🐸

Build Status NPM

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

  1. Install 🐸 to your project.
  • $ npm i -D puppeteer kaerukun
    • Require puppeteer@^1.0.0 as peerDependencies.
  1. Put config file kaerukun.config.js on your project root.
  2. $ ./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 and b then group a will execute on https://example.com/foo and https://example.com/bar, group b will execute on https://example.com/bar.
      • Group a tasks is ./tasks/a/*.js
      • Group b tasks is ./tasks/b/*.js
      • ./tasks/*.js will execute on all urls.
  • puppeteer <Object> (optional): Object passed to puppeteer.launch
    • default value is {args: ['--no-sandbox', '--disable-setuid-sandbox']}
  • concurrent <Number> (optional): Number of opening tab concurrently.
    • default: 5
{
  tasks: './tasks',
  urls: {
    'a': [
      'https://example.com/foo',
      'https://example.com/bar'
    ],
    'b': [
      'https://example.com/bar'
    ]
  }
}

Readme

Keywords

Package Sidebar

Install

npm i kaerukun

Weekly Downloads

1

Version

1.2.1

License

MIT

Unpacked Size

9.52 kB

Total Files

8

Last publish

Collaborators

  • pastak