Code Monkey home page Code Monkey logo

kaerukun's Introduction

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

kaerukun's People

Contributors

pastak avatar

Stargazers

Devyn Spencer avatar Ryoji Miyazato avatar Takuma HANATANI avatar TAMADA Akihiro avatar AMAGI / Jun Yuri avatar ใใ‚‹ใใ‚‹ avatar  avatar Kevin Segal avatar hitode909 avatar  avatar Masayoshi Wada avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.