If you use PhantomJS http://phantomjs.org/ you can simply access these variables as you would from within the webpage, with JavaScript. A very simple example is as follows:
//where url is the page that contains these variables.
page.open(url, function (status) {
//Page is loaded!
var dataFromPage = page.evaluate(function(){
return {
metrics_level2:metrics_level2,
metrics_level3:metrics_level3,
metrics_level4:metrics_level4
};
});
//dataFromPage now contains those variables
phantom.exit();
});
If you already have your webpages scraped and saved off to html files or something, you could just set the content of the page object using the content
method as appose to opening the page as seen above. See http://phantomjs.org/api/webpage/property/content.html