Skip to content

Instantly share code, notes, and snippets.

@gwintrob
Created November 5, 2014 20:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gwintrob/67e44b851d435509097b to your computer and use it in GitHub Desktop.
Save gwintrob/67e44b851d435509097b to your computer and use it in GitHub Desktop.
Nightmare Async Example
var Nightmare = require('nightmare');
var async = require ('async');
var urls = ['https://segment.com/', 'http://www.nytimes.com/', 'http://www.gnu.org/'];
function test(url, cb) {
console.log('test: ' + url);
var nightmare = new Nightmare();
nightmare
.goto(url)
.evaluate(function () {
return document.documentElement.innerHTML;
}, function (res) {
console.log('evaluate: ' + url);
})
.run(function (err, nightmare) {
console.log('run: ' + url);
cb();
});
}
async.each(urls, test, function (err) {
console.log('done!');
});
test: https://segment.com/
test: http://www.nytimes.com/
test: http://www.gnu.org/
evaluate: http://www.gnu.org/
run: http://www.gnu.org/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment