Skip to content

Instantly share code, notes, and snippets.

@gwintrob
Last active July 21, 2016 18:58
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/0dda54b7017de7213e68 to your computer and use it in GitHub Desktop.
Save gwintrob/0dda54b7017de7213e68 to your computer and use it in GitHub Desktop.
Multiple Nightmare Example
var Nightmare = require('nightmare');
var urls = ['http://www.nytimes.com/', 'http://www.gnu.org/'];
function test() {
var nightmare1 = new Nightmare();
var nightmare2 = new Nightmare();
nightmare1
.goto(urls[0])
.evaluate(function () {
return document.documentElement.innerHTML;
}, function (res) {
console.log('evaluate: ' + urls[0]);
})
.run(function (err, nightmare) {
console.log('run: ' + urls[0]);
});
nightmare2
.goto(urls[1])
.evaluate(function () {
return document.documentElement.innerHTML;
}, function (res) {
console.log('evaluate: ' + urls[1]);
})
.run(function (err, nightmare) {
console.log('run: ' + urls[1]);
});
}
test();
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