niomok.blogg.se

Free download puppeteer documentation
Free download puppeteer documentation










The nice thing is because there’s not much boilerplate, this should really transfer to any project, so you should have no problem following along within your pre-existing project. Step 0: Creating a new node projectįor this project, we’re going to start from scratch, as there’s not much boilerplate needed for this. We’ll use the Netlify CLI to work with our functions, but it should work pretty similarly however you run and package up your functions.

free download puppeteer documentation free download puppeteer documentation

In this, we’ll learn how we can take advantage of packages like chrome-aws-lambda and Puppeteer itself to package all of this up in a serverless function that can run on request. We’re going to use Netlify to create a new serverless function that we’re able to POST a request to via an API endpoint. So we can take advantage of this capability allowing us to build API endpoints that can perform an action using Puppeteer. This makes it great for running in places you might not have a browser UI to open like CI environments and like you might have guessed, serverless functions. Puppeteer works both with opening a visible browser UI and “headless”, meaning, it will run as a process without actually launching the UI. How can we use Puppeteer in a serverless function on Netlify?

free download puppeteer documentation

For instance, we can use Puppeteer to launch a website in Chrome and get it’s lighthouse score ( see the example from the Puppeteer team). Puppeteer is a JavaScript library from Google that allows developers to control Chrome via an API.Ī common use case is using Puppeteer for testing, where we can make sure that actions we perform in the browser work as we expect them to.īut we can also use it to automate tasks that we want to programmatically perform in the browser.












Free download puppeteer documentation