Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Readability - docs example fixed
var Readability = require('Readability');
var JSDOM = require('jsdom').JSDOM;
var doc = new JSDOM("<body>Here's a bunch of text</body>", {
url: "https://www.example.com/the-page-i-got-the-source-from",
});
let reader = new Readability(doc.window.document);
let article = reader.parse();
console.log(article);
@buley
Copy link
Author

buley commented Jan 28, 2019

(master)⚡ % node fixed.js                      ~/Documents/Code/birch/api/test
{ title: '',
  byline: null,
  dir: null,
  content:
   '<div id="readability-page-1" class="page">Here\'s a bunch of text</div>',
  textContent: 'Here\'s a bunch of text',
  length: 22,
  excerpt: undefined,
  siteName: null }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment