ฉันกำลังพยายามเรียกใช้ cron ด้วย nightmare js ในเครื่อง ขออภัย ฉันมีข้อผิดพลาดนี้
Unhandled rejection (<{"message":"navigation error","code":-...>, no stack trace)
ปัญหาที่เกี่ยวข้อง: Nightmare JS ไม่ทำงาน
ฉันสงสัยว่ามันเชื่อมโยงกับความจริงที่ว่าฝันร้ายต้องใช้อินเทอร์เฟซแบบกราฟิกหรือไม่?
ขอบคุณสำหรับความช่วยเหลือของคุณ,
แก้ไข
ใน cron ของฉัน ฉันมีฟังก์ชัน Promise หนึ่งฟังก์ชันซึ่งประกอบด้วย cron ตามด้วยสัญญา
var job = new CronJob('* */10 * * * *', function() {
crawl()
}, function () {
console.log("crawl ended")
},
true
);
job.start();
นี่คือลักษณะของฝันร้าย:
var Nightmare = require('nightmare');
var nightmare = Nightmare({
typeInterval: 300,
show: true
});
nightmare
.goto('https://pageThatRequireToLoginThenDiplayJsonAsText.com')
.type('[name=email]', '')
.wait(1000)
.type('[name=email]', 'myemail')
.wait(1000)
.type('[name=password]', '')
.wait(1000)
.type('[name=password]', 'mypassword')
.click('[type=submit]')
.wait(25000)
.wait(25000)
.evaluate(function (page, done) {
document.documentElement
done()
})
.end()
.then(function (result) {
// fs.writeFileSync('testOutput.json', JSON.stringify(result));
console.log(JSON.stringify(result))
})
.catch(function (error) {
console.error('failed:', error);
});
เมื่อฉันเรียกใช้ฟังก์ชันการรวบรวมข้อมูลโดยไม่มี cron มันใช้งานได้ดีมาก