title: node.js + cheerio scrape: Passing an array of urls to download?
body: <p>Firstly, here is my code as I've progressed so far:</p>
  
  <pre><code>var http = require("http");
  
  // Utility function that downloads a URL and invokes
  // callback with the data.
  function download(url, callback) {
    http.get(url, function(res) {
      var data = "";
      res.on('data', function (chunk) {
        data += chunk;
      });
      res.on("end", function() {
        callback(data);
      });
    }).on("error", function() {
      callback(null);
    });
  }
  
  var cheerio = require("cheerio");
  
  var url = "http://www.bloglovin.com/en/blogs/1/2/all";
  var myArray = [];
  var a = 0;
  
  var getLinks = function(){download(url, function(data) {
    if (data) {
      // console.log(data);
      var $ = cheerio.load(data);
      $(".content").each(function(i, e) {
        var blogName = $(e).find(".blog-name").text();
        var followLink = $(e).find("a").attr("href");
        var blogSite = $(e).find(".description").text();
  
        myArray[a] = [a];
        myArray[a]["blogName"] = blogName;
        myArray[a]["followLink"] = "http://www.bloglovin.com"+followLink;
        myArray[a]["blogSite"] = blogSite;
  
        a++;
  
        console.log(myArray);
  
      });
    }
  });
  }
  
  getLinks();
  </code></pre>
  
  <p>As you can see, <code>followLinks</code> is concatenated to <code>followUrl</code>, of which I'd like to pass through the <code>'url'</code> download, so effectively I'll be scraping each of the pages using the same CSS rules, which will be added to the multidimensional array for the corresponding blogger.</p>
  
  <p>How can I go about this?</p>