-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.html
47 lines (39 loc) · 1.73 KB
/
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
<h1 id="fetch-dom">fetch-dom</h1>
<p>Library for Nodejs that retrieve the DOM and global vars from a remote html page.</p>
<p><a href="https://badge.fury.io/js/node-fetch-dom"><img src="https://badge.fury.io/js/node-fetch-dom.svg" alt="npm version"></a></p>
<p><em>Licensed under the MIT license.</em></p>
<p><em>Copyright <a href="https://opengeo.tech/stefano-cudini/">Stefano Cudini</a></em></p>
<h2 id="source-code">Source code</h2>
<p><a href="https://github.com/stefanocudini/node-fetch-dom" class="github-fork-ribbon" data-ribbon="Fork me on GitHub">Github</a><br><a href="https://npmjs.org/package/fetch-dom">NPM</a></p>
<h1 id="usage">Usage</h1>
<h2 id="install-in-command-line">Install in command line</h2>
<pre><code class="lang-bash">$ npm install -g @stefcud/fetch-dom
</code></pre>
<p><strong>run command</strong><br>page url and global variable name</p>
<pre><code class="lang-bash">$ fetchdom https://opengeo.tech/index.html allTags
</code></pre>
<h2 id="integrate-in-your-application">Integrate in your application</h2>
<pre><code class="lang-bash">$ npm install --save fetch-dom
</code></pre>
<p><strong>application code</strong></p>
<pre><code class="lang-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);
});
</code></pre>