I am using Nightmare to create a automated downloader for today's newspaper. I managed to login and go the the specified page. However I could not find out how to download a file with Nightmare.
var Nightmare = require('nightmare');
new Nightmare()
.goto('https://login.nrc.nl/login?service=http://digitaleeditie.nrc.nl/welkom')
.type('input[name="username"]', 'Username')
.type('input[name="password"]','Password')
.click('button[type="submit"]')
.wait()
.goto('http://digitaleeditie.nrc.nl/digitaleeditie/NH/2014/10/20141124___/downloads.html')
.wait()
.click('a[href="/digitaleeditie/helekrant/epub/nrc_20141124.epub"]')
.wait()
.url(function(url) {
console.log(url)
})
.run(function (err, nightmare) {
if (err) return console.log(err);
console.log('Done!');
});
I tried to download the file by clicking on the download button. However this seems not to work.
There is a Nightmare download plugin. You can download the file just with this code below: