platypush/platypush/plugins/http/webpage/mercury-parser.js
Fabio Manganiello 5293f5b203 : Implemented wrapper plugin for the new Node.js mercury-parser.
As the Mercury reader web API is deprecated, and the only available
implementation is the open source mercury-parser, node, npm and
@postlight/mercury-parser have to be added as dependencies for the
http.webpage plugin (or at least for the `simplify` action).
2019-07-24 19:02:53 +02:00

20 lines
524 B
JavaScript
Executable file

#!node
// This script will parse the content and title of a webpage using the
// mercury-parser JavaScript library (https://github.com/postlight/mercury-parser)
// and print a JSON object with the extracted information.
'use strict';
const parser = require('@postlight/mercury-parser');
if (process.argv.length < 3) {
console.error('Usage: ' + process.argv[1] + ' <url to parse>');
process.exit(1);
}
const url = process.argv[2];
parser.parse(url).then(result => {
console.log(JSON.stringify(result));
});