Grab the resource contents in CasperJS or PhantomJS

casperjs, phantomjs

Solution

Did not realize I could grab the source from the document object like this:

casper.start(url, function() {
    var js = this.evaluate(function() {
        return document; 
    }); 
    this.echo(js.all[0].outerHTML); 
});

More info here.

Problem

I see that CasperJS has a "download" function and an "on resource received" callback but I do not see the contents of a resource in the callback, and I don't want to download the resource to the filesystem. I want to grab the contents of the resource so that I can do something with it in my script. Is this possible with CasperJS or PhantomJS?

Original source

Related problems