So I have a piece of HTML that looks something like this:
<html>
<body>
<script>
var foo = {
bar: []
};
</script>
</body>
</html>
And I am trying to use PhantomJS to extract the value of foo.bar. How would I do this? So far I know I would have is structured like this:
var webPage = require('webpage');
var page = webPage.create();
page.open(MY_URL, function(status) {
var foo = page.evaluate(function(){
//gets javascript from the HTML in the response
// and extracts foo from there
});
});
console.log(someVar);
phantom.exit();