我需要做什么才能让 node-horseman 在 azure 上工作?
What do I need to do for the node-horseman to work on the azure?
node-horseman 在我的本地服务器上运行得很好,但是当我把它放在 azure 上时它就不起作用了。
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
Other scenarios that are not supported:
PhantomJS/Selenium: tries to connect to local address, and also uses GDI+.
如果您使用自己的容器(带有 PhantomJS 和所有依赖项),将您的应用程序部署到 Cloud Services or a VM instead. App Service on Linux 应该也可以。
node-horseman 在我的本地服务器上运行得很好,但是当我把它放在 azure 上时它就不起作用了。 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
Other scenarios that are not supported:
PhantomJS/Selenium: tries to connect to local address, and also uses GDI+.
如果您使用自己的容器(带有 PhantomJS 和所有依赖项),将您的应用程序部署到 Cloud Services or a VM instead. App Service on Linux 应该也可以。