Javascript 如何在Dream js中下载多个文件
我已经准备好了Javascript 如何在Dream js中下载多个文件,javascript,node.js,headless-browser,nightmare,Javascript,Node.js,Headless Browser,Nightmare,我已经准备好了 const Nightmare = require('nightmare'); require('nightmare-inline-download')(Nightmare); require('nightmare-download-manager')(Nightmare); const nightmare = Nightmare({ show: false, waitTimeout: 2500, gotoTimeout: 5000 }); var download = (
const Nightmare = require('nightmare');
require('nightmare-inline-download')(Nightmare);
require('nightmare-download-manager')(Nightmare);
const nightmare = Nightmare({ show: false, waitTimeout: 2500, gotoTimeout: 5000 });
var download = ( async () => {
const url = "someurl"
nightmare.on('download', function(state, downloadItem){
if(state == 'started'){
nightmare.emit('download', downloadItem.filename, downloadItem);
}
});
let test = nightmare
.downloadManager()
.goto(url, {Authorization: "Basic"})
.wait("#summary-val")
.evaluate( () => {
document.querySelectorAll("#attachments li .attachment-thumb a").forEach( function(elem) {
elem.click()
})
})
.waitDownloadsComplete()
.end()
.then(data => {
})
.catch((error) => {
console.error('Search failed:', error);
});
})
download();
但是,这只下载最后一个文件。执行单击(“#attachments li.attachment thumb a”)
只会下载第一个文件
那么我怎样才能让它递归地下载所有的文件呢