fetch-dom

Library for Nodejs that retrieve the DOM and global vars from a remote html page.

npm version

Licensed under the MIT license.

Copyright Stefano Cudini

Source code

Github
NPM

Usage

Install in command line

$ npm install -g @stefcud/fetch-dom

run command
page url and global variable name

$ fetchdom https://opengeo.tech/index.html allTags

Integrate in your application

$ 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);

});