JS

NODEJS WEB SCRAPER

(a simple example)

<div id="product">   <img src="box.png" id="pImg">   <div id="pName">Empty Box</div>   <div id="pPrice">$12.34</div>   <div id="pDesc">It's an empty box.</div>    <input type="button" value="Add To Cart"                 id="pAdd"> </div>

DUMMY PRODUCT PAGE

01

02

LOAD JSDOM const jsdom = require("jsdom"); const { JSDOM } = jsdom;

NODEJS WEB SCAPER

FETCH HTML & EXTRACT DATA fetch("http://site.com/dummy.html") .then(res => res.text()).then(txt => {   const dom = new JSDOM(txt);   const doc = dom.window.document;   console.log(doc.getElementById   ("pName").innerHTML);   console.log(doc.getElementById   ("pPrice").innerHTML);   console.log(doc.getElementById   ("pDesc").innerHTML);   console.log(doc.getElementById   ("pImg").src); });