nodejs save all images

What would be a solution to save all images to file from an web page.

I am still playing around. All I have got at the moment is listing the src. How can I now go about to download these files.

var request = require('request');
var cheerio = require('cheerio');

var url = 'http://www.slashdot.org';

request(url, function(err, resp, body){

  $ = cheerio.load(body);
  imglist = $('img');

  for (var i = 0; i < imglist.length; i++){
    console.log(imglist[i].attribs.src);
  }

});

Ideally I would of wanted a local copy of the page with the images save locally as well, but is this possible?

Of course it is possible to save the page along with the images but its not super easy. To start with you already have the body text, so you can save that to a file. But before you do that, you need to adjust the locations of all resources (like images) so they point to your local copy.

Otherwise, you should be able to get the images just like you got the page.

Go go go you can do it!

Once you've got the img src attribute you can make it into a URL relative to the page location (if it isn't already a full URL).

Once you've got a URL you can fetch the resource using http.get(options, callback).