forked from platypush/platypush
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).
20 lines
524 B
JavaScript
Executable file
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));
|
|
});
|
|
|