title: How to Fetch ajax loaded website with CasperJS
body: <p>Hello i am trying to get a betting coupon from the web via scraping with casperjs and phantomjs. The page loads via ajax and prints a table with the data .The web site is : <code>https://www.pamestoixima.gr/UK/1/Print#market-group=12924.1&amp;marketgroup-template=EVENTSPERDAY&amp;marketgroup-longlist=1</code>
  The data i'm interested in are lying in the table with the class : 'markets'
  I've tried every code in the internet and i still cant get results. The page is getting scraped but it prints that 'The browser must have javascript enabled'</p>
  <p>My code so far :</p>
  <pre><code>    var casper = require('casper').create();
  casper.start('https://www.pamestoixima.gr/UK/1/Print#market-group=12924.1&amp;marketgroup-template=EVENTSPERDAY&amp;marketgroup-longlist=1', function() {
      this.wait(5000, function() {
          console.log(this.getHTML() );
     });
  });
  casper.run();
  </code></pre>
  <p>And the console output :</p>
  <pre><code>C:\Users\Bampis\Desktop\phantom&gt;casperjs test.js
  &lt;!DOCTYPE html PUBLIC &quot;-//W3C//DTD XHTML 1.0 Strict//EN&quot; &quot;http://www.w3.org/TR/x
  html1/DTD/xhtml1-strict.dtd&quot;&gt;&lt;html lang=&quot;en&quot; xmlns=&quot;http://www.w3.org/1999/xhtml
  &quot; class=&quot;ua-dom ua-strict ua-secure ua-windows ua-likegecko ua-safari ua-webkit&quot;
  &gt;&lt;head&gt;&lt;meta http-equiv=&quot;content-language&quot; value=&quot;en&quot;&gt;
                  &lt;meta http-equiv=&quot;content-type&quot; content=&quot;text/html; charset=utf-
  8&quot;&gt;
                  &lt;title&gt;&lt;/title&gt;
                  &lt;!--meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=10&quot;/--&gt;
                  &lt;link href=&quot;/Areas/Print/template_1_UK/template.css?ts=201504081
  530&quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;screen, tv, projection&quot; charset=&quot;ut
  f-8&quot;&gt;
                  &lt;link href=&quot;/debug.css?ts=201504081530&quot; rel=&quot;stylesheet&quot; type=&quot;t
  ext/css&quot; media=&quot;screen, tv, projection&quot;&gt;
                  &lt;link href=&quot;/Areas/.css/jquery-plugins.css?ts=201504081530&quot; rel=
  &quot;Stylesheet&quot; type=&quot;text/css&quot;&gt;
                  &lt;link href=&quot;/Areas/Print/template_1_UK/print.css?ts=201504081530
  &quot; rel=&quot;stylesheet&quot; type=&quot;text/css&quot; media=&quot;print&quot;&gt;
  
                  &lt;script async=&quot;&quot; src=&quot;//www.google-analytics.com/analytics.js&quot;&gt;&lt;
  /script&gt;&lt;script src=&quot;//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js&quot;
  &gt;&lt;/script&gt;
                  &lt;script type=&quot;text/javascript&quot;&gt;window.jQuery || document.write('
  &lt;script src=&quot;/common/js/jquery/jquery.min.js&quot;&gt;&lt;\/script&gt;');&lt;/script&gt;
                  &lt;script src=&quot;//ajax.googleapis.com/ajax/libs/jqueryui/1.10.1/jqu
  ery-ui.min.js&quot;&gt;&lt;/script&gt;
                  &lt;script type=&quot;text/javascript&quot;&gt;window.jQuery.ui || document.writ
  e('&lt;script src=&quot;/common/js/jquery/jquery-ui.min.js&quot;&gt;&lt;\/script&gt;');&lt;/script&gt;
  
          &lt;script src=&quot;/common/js/jquery/jquery-plugins.js&quot;&gt;&lt;/script&gt;
          &lt;script src=&quot;/common/js/script.js&quot;&gt;&lt;/script&gt;
          &lt;script type=&quot;text/javascript&quot;&gt;
  /*&lt;![CDATA[*/
  if(window.location.search != &quot;&quot; &amp;&amp; window.location.search.indexOf('?debug') == 0
  )
  {
          document.write(unescape(&quot;%3Cscript type='text/javascript' src='/common/j
  s/runtime-debug-201504021456.js'%3E %3C/script%3E&quot;));
          document.write(unescape(&quot;%3Cscript type='text/javascript' src='/Areas/Pr
  int/template_1_UK/components-debug-201504081530.js'%3E %3C/script%3E&quot;));
  }
  else
  {
          document.write(unescape(&quot;%3Cscript type='text/javascript' src='/common/j
  s/runtime-201504021456.js'%3E %3C/script%3E&quot;));
          document.write(unescape(&quot;%3Cscript type='text/javascript' src='/Areas/Pr
  int/template_1_UK/components-201504081530.js'%3E %3C/script%3E&quot;));
  }
  /*]]&gt;*/
  &lt;/script&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;/common/js/runtime-201504021456.js&quot;
  &gt; &lt;/script&gt;&lt;script type=&quot;text/javascript&quot; src=&quot;/Areas/Print/template_1_UK/compon
  ents-201504081530.js&quot;&gt; &lt;/script&gt;&lt;/head&gt;
          &lt;body class=&quot; print col1 lang-UK&quot;&gt;
                  &lt;div class=&quot;c&quot;&gt;
                          &lt;div class=&quot;bg-content clearfix&quot;&gt;
                                  &lt;div class=&quot;cc wrapper clearfix&quot;&gt;
                                          &lt;noscript&gt;
                                                  &amp;lt;div class=&quot;noscriptDiv&quot;&amp;gt;
                                                          &amp;lt;div class=&quot;top&quot;&amp;gt;&amp;
  amp;nbsp;&amp;lt;/div&amp;gt;
                                                          &amp;lt;div class=&quot;middle&quot;&amp;g
  t;
                                                                  &amp;lt;p&amp;gt;Javascr
  ipt is currently not active in your browser. Javascript must be enabled for this
   website.&amp;lt;/p&amp;gt;
                                                                  &amp;lt;p&amp;gt;Javascr
  ipt ╬┤╬╡╬╜ ╬╡╬ψ╬╜╬▒╬╣ ╬╡╬╜╬╡╧Β╬│╬χ ╧Δ╧Ε╬┐╬╜ browser ╧Δ╬▒╧Γ. ╬Ω Javascript ╧Α╧Β╬φ
  ╧Α╬╡╬╣ ╬╜╬▒ ╬╡╬ψ╬╜╬▒╬╣ ╬╡╬╜╬╡╧Β╬│╬┐╧Α╬┐╬╣╬╖╬╝╬φ╬╜╬╖ ╬│╬╣╬▒ ╬▒╧Ζ╧Ε╬χ ╧Ε╬╖╬╜ ╬╣╧Δ╧
  Ε╬┐╧Δ╬╡╬╗╬ψ╬┤╬▒.&amp;lt;/p&amp;gt;
                                                          &amp;lt;/div&amp;gt;
                                                          &amp;lt;div class=&quot;bottom&quot;&amp;g
  t;&amp;amp;nbsp;&amp;lt;/div&amp;gt;
                                                  &amp;lt;/div&amp;gt;
                                          &lt;/noscript&gt;
  
                                          &lt;div id=&quot;plchcentre&quot; class=&quot;centre place
  holder&quot;&gt;
                                                  &lt;div id=&quot;plchFlash&quot;&gt;&lt;/div&gt;
                                                  &lt;div id=&quot;plchcentrebox2&quot;&gt;&lt;/div&gt;
                                          &lt;div class=&quot;hidden&quot; id=&quot;BodyClassOverrid
  eComponent1&quot;&gt;&lt;/div&gt;&lt;div class=&quot;market-list&quot; id=&quot;MarketListContentComponent2&quot; sty
  le=&quot;display: block; &quot;&gt;&lt;img src=&quot;/indicator.gif&quot; alt=&quot;Loading&quot;&gt;&lt;/div&gt;&lt;/div&gt;&lt;!-- .
  centre --&gt;
  
                                          &lt;div class=&quot;print-buttons&quot;&gt;
                                                  &lt;a class=&quot;button&quot; href=&quot;/Areas/P
  rint/template_1_UK/#&quot; onclick=&quot;window.print(); return false;&quot;&gt;Print&lt;/a&gt;
                                          &lt;/div&gt;
  
                                  &lt;/div&gt;&lt;!-- .c --&gt;
                          &lt;/div&gt;
                  &lt;/div&gt;
          &lt;!-- Google Analytics --&gt;
          &lt;script src=&quot;/static/common/analytics/analytics.js&quot; type=&quot;text/javascrip
  t&quot;&gt;&lt;/script&gt;
          &lt;script type=&quot;text/javascript&quot;&gt;
          //Built with PageBuilder v. 1.0.0.0
          var autoWiring = new Framework.AutoWiring();
          autoWiring.init(serviceConfiguration, componentConfiguration, dynamicCom
  ponentConfiguration, componentPlacementMap, encodedXsltDocumentsMap);
          autoWiring.run();
  &lt;/script&gt;&lt;div id=&quot;GarbageCollector&quot; style=&quot;display: none; &quot;&gt;&lt;/div&gt;
  
  
  &lt;div class=&quot;ui-tooltip ui-widget ui-corner-all ui-widget-content&quot; id=&quot;warp-toolt
  ip&quot; style=&quot;position: absolute; left: 0px; top: 0px; z-index: 200000; display: no
  ne; &quot;&gt;&lt;/div&gt;&lt;/body&gt;&lt;/html&gt;
  </code></pre>