I'm having a problem downloading files from urls I am creating when scrapping a website. Currently I discovering the month and year of a file then replacing the values in a url and downloading trying to download from that location. I understand that you can't use the download function from inside the evaluation scope.
this.evaluate(function collectAllData (MONTHS) {
for (...) {
// Create url from page information ...
casper.emit('test.download', url, fileName);
}
}, MONTHS);
casper.on('remote.download', function processRemoteDownload(url, fileName) {
this.download(url, fileName);
});
Is there anyway to emit a custom event from within evaluate? I don't want to navigate away from the current page I am on or have to go back and forth from the evaluate scope. I know I could return a list of urls and process them after the fact but was curious if this was possible. Thanks for any help.