Socket
Book a DemoInstallSign in
Socket

hacker-news-parser

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

hacker-news-parser

parser for hacker news comments

latest
Source
npmnpm
Version
0.0.2
Version published
Maintainers
1
Created
Source

#hacker-news-parser

Parses the insanely shitty html of hacker news comments into json

Build Status

example


var hn = require('hacker-news-parser');
request("https://news.ycombinator.com/item?id=4992617", function(err, res) {
  if(err) throw err;
  var content = hn.parse(res.body);
  console.log(content.comments);
});

api

hn.parse(html)

parses the html of a hacker news post returns:

var result = {
  comments: [comment], /*array of Comment objects*/
  more: moreLink /*MoreLink object - null if there is no next page*/
}

note: moreLink will be null if there is no 'more' link at the bottom

Comment

represents a single comment, accessible via the result returned from hn.parse

var comment = {
  body: /*raw html body of the comment*/
  date: /*date object (UTC) of when the comment was posted*/
  href: /*the uri to the comment*/
  comments: [] /*array of child Comments*/
}

represents a link to the next page (if there is a next page), accessible via the result returned from hn.parse

var moreLink = {
  href: /*the uri to the next page of comments*/
}

why?

Because hacker news has no public API, and the other modules did too much and/or didn't have test suites.

Keywords

hacker

FAQs

Package last updated on 17 Jan 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts