0.1.2 • Published 10 years ago

hnindex v0.1.2

Weekly downloads
1
License
-
Repository
github
Last release
10 years ago

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) { ... } );