JavaScript Playwright scraper
A Playwright-based browser scraper supporting multiple browsers and contexts.
src/main.js
src/routes.js
1/**2 * This template is a production ready boilerplate for developing with `PlaywrightCrawler`.3 * Use this to bootstrap your projects using the most up-to-date code.4 * If you're looking for examples or want to learn more, see README.5 */6
7// For more information, see https://crawlee.dev8import { PlaywrightCrawler } from '@crawlee/playwright';9// For more information, see https://docs.apify.com/sdk/js10import { Actor } from 'apify';11
12// this is ESM project, and as such, it requires you to specify extensions in your relative imports13// read more about this here: https://nodejs.org/docs/latest-v18.x/api/esm.html#mandatory-file-extensions14import { router } from './routes.js';15
16// Initialize the Apify SDK17await Actor.init();18
19const { startUrls = ['https://apify.com'] } = (await Actor.getInput()) ?? {};20
21// `checkAccess` flag ensures the proxy credentials are valid, but the check can take a few hundred milliseconds.22// Disable it for short runs if you are sure your proxy configuration is correct23const proxyConfiguration = await Actor.createProxyConfiguration({ checkAccess: true });24
25const crawler = new PlaywrightCrawler({26 proxyConfiguration,27 requestHandler: router,28 launchContext: {29 launchOptions: {30 args: [31 '--disable-gpu', // Mitigates the "crashing GPU process" issue in Docker containers32 ],33 },34 },35});36
37await crawler.run(startUrls);38
39// Exit successfully40await Actor.exit();This template is a production-ready boilerplate for developing an Actor with PlaywrightCrawler. Use this to bootstrap your projects using the most up-to-date code.
We decided to split Apify SDK into two libraries, Crawlee and Apify SDK v3. Crawlee will retain all the crawling and scraping-related tools and will always strive to be the best web scraping library for its community. At the same time, Apify SDK will continue to exist, but keep only the Apify-specific features related to building Actors on the Apify platform. Read the upgrading guide to learn about the changes.
If you're looking for examples or want to learn more visit:
- Crawlee + Apify Platform guide
- Documentation and examples
- Node.js tutorials in Academy
- Scraping single-page applications with Playwright
- How to scale Puppeteer and Playwright
- Integration with Zapier , Make, GitHub, Google Drive and other apps
- Video guide on getting data using Apify API
- A short guide on how to create Actors using code templates:
JavaScript Cheerio crawler
A fast HTTP crawler that extracts data from every page. Good for simple sites like blogs, news, or product listings, but it can't run client-side JavaScript.
JavaScript one-page scraper
Get data from one web page with Cheerio. The simplest way to start scraping.
JavaScript Puppeteer scraper
A headless Chrome scraper that renders JavaScript before extracting data. Good for social feeds, dashboards, or single-page apps.
JavaScript Camoufox scraper
A Firefox-based browser built to look like a real user and bypass bot protection.
Cheerio crawler (advanced)
A minimal crawler for developers who already know the Apify SDK and Crawlee.
Cypress test runner
A cloud test runner for Cypress that saves results and videos.