Library for Nodejs that retrieve the DOM and global vars from a remote html page.
Licensed under the MIT license.
Copyright Stefano Cudini
$ npm install -g @stefcud/fetch-dom
run command
page url and global variable name
$ fetchdom https://opengeo.tech/index.html allTags
$ npm install --save fetch-dom
application code
var fetchdom = require('@stefcud/fetch-dom');
/*
by default return the window object
*/
fetchdom('https://opengeo.tech/', function(window) {
console.log(window.document.body);
});
/*
specify sub property of default DOM
*/
fetchdom('https://opengeo.tech/', 'location.href', function(href) {
console.log(href);
});
/*
parsing of global remote variables (in remote page is defined window.allTags = {...}; )
*/
fetchdom('https://opengeo.tech/', 'allTags', function(tags) {
console.log(tags);
});