我想在AWS Lambda函数上使用Node.js包Chromeless。我使用两个软件包:无色和无服务器铬在我的本地计算机上,我的测试脚本运行良好。当我将其部署到Lambda时,.html()的结果为空结果是没有空字符串,它是一个空页面。 ( )CloudWatch Logs中没有错误。chrome浏览器运行正常,但无法加载该网站。NodeJS版本是8.10,异步/等待似乎可以正常工作。希望有人有一个主意。码:const launchChrome = require('@serverless-chrome/lambda');const { Chromeless } = require('chromeless');let index = async function handler () { await launchChrome({ port: 9222, chromeFlags: [ '--window-size=1200,800', '--disable-gpu', '--headless' ] }) .then(async (chrome) => { const chromeless = new Chromeless( { launchChrome:false, cdp:{host: 'localhost', port: 9222, secure: false} } ); const html = await chromeless .goto('http://www.google.com') .wait(5000) .html(); console.log(html); chromeless.end(); })};exports.handler = index;日志:16:39:44 START RequestId: xxx Version: $LATEST16:39:52 2018-04-05T16:39:52.163Z xxx <html><head></head><body></body></html>16:39:52 END RequestId: xxx16:39:52 REPORT RequestId: xxxDuration: 7375.83 ms Billed Duration: 7400 ms Memory Size: 576 MB 最佳答案 Chromeless问题[https://github.com/graphcool/chromeless/issues/414]]中已很好地记录了该问题。无服务器的依赖关系中存在问题,这会引起问题。要更正它,请将您的serverless / package.json更新为将“ serverless-plugin-chrome”固定为版本“ 1.0.0-38”。例如,我的开发依赖项如下所示: "devDependencies": { "@types/cuid": "^1.3.0", "@types/node": "^9.6.2", "serverless": "^1.19.0", "serverless-offline": "^3.15.3", "serverless-plugin-chrome": "1.0.0-38", "serverless-plugin-typescript": "^1.0.0" }关于node.js - 在AWS Lambda上运行Chromeless时获取空网页,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/49681378/
10-11 10:34