我正在使用这个框架来制作几个网址的屏幕截图。截图的过程是异步的,并且该方法没有提供执行回调的方法,我想在这个脚本上每次截图时执行回调:
nightmare = new Nightmare();
urls.forEach(function (url) {
nightmare.goto(url).screenshot(path);
});
nightmare.run(function () {
console.log('finished all');
});
有什么想法我该怎么做?
我找到了一种方法来做到这一点,使用“use”方法来执行插件。
nightmare = new Nightmare();
urls.forEach(function (url) {
nightmare.goto(url).screenshot(path).use(function () {
console.log('finished one');
});
});
nightmare.run(function () {
console.log('finished all');
});
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)