Puppeteer, Playwright & other client libraries
Connect Puppeteer, Playwright, Chromedp, or Selenium to Lightpanda in under 10 minutes, and read content that only exists once a page’s JavaScript runs. Get the same automation you already know, running faster and lighter than Chrome.
Steps
Install Lightpanda
curl -fsSL https://pkg.lightpanda.io/install.sh | bash
export PATH="$HOME/.local/bin:$PATH"Other options: WSL2 on Windows, Docker, package managers.
Install your client library
Puppeteer
Needs Node.js . In a new project directory:
npm init -y
npm pkg set type=module
npm install --save puppeteer-coreStart Lightpanda
Puppeteer
lightpanda serveLightpanda listens on 127.0.0.1:9222 by default, the address the script connects to. Find every serve flag, including host/port binding, CDP connection limits, and logging, in the serve reference.
Respect robots.txt and avoid high-frequency requests against small sites. Pass --obey-robots to have Lightpanda follow robots.txt for you.
Connect and read JS-rendered content
The script opens quotes.toscrape.com/js and prints the first quote. The quotes are rendered by JavaScript, so a plain HTTP fetch returns an empty list: Lightpanda runs that JavaScript before your script reads the page.
Puppeteer
Save as index.js:
'use strict'
import puppeteer from 'puppeteer-core'
const browser = await puppeteer.connect({
browserWSEndpoint: 'ws://127.0.0.1:9222',
})
const context = await browser.createBrowserContext()
const page = await context.newPage()
await page.goto('https://quotes.toscrape.com/js/')
const quote = await page.$eval('.quote .text', el => el.textContent)
console.log(quote)
await page.close()
await context.close()
await browser.disconnect()Find more Puppeteer options.
Run it
Puppeteer
node index.jsYou should see the first quote printed to your terminal. For more complex examples, like filling a form and waiting for dynamic results, see Interact with a webpage.
Go to production
Switch to Lightpanda Cloud by exporting your token and connecting over wss:// instead of ws://:
export LPD_TOKEN="your token here"Puppeteer
const browser = await puppeteer.connect({
browserWSEndpoint: 'wss://euwest.cloud.lightpanda.io/ws?token=' + process.env.LPD_TOKEN,
})