When loading a web page, javascripts are executed to provide info. I want to "load" a page (including executing the javascripts), but instead of getting the html output after that, I want to get the output of one of the executed javascripts. I have the path to the webpage and the script.
This is exactly the same as going to google, loading a page while having dev-tools->console open and viewing a javascript and it's json output. I have the url of the site (e.g. https://example.com) and the url to the javascript I want to output of (e.g. https://example.com/script.js).
If it's possible, I would like to immediatly integrate jq to get the desired value in that json output as the output of the script (so the output of the script should just be the "raw" value of a key in the json output of that javascript).
And I prefer it being done using PhantomJS, however I'm open to other things.
- I need to give the url via an argument. Inside the phantomjs script, the url would be
$1
and the script url $1/script.js
, to say it in bash language.
- The jq "path" (aka .path.to.key) can be set in the script, so that doesn't need to be given via an argument.
- I need to get the output in a variable of a bash script.
So those three points combined would be value=$(phantomjs test.js https://example.com)
Hopefully you can help me. Thanks!