Closed jaimeiniesta closed 6 years ago
Having the same issue here!
For the record, I finally changed to use chrome-aws-lambda
and puppeteer
instead. Check out comments and links here:
I was having the same issue. There is a workaround for that. You can run two projects, one is running the serverless example and the other one is running your business logic by connecting to the chrome which is hosting in your first project. Personally speaking, I'm in favour of this solution cause you don't need to deploy the whole chrome application to server everytime you change your business logic. Deploying chrome is like a pre set up, you just need to do it once and use its service.
Details: Project 1: Deploying Chromeless Proxy service to AWS
Get endpointUrl and apiKey
Project 2: Running your business logic:
const Chromeless = require('chromeless').default
async function run() {
const chromeless = new Chromeless({
remote: {
endpointUrl: 'https://XXXXXXXXXX.execute-api.eu-west-1.amazonaws.com/dev',
apiKey: 'your-api-key-here'
},
})
const screenshot = await chromeless
.goto('https://www.google.com')
.type('chromeless', 'input[name="q"]')
.press(13)
.wait('#resultStats')
.screenshot()
console.log(screenshot) // prints local file path or S3 url
await chromeless.end()
}
run().catch(console.error.bind(console))
Please leave your comments if anyone has a better solution
Hello, I'm trying to set up an AWS Lambda function with serverless that has an endpoint, accepts an
url
and returns an screenshot URL.I could find examples on setting up AWS Lambda to be used with a proxy, but are there examples on how to embed this for direct use in a AWS Lambda function?
My first attempt was including the
chromeless
dependency inpackage.json
, runnpm install
from a Docker instance (so that it gets the linux binaries), and upload a function that basically does this:But when I execute it, I see this error in the logs:
It looks like Chrome can't be found, what is the PATH for the Chrome binary?
Thanks!