hnindex

HackerNews scraper for Node.js

npm install hnindex
7 downloads in the last week
8 downloads in the last month

HNIndex

Build Status Coverage Status

Very simple HackerNews scraper for Node.js

Installation

npm install hnindex

Usage

var HN = require('hnindex');

var template = (function(i) {
    return function(entries) {
       return entries.map(function(entry) {
          return i++ + "> " + entry.title +
                   " [" + entry.url + "] " +
                   " by (" + entry.owner + ") " +
                   entry.hnThreadId + " | " + entry.score + "/" + entry.commentScore;
       });
    };
})(1);


HN.popular( function(err, results) {
   console.log( template(results.entries) );

   results.more( function(err, moreResults) {
      console.log( template(moreResults.entries) );
   } );
} );

API

// Parses links from /news
HN.popular(function(err, result) { 
    // do something with result.entries

    result.more( function(err, moreResult) { ... } );
});

// Parses links from /newest
HN.newest( function(err, results) { ... } );

// Parses links from /ask
HN.ask( function(err, results) { ... } );
npm loves you