Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save davidguttman/ba96b1cfc0dfff2d4da8 to your computer and use it in GitHub Desktop.
Save davidguttman/ba96b1cfc0dfff2d4da8 to your computer and use it in GitHub Desktop.

Revisions

  1. @Spencer-Allen Spencer-Allen created this gist Aug 15, 2014.
    32 changes: 32 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,32 @@
    var http = require('http');
    var bl = require('bl');

    var urls = [];
    process.argv.slice(2).forEach(function(item){
    urls.push(item)
    });

    console.log (urls)

    var getter = function(url, index){
    results = []
    http.get(url, function(response) {
    response.setEncoding('utf8');
    response.pipe(bl(function(err, data){
    if (err) {
    return;
    }
    results.splice(index, 0, data.toString());
    }));
    });
    }

    for (var x=0; x < urls.length - 1; x++){
    var answer = getter(urls[x], x)
    }

    for (y in results){
    console.log(results[y]);
    }