我使用夢魘爲當今的報紙創建自動化下載程序。我設法登錄並進入指定頁面。但是我無法找到如何使用夢魘下載文件。使用夢魘下載文件
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!');
});
我試圖通過單擊下載按鈕來下載文件。但是,這似乎不起作用。
我試圖實現這一點。但是,這隻能下載一個具有相同名稱的4k文件。它不下載整個文件。 – 2014-11-25 13:18:40
4k有點任意。內容是什麼?也許這是一個錯誤頁面。 – 2014-11-25 13:24:30
這是一個大小爲4k的epub文件。如果在文本編輯器中打開,它只包含null。 – 2014-11-25 13:30:33