Skip to content

Instantly share code, notes, and snippets.

@JonAbrams
Created September 18, 2014 21:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save JonAbrams/af4020ea3dd31cf3ffc2 to your computer and use it in GitHub Desktop.
Save JonAbrams/af4020ea3dd31cf3ffc2 to your computer and use it in GitHub Desktop.
Scrape list of URLs and prints them - Uses promises
var Promise = require('bluebird'); // The best promise library out there
var request = require('request-promise'); // Scrapes the specified url, returns promise e.g. request(url)
var urls = process.argv.slice(2); // List of URLs to scrape
Promise.map(urls, request) // Returns an array of promises to the results of scraping the url
.each(console.log) // Call console.log on each resolved promise
.catch(console.error);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment