0

Hey I'm trying to access global variables from the result of a HTML request in node. I can currently access the nodes using the cheerio module however I'm stumped as to how I can access a global page variable ?

request(options, function(error, response, html) {

 if (!error && response.statusCode == 200) {

  var productData = {};

  // access html with JQUERY
  var $ = cheerio.load(html);

  // is it possible to access global 
    // page variables here ?
    
 }
}
  • What do you mean with page variables? [Cheerio is not a web browser](https://github.com/cheeriojs/cheerio#cheerio-is-not-a-web-browser): "It does not interpret the result as a web browser does. Specifically, it does not produce a visual rendering, apply CSS, load external resources, or execute JavaScript." – Álvaro González May 30 '17 at 15:44

1 Answers1

0

Cheerio does not have access to the browser's java script global variables. It can only parse the html page's DOM structure.

See other answer as source:

How can I use Node / Cheerio (or something else) to scrape a global variable from a site?

Peter Hauge
  • 705
  • 6
  • 15