我需要做些什么来让节点骑手在天蓝色上工作?
问题描述:
节点骑士完美地在我的本地服务器上工作,但是当我将它放在天蓝色的时候它不起作用。 Node-horseman是node.js的无头浏览器模块。 我认为azure阻止了外部链接的访问,但我怎么解开这个问题?我需要做些什么来让节点骑手在天蓝色上工作?
const Horseman = require('node-horseman');
const users = ['PhantomJS', 'nodejs'];
var express = require('express'),
http = require('http'),
app = express();
app.get('/', function (req, res) {
res.send("Deu certo!");
console.log("Funcionou");
});
app.get('/twitter/', function (req, res) {
var retorno = ``;
var extracoes = 0;
console.log("aqui");
users.forEach((user) => {
const horseman = new Horseman();
horseman
.open(`http://twitter.com/${user}`)
.text('.ProfileNav-item--followers .ProfileNav-value')
.then((text) => {
retorno += `${user}: ${text}<br>`;
extracoes ++;
if (extracoes == users.length) {
res.send(retorno);
}
})
.close();
});
});
app.set('port', process.env.PORT || 3000);
http.createServer(app).listen(app.get('port'), function(){
console.log('Express server listening on port ' + app.get('port'));
});
答
如果你在Azure的应用服务托管,要知道这个wiki在这里 - https://github.com/projectkudu/kudu/wiki/Azure-Web-App-sandbox#unsupported-frameworks
其他方案不受支持:
PhantomJS /硒:尝试连接到本地地址并且还使用GDI +。
改为将您的应用程序部署到Cloud Services或VM。如果您携带自己的容器(使用PhantomJS和所有依赖项),App Service on Linux也应该可以工作。
请显示您的代码。由于Stack Overflow隐藏了你的密切原因:*寻求调试帮助的问题(“为什么这个代码不工作?”)必须包含所需的行为,特定的问题或错误以及在问题本身中重现它的最短代码。没有明确问题陈述的问题对其他读者无益。请参阅:[如何创建最小,完整和可验证示例](https://*.com/help/mcve)。* – jww