Skip to content

Instantly share code, notes, and snippets.

@fb55
Created August 28, 2011 10:18
Show Gist options
  • Save fb55/1176506 to your computer and use it in GitHub Desktop.
Save fb55/1176506 to your computer and use it in GitHub Desktop.
Test of event module for htmlparser
/*
Dependencies:
* Request (npm install request)
* readabilitySAX (npm install readabilitySAX)
* my htmlparser fork (https://github.com/FB55/node-htmlparser)
*/
var request = require("request"),
readability = require("./readabilitySAX");
Parser = require("node-htmlparser/lib/Parser.js"),
EventedHandler = require("node-htmlparser/lib/EventedHandler.js");
var cbs = {},
readable = readability.process(cbs, {}),
handler = new EventedHandler(cbs),
parser = new Parser(handler);
request("http://addyosmani.com/blog/lessons-from-a-javascript-code-review/")
.on("data", function(data){ parser.parseChunk(data.toString()); })
.on("end", function(){
console.log(readable.getArticle());
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment