var client = require('cheerio-httpcli');
var URL = require('url');
var target = "http://nodejs.jp/"
downloadRec(target, 2);
function downloadRec(url, l) {
if (l <= 0) return;
console.log(url);
client.fetch(url, {}, function(err, $, res) {
$("a").each(function(i) {
var next_url = $(this).attr('href');
next_url = URL.resolve(url, next_url);
downloadRec(next_url, l - 1);
});
});
}