hnindex

0.1.2 • Public • Published

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

Readme

Keywords

none

Package Sidebar

Install

npm i hnindex

Weekly Downloads

3

Version

0.1.2

License

MIT

Last publish

Collaborators

  • tonyskn