title: Site scraping: Waiting until site is completly loaded
body: <p>I need to download the following webpage: <a href="http://m.10bet.com/#leage_panel#10096" rel="noreferrer">http://m.10bet.com/#leage_panel#10096</a></p>
  
  <p>It is a sportsbetting page and I need the quotes. So, in the first place this seems pretty simple. However, here is what happens (you can check this with eg. developer tools of your browser):</p>
  
  <ol>
  <li>Open the URL</li>
  <li>The page loads an initial HTML that subsequently invokes an ajax request to retrieve the quotes</li>
  <li>However, the quote are contained in json BUT they are obfruscated such that it is not possible to simply parse them directly from the ajax call. Additionally the javascript of the webpage is obfruscated as well. So no chance to directly read the quotes from the request. </li>
  </ol>
  
  <p>Instead, I will need to use a headless browser capable of evaluating javascript. HtmlUnit for java is inadequate since it does not offer robust javascript functionality. Therefore PhantomJS in combination with CasperJS is my current choice. I apply CasperJS with the following script: </p>
  
  <pre><code>var casper = require('casper').create();
  
  casper.start('http://m.10bet.com/#leage_panel#10096', function() {
      var url = 'http://m.10bet.com/#leage_panel#10096';
      this.download(url, '10bet.html');
  });
  
  casper.run(function() {
      this.echo('Done.').exit();
  });
  </code></pre>
  
  <p>However, this script does not load the complete page. Just the inital page. How do I load the complete webpage as it is presented in the browser?</p>