title: Get html rendered by Javascript using PhantomJS
body: <p>I am trying to utilize PhantomJS to get html generated by dynamic page. I supposed that this would be easy, but after few hours of trying, I am still not lucky.</p>
  
  <p>The page itself has this source code and what gets saved in 1.html eventually:</p>
  
  <pre><code>&lt;!doctype html&gt;
  &lt;html lang="cs" ng-app="appId"&gt;
  &lt;head ng-controller="MainCtrl"&gt;
       (ommited some lines)
      &lt;script src="/js/conf/config.js?pars"&gt;&lt;/script&gt;
      &lt;script src="/js/all.js?pars"&gt;&lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;!--&lt;![endif]--&gt;
      &lt;div site-loader&gt;&lt;/div&gt;
      &lt;div page-layout&gt;
          &lt;div ng-view&gt;&lt;/div&gt;
      &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>All content of web gets loaded inside site-loader div, but I have no luck to get it, even though I am using timeout before scraping html by PhantomJS. Here goes code I am using:</p>
  
  <pre><code>var url = 'http:...';
  var page = require('webpage').create();
  var fs = require('fs');
  
  page.open(url, function (status) {
      if (status !== 'success') {
          console.log('Fail');
          phantom.exit();
      } else {        
          window.setTimeout(function () {
          fs.write('1.html', page.content, 'w');
          phantom.exit();
          }, 2000); // Change timeout as required to allow sufficient time 
      }
  });
  </code></pre>
  
  <p>Please what am I doing wrong?</p>
  
  <p>EDIT:
  I have decided to try PJscrapper framework and configured it to scrappe all contents of div block. All I got was lousy:</p>
  
  <pre><code>["","\n\t\tif (window.DOT) {\n\t\t\tDOT.cfg({service: 'sreality', impress: false});\n\t\t}\n\t","","Loader.load()","",""]
  </code></pre>
  
  <p>Seems that I seriously do not get it and always get code before Loader.load() acts. And obviously, timeout does not solve it.</p>