Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/stefanocudini/node-fetch-dom

Magic utility that extract javascript global variables from a remote html page.
https://github.com/stefanocudini/node-fetch-dom

crawler dom nodejs scraping webscraping

Last synced: 18 days ago
JSON representation

Magic utility that extract javascript global variables from a remote html page.

Awesome Lists containing this project

README

        

# fetch-dom
Magic utility that extract javascript global variables from a remote html page.

[![npm version](https://badge.fury.io/js/node-fetch-dom.svg)](https://badge.fury.io/js/node-fetch-dom)

*Licensed under the MIT license.*

*Copyright [Stefano Cudini](https://opengeo.tech/stefano-cudini/)*

## Source code
[Github](https://github.com/stefanocudini/node-fetch-dom)
[NPM](https://npmjs.org/package/fetch-dom)

# Usage
## Install in command line

```bash
$ npm install -g @stefcud/fetch-dom
```
**run command**
parameters is a url page and a global variable name
```bash
$ fetchdom https://opengeo.tech/index.html allTags
```
the output is a json

**html in remote page**
```html

var allTags = {"ajax":0,"bash":0,"bootstrap":0,"crawler":0,"css3":0,"cv":0,"debian":0,"developer":0,"dom":0,"fetch":0,"geojson":0,"geosocial":0,"gis":0,"gps":0,"gpx":0,"gruntjs":0, ....

```

## Usage
```bash
$ npm install --save fetch-dom
```

## Integrate in your code
```javascript

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

});
```