Is there a command line tool that allows you to get the text of the JavaScript interpreted source of a web page similar to how you can see the interpreted code in FireBug on FireFox?
I would like to use CURL or similar tool to request a web page. The catch is I would like to view how the code has been modified by JavaScript. For instance if the dom has been changed or an element has been modified, I would like to see the modified version. I know FireBug does this for FireFox, but I am looking for a way to script the process.
For most browsers, to view inline JavaScript in the HTML source code, do one of the following. Press the Ctrl + U keyboard shortcut. Right-click an empty area on the web page and select the View page source or similar option in the pop-up menu.
To run the REPL, just type node at the command line. You'll see a new prompt appear—this time, a > instead of a $ . As long as the prompt is > , you can type Javascript expressions and see what they evaluate to (sort of like a calculator). To exit the REPL, type .
In contrast, JavaScript has no compilation step. Instead, an interpreter in the browser reads over the JavaScript code, interprets each line, and runs it. More modern browsers use a technology known as Just-In-Time (JIT) compilation, which compiles JavaScript to executable bytecode just as it is about to run.
Have you looked in to tools like PhantomJS for running the tests? Many of them support running a "headless" browser, which lets you render pages and run JS against the rendered page without having to actually run a browser. It doesn't use curl
, but I don't see why that should be a requirement.
For instance:
$ phantomjs save_page.js http://example.com
with save_page.js:
var system = require('system');
var page = require('webpage').create();
page.open(system.args[1], function()
{
console.log(page.content);
phantom.exit();
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With