Skip to content

Instantly share code, notes, and snippets.

@buley
Created January 28, 2019 18:43
Show Gist options
  • Save buley/6fe57bca09d8c469425b771866633021 to your computer and use it in GitHub Desktop.
Save buley/6fe57bca09d8c469425b771866633021 to your computer and use it in GitHub Desktop.
Readability - docs example
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);
let article = reader.parse();
@buley
Copy link
Author

buley commented Jan 28, 2019

/Users/buley/Documents/Code/birch/api/node_modules/Readability/Readability.js:34
    throw new Error("First argument to Readability constructor should be a document object.");
    ^

Error: First argument to Readability constructor should be a document object.
    at new Readability (/Users/buley/Documents/Code/birch/api/node_modules/Readability/Readability.js:34:11)
    at Object.<anonymous> (/Users/buley/Documents/Code/birch/api/test/readability.js:6:14)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:743:3)

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