云功能在本地运行,但是在部署后停止工作。
目的是从搜索引擎获取特定查询的链接,以便以后在每个页面内查找特定信息。
我已经在heroku中尝试过,但是也没有用。
const functions = require('firebase-functions');
const admin = require('firebase-admin');
const credential = require('./xxx-firebase-adminsdk-xxx-xxx.json')
const sec = require('search-engine-client');
console.log('initialing functions at ', new Date().toString())
admin.initializeApp({ credential: admin.credential.cert(credential), databaseURL: "https://wasender-fa4c9.firebaseio.com" });
exports.getLinks = functions.runWith({ timeoutSeconds: 540 }).https.onCall((data, context) => {
console.log('starting to get links ', new Date().toString())
console.log('search-engine-client working? ', sec)
sec.google("text to search").then(function(result){
console.log('google result',result); // these lines are not getting printed in the function log
});
sec.bing("text to search").then(function(result){
console.log('bing result',result); // these lines are not getting printed in the function log
});
})
它没有为搜索引擎打印任何结果链接。
search-engine-client working? { google: [AsyncFunction: GetLinks],
bing: [AsyncFunction: GetLinks],
aol: [AsyncFunction: GetLinks],
ask: [AsyncFunction: GetLinks],
yahoo: [AsyncFunction: GetLinks],
duckduckgo: [AsyncFunction: GetLinks],
baidu: [AsyncFunction: GetLinks],
builder: [AsyncFunction: LinkBuilder] }
pastebin上的完整代码为https://pastebin.com/aCRJrFk5
我发现,nightmare.js和电子只能在Aws和Azure上运行。我现在正在尝试将其部署在Azure上。
显然,由于Nightmare.js使用Electron,因此它需要具有图形用户界面的操作系统。否则不起作用。 VPS可能是这种情况的解决方案。