I am trying to send a request to a page and grab the entire DOM. Basically a crawl. On this website, there is a variable loaded directly into the HTML (not a script file) with some data. Using my NodeJS backend, which I use request with, how would I request this page and return the variable's data? Here's an example:
http://some-page.com/index.html
<html>
<head>
<script>
var my_var = {
title: "Good title",
description: "Nice description",
page: 5
};
</script>
</head>
</html>
If I visit the website, open the console and type in my_var I can see the content in the console, so it's a global variable.
How can I do something like this? I can use another request library if that is needed.
eval(body.match(/<script>.*<\/script>/).join('\n'))where body is the third parameter of the callback (per the example in the repo's readme).