title: Stuck with looping in Request + Cheerio (NODEJS)
body: <p>I'm trying to scrape a web page, place all the URLS in an array and then scrape the next page in the array. But it's just looping the firs URL rather than following the next URL in the array. How do I change it so it scrapes each page?</p>
  
  <p>Thanks for your help.</p>
  
  <pre><code>var request = require('request');
  var cheerio = require('cheerio');
  var async = require('async');
  var fs = require('fs');
  
  
  var i = 0;
  var array = [];
  
  
  var q = async.queue(function (task, done) {
  request(task.url, function(err, res, body) {
      if (err) return done(err);
      if (res.statusCode != 200) return done(res.statusCode);
  
      var $ = cheerio.load(body);
      links = $('a');
     $(links).each(function(i, link){
     var href = $(link).attr('href');
      array.push(href);
     console.log(array);
  
  
   });
  
      done();
      i++
    q.push({ url: array[i] });
  });
  }, 5);
  
  q.push({ url: 'http://www.hobo-web.co.uk/' });
  </code></pre>