Created
December 26, 2016 13:27
-
-
Save otarza/7f2332cc412adccd5ee639cf91841e82 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 fetchByURLs_$(urls, parserTemplate){ | |
urls.map(url => { | |
return { | |
url: url, | |
urisListPromise: scrapeIt(url, parserTemplate), | |
} | |
}).reduce(function (sequence, urlWithUrisListPromise) { | |
return sequence.then(() => { | |
return urlWithUrisListPromise.urisListPromise; | |
}).then(urisList => { | |
//TODO DB insert | |
}, reason => { | |
errored.push(urlWithUrisListPromise.url); | |
}); | |
}, Promise.resolve()).then(function() { | |
console.log("All done"); | |
}).catch(function(err) { | |
console.log("Oops: " + err.message); | |
}).then(function() { | |
//TODO DB close! | |
if(errored.length) { | |
fetchByURLs_$(errored, parserTemplate ) | |
} | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.