0
我在CentOS 7服務器(http://serverip:3000/)上運行一個簡單的夢魘應用程序,它永遠運行,儘管它通過一個簡單的res.send('hello world')傳遞,但沒有結果返回。Nightmarejs永遠運行?
我正在使用節點6.11。相同的代碼在本地PC上運行得很好。
const express = require('express')
const app = express()
app.get('/', function (req, res) {
//res.send('hello world'); => works fine for port 3000
var Nightmare = require('nightmare');
var nightmare = Nightmare({ show: false });
nightmare
.goto('https://www.google.com')
.wait('#searchform')
.evaluate(function() {
return (document.body.innerHTML);
})
.end()
.then(function (result) {
console.log(result);
})
.catch(function (error) {
console.error('Search failed:', error);
});
})
app.listen(3000, function() {
console.log('Example app listening on port 3000!')
})
是否可以從您的CentOS服務器訪問google.com?代碼對我看起來很好。要麼它應該超時默認(30秒)或應該顯示一些錯誤。 – devilpreet
在Linux上運行無頭惡夢似乎有些問題。谷歌投訴很多,但很難得到它的工作。 –
您是否試過在沒有'Express'的情況下直接運行? –