title: phantomJS scraping with breaks not working
body: <p>I'm trying to scrape some URLS from a webservice, its working perfect but I need to scrape something like 10,000 pages from the same web servicve. </p>
  
  <p>I do this by creating multiple phantomJS processes and they each open and evaluate a different URL (Its the same service, all I change is one parameter in the URL of the website). </p>
  
  <p>Problem is I don't want to open 10,000 pages at once, since I don't want their service to crash, and I don't want my server to crash either.</p>
  
  <p>I'm trying to make some logic of opening/evaluating/insertingToDB ~10 pages, and then sleeping for 1 minute or so.</p>
  
  <p>Let's say this is what I have now:</p>
  
  <pre><code>var numOfRequests = 10,000; //Total requests
      for (var dataIndex = 0; dataIndex &lt; numOfRequests; dataIndex++) {
           phantom.create({'port' : freeport}, function(ph) { 
             ph.createPage(function(page) {
               page.open("http://..." + data[dataIncFirstPage], function(status) {
  </code></pre>
  
  <p>I want to insert somewhere in the middle something like:</p>
  
  <pre><code>if(dataIndex % 10 == 0){
     sleep(60); //I can use the sleep module
  }
  </code></pre>
  
  <p>Every where I try to place <a href="https://www.npmjs.org/package/sleep" rel="nofollow" title="sleep">sleepJS</a> the program crashes/freezes/loops forever...</p>
  
  <p>Any idea what I should try?</p>
  
  <p>I've tried placing the above code as the first line after the for loop, but this doesn't work (maybe because of the callback functions that are waiting to fire..)
  If I place it inside the <code>phantom.create()</code> callback also doesn't work..</p>