Skip to content

Instantly share code, notes, and snippets.

@buley
Created January 28, 2019 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save buley/f93a5e9fcf4a47a539a4e2b90c67b324 to your computer and use it in GitHub Desktop.
Save buley/f93a5e9fcf4a47a539a4e2b90c67b324 to your computer and use it in GitHub Desktop.
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