npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

node-nutch

v0.4.2

Published

A set of Gulp commands that provide similar functionality to Apache Nutch.

Downloads

7

Readme

node-nutch

A set of Gulp commands that provide similar functionality to Apache Nutch.

Whilst Nutch was used for inspiration, as things have developed the reasons for following Nutch patterns have become fewer and fewer, so a lot will probably change; at some point this project will be factored so that it becomes a set of sifttt recipes.

Concepts

Design

The Nutch Model

Nutch is designed to have a number of tasks that can be run in a self-contained way, and the status of the tasks stored centrally. This makes it possible to run many servers, each running different parts of the pipeline, at different stages.

Other Node Crawlers

There are lots of Node crawlers but generally they retrieve documents and then process those documents all in one step. This makes it difficult to scale them, which is why we've followed Nutch's model. bot-marvin is an honurable exception, but seems too closely integrated with MongoDB at the moment.

Some Node crawlers can be enhanced by adding extra pipelines (such as roboto) but we feel that there is already a well established pipeline model in the Node eco-system, based on Vinyl files and Gulp streams, so we have decided to integrate with that.

CrawlBase

Crawled files and their status are stored in a CrawlBase which eventually could be located anywhere that can be a Gulp destination. So far the targets that have been used reliably are the file system (via Gulp) and S3, but in principle the CrawlBase could be located in a relational database, ElasticSearch, or whatever.

The path to the CrawlBase defaults to crawl/Crawlbase, and can be set with the environment variable CRAWLBASE.

Status

Each command does its work and then sets some indication of status in the status file. This is then used by subsequent commands to determine what needs doing.

Commands

E.g.:

gulp inject

clean:CrawlBase

Completely deletes the crawl database.

inject

Inject some URLs into the crawl database, ready for crawling. The list of URLs to inject will come from files in the seeds directory. All files are read and each line in the file is processed, so there can be as many or few files as needed. Any line that begins with a '#' is ignored.

generate

To indicate that a URL is ready to be fetched, run generate. At the moment this will cause all URLs to be made candidates for fetching, but in the future this may become more refined, and a subset of the URLs could be chosen.

fetch

The fetch command will retrieve all URLs and update the status with the return code, headers and of course the body of the document retrieved.

parse

The parse command will process the retrieved document and convert it to the desired format.

extract

Sometimes only a part of a document is required, particularly if an API is being crawled. The extract command will convert the parse document to some further document.

process

The commands above are used to handle the crawling and recrawling, but the process command is used to do any basic processing with the extracted data, ready to be used by some other processor.

dbupdate:status

The dbupdate:status command will update various values in the CrawlBase status. For example, it might set the time for the next fetch based on whether the document changed last time it was fetched, and so cause pages that aren't changing very often to be examined less frequently than others.

dbupdate:outlinks

A web page or an API might refer to other pages from which more data can be retrieved. The dbupdate:outlinks command is used to extract these further links depending on settings such as how deep to crawl, whether to bring in links that point outside of the initial website, etc.

Usage

In your gulpfile:

const gulp = require('gulp');
const nodeNutch = require('node-nutch');

Then, if using the filesystem as a CrawlBase:

nodeNutch.addTasks(gulp, undefined, customExtract, customProcess);

Alternatively, if using S3 as a CrawlBase:

const s3 = require('vinyl-s3');

s3.exists = function(glob, cb){
  var exists = false;

  this.src(glob)
    .on('data', function(){
      exists = true;
    })
    .on('end', function(){
      cb(exists);
    });
};

nodeNutch.addTasks(gulp, s3, customExtract, customProcess);