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 http://labs.easyblog.it/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('http://labs.easyblog.it/', function(window) {

    console.log(window.document.body);
});

/*
  specify sub property of default DOM
*/
fetchdom('http://labs.easyblog.it/', 'location.href', function(href) {

    console.log(href);

});

/*
  parsing of global remote variables (in remote page is defined window.allTags = {...}; )
*/
fetchdom('http://labs.easyblog.it/', 'allTags', function(tags) {

    console.log(tags);

});