title: Node.js with express : How to wait until all element loaded (including one with ajax request or angular.js)?
body: <p>I'm trying to scrape one page that loaded completely after a while. I use <code>request.get</code> and the request returned <code>response.statusCode == 200</code>.</p>
  
  <p>The only problem is, the page is still loading and requesting something with <code>ajax</code> request. My best guess from the page is they are using <code>angular.js</code> so it's SPA. </p>
  
  <blockquote>
    <p>ISSUE : I want to scrape all <code>div</code> in the products site, the one that is not yet loaded.</p>
  </blockquote>
  
  <pre><code>var express = require('express');
  var fs = require('fs');
  var request = require('request');
  var cheerio = require('cheerio');
  
  var app = express();
  
  app.get('/scrape', function(req, res){
      var options = {
        url: 'http://example.com'
      };
  
      request.get(options, function(error, response, html){
          if (!error &amp;&amp; response.statusCode == 200) {
  
              var $ = cheerio.load(html);
  
              if(!error){
                  var i=0;
  
                  console.log(html); // here (in the html variable) I found the page is still loaded with {width.something etc} &lt;&lt; my best guess is this one is angular.js code
              }
          }
      });
  });
  
  app.listen('8081');
  console.log('Listening...'); 
  exports = module.exports = app;
  </code></pre>
  
  <p>how can I use <code>request</code> to wait until all request including ajax or <code>angular.js</code> request to finish? I've tried many things including <code>waitUntilExist</code> function but still no luck</p>