Skip to content

Instantly share code, notes, and snippets.

@joepie91
Forked from anonymous/gist:2e38bfd2bf09b976dff1
Last active August 29, 2015 14:24
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 joepie91/e883e95dc604a29241db to your computer and use it in GitHub Desktop.
Save joepie91/e883e95dc604a29241db to your computer and use it in GitHub Desktop.
function runBow(input, cb) {
return Promise.try(function(){
if (input.url.match(/^https:\/\//i)) {
/* Mutating is bad! */
var url = input.url.replace(/^https:\/\//i, 'http://');
} else {
var url = input.url;
}
return bow.crawl(url);
})
.map(bow.parseResults, {concurrency: 20})
.then(function(parsedResults){
/* parsedResults now has an array of parsed results... */
console.log("Done!");
})
/* and if you want to handle errors here: (but you probably don't need to, as they bubble up) */
.catch(function(err){
console.log("Error occurred!", err);
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment