1.2.1 • Published 6 years ago

kaerukun v1.2.1

Weekly downloads
6
License
MIT
Repository
github
Last release
6 years ago

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'
    ]
  }
}
1.2.1

6 years ago

1.2.0

6 years ago

1.1.0

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.1.0

6 years ago

0.0.1

6 years ago