Error during parse | TypeError: Cannot read properties of null
bradonomics opened this issue · comments
I'm getting the below error when parsing articles on coryzue.com.
TypeError: Cannot read properties of null (reading 'content')
at app/lib/readability.js:11:25
at Object.readFileAfterClose (node:internal/fs/read_file_context:68:3)
at tick (node:internal/fs/read_file_context:115:9)
at processTicksAndRejections (node:internal/process/task_queues:82:21)
The app/lib/readability.js file above looks like this:
var fs = require('fs');
var { Readability } = require('@mozilla/readability');
var JSDOM = require('jsdom').JSDOM;
try {
fs.readFile(0, 'utf8', function(err, data) {
if (err) throw err;
var doc = new JSDOM(data, { url: process.argv.slice(2) });
var article = new Readability(doc.window.document).parse();
console.log(article.content);
});
} catch (error) {
console.log(error instanceof TypeError);
}