Skip to main content
Version: 3.12

Using Firefox browser with Playwright crawler

This example demonstrates how to use PlaywrightCrawler with headless Firefox browser.

tip

To run this example on the Apify Platform, select the apify/actor-node-playwright-firefox image for your Dockerfile.

Run on
import { PlaywrightCrawler } from 'crawlee';
import { firefox } from 'playwright';

// Create an instance of the PlaywrightCrawler class.
const crawler = new PlaywrightCrawler({
launchContext: {
// Set the Firefox browser to be used by the crawler.
// If launcher option is not specified here,
// default Chromium browser will be used.
launcher: firefox,
},
async requestHandler({ request, page, log }) {
const pageTitle = await page.title();

log.info(`URL: ${request.loadedUrl} | Page title: ${pageTitle}`);
},
});

await crawler.addRequests(['https://example.com']);

// Run the crawler and wait for it to finish.
await crawler.run();

To see a real-world example of how to use PlaywrightCrawler in combination with RequestQueue to recursively scrape the Hacker News website check out the Playwright crawler example.