-
-
Save joepie91/e883e95dc604a29241db to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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