I am new to JavaScript and am pretty sure I am missing something fundamental in using JSfrom a HTML page (to be browsed by a web browser).
My goal is to scrap photo links from a dynamic website using cheerio and display them in a js gadget (e.g., using lightslider), it looks quite successful following this tutorial to obtain the following script and run it by simply nodejs scrapt.js in a bash terminal:
var request = require('request');
var cheerio = require('cheerio');
request('https://outbox.eait.uq.edu.au/uqczhan2/Photos/', function (error, respo
if (!error && response.statusCode == 200) {
console.log(html);
}
});
But now I am not able to run this script in a general webbrowser (by pressing f12 -> console), as error shows after the first syntax:
>var request = require('request');
VM85:1 Uncaught ReferenceError: require is not defined
at <anonymous>:1:15
I understood some JavaScript modules is required to be loaded before using them, for example for d3.js. i need to run:
<script src="https://d3js.org/d3.v4.min.js"></script>
to use all the d3 function. how should I achieve the same thing that would allow me to use cheerio in a web browser?