title: Webpage's HTML using Phantom
body: <p>I am trying to use PhantomJS to load a page (that uses Javascript to load items on the webpage) and returns all the HTML on the page (at least within the <code>&lt;body /&gt;</code> tags) to the PHP function that executes <code>phantomjs httpget.js</code>.</p>
  
  <p><strong>Problem:</strong> I can get phantomjs to return the <code>document.title</code>, but asking it to <code>console.log(document.body)</code> simple gives me a <code>[object Object]</code>. How can I extract the page's HTML?</p>
  
  <p><em>It also takes much longer to load the webpage using phantomjs compared to the browser</em>.</p>
  
  <p><strong>httpget.js</strong></p>
  
  <pre><code>console.log('hello!');
  var page = require('webpage').create();
  page.open("http://www.asos.com/Men/T-Shirts-Vests/Cat/pgecategory.aspx?cid=7616#parentID=-1&amp;pge=0&amp;pgeSize=900&amp;sort=1",
      function(status){
          console.log('Page title is ' + page.evaluate(function () {
              return document.body;
          }));
          phantom.exit();
      });
  </code></pre>
  
  <p><strong>Output</strong> <em>(running from shell)</em></p>
  
  <pre><code>hello!
  Page title is [object Object]
  </code></pre>