Socket
Book a DemoInstallSign in
Socket

bauer-crawler

Package Overview
Dependencies
Maintainers
1
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bauer-crawler

Multi-thread crawler engine.

0.2.9
latest
Source
npmnpm
Version published
Weekly downloads
3
Maintainers
1
Weekly downloads
 
Created
Source

bauer-crawler

Multi-process task runner.

Installation

npm install bauer-crawler

Usage

var Crawler = require("bauer-crawler");

var myCrawler = new Crawler({
  
  // plugins to be loaded
  plugins: [
    "bauer-plugin-fetch",
    "bauer-plugin-scrape"
  ],
  
  // configurations for each plugin
  config: {
    fetch: {
      workers: 2,
      cache: {
        dir: "./http-cache",
        expires: "1d"
      }
    },
    scrape: {
      workers: 1,
      cache: {
        dir: "./scraper-output",
        expires: "1d"
      }
    }
  }
});

// starts the cluster application
myCrawler.start(function(promise) {
  
  // when returned promise is resolved process exits
  return promise
    .fetch("http://http-bin.org")
    .scrape({
      "a[href]": {
        urls: "attr:href"
      }
    });
});

API Summary

  • Crawler

    • new Crawler(options Object) :Crawler
    • .require(module String) :Object
    • .setupConfig(config Object) :void
    • .setupConfig(file String) :void
    • .setupCluster() :void
    • .setupCluster(cluster Cluster) :void
    • .setupCrawler(options Object) :void
    • .loadPlugin(plugins Array) :void
    • .loadPlugin(plugin String) :void
    • .loadPlugin(plugin Object) :void
    • .wrapCallback(module String) :Function
    • .wrapCallback(callback Function) :Function
    • .getWorkerRoleMap() :Object
    • .createWorkers() :void
    • .requestWorker(role String, request Object) :Promise
    • .wrapPromise(module String) :void
    • .wrapPromise(callback Function) :void
    • .wrapPromise(promise Promise, callback Function) :void
    • .start(main Function) :void
    • .setRepeat(repeat Boolean) :void
    • .getRepeat() :Boolean
  • Response

    • .sendOk() :void
    • .sendOk(data Object) :void
    • .sendError(error Error) :void
  • Worker

    • .sendReady() :void
  • Promise

    • .requestWorker(role String, request Object) :Promise
    • .repeat() :Promise
    • .repeat(repeat Boolean) :Promise
    • .time(callback Function) :Promise
    • .print() :Promise
    • .print(text String) :Promise
    • .print(array Array) :Promise
    • .print(object Object) :Promise
    • .print(anything) :Promise
    • .exit() :Promise

License

MIT

Keywords

multi-thread

FAQs

Package last updated on 16 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.