Very simple Hacker News scraper for Node.js
JavaScript
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
coverage
example
src
test
.gitignore
.npmignore
.travis.yml
Gruntfile.js
Readme.md
index.js
package.json

Readme.md

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