Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/stefanocudini/node-fetch-dom
- Owner: stefanocudini
- License: mit
- Created: 2018-10-12T10:33:30.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2023-05-02T10:16:20.000Z (over 1 year ago)
- Last Synced: 2024-10-03T08:56:38.108Z (about 1 month ago)
- Topics: crawler, dom, nodejs, scraping, webscraping
- Language: HTML
- Homepage: https://opengeo.tech/node-fetch-dom/
- Size: 29.3 KB
- Stars: 12
- Watchers: 1
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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**
```htmlvar 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
```javascriptvar 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);
});
```