Created
November 5, 2014 20:14
-
-
Save gwintrob/67e44b851d435509097b to your computer and use it in GitHub Desktop.
Nightmare Async Example
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
| 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!'); | |
| }); |
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
| 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