TypeScript Camoufox scraper
A Firefox-based browser built to look like a real user and bypass bot protection.
src/main.ts
src/routes.ts
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';11import { launchOptions as camoufoxLaunchOptions } from 'camoufox-js';12import { firefox } from 'playwright';13
14// this is ESM project, and as such, it requires you to specify extensions in your relative imports15// read more about this here: https://nodejs.org/docs/latest-v18.x/api/esm.html#mandatory-file-extensions16// note that we need to use `.js` even when inside TS files17import { router } from './routes.js';18
19interface Input {20 startUrls: {21 url: string;22 method?: 'GET' | 'HEAD' | 'POST' | 'PUT' | 'DELETE' | 'TRACE' | 'OPTIONS' | 'CONNECT' | 'PATCH';23 headers?: Record<string, string>;24 userData: Record<string, unknown>;25 }[];26 maxRequestsPerCrawl: number;27}28
29// Initialize the Apify SDK30await Actor.init();31
32// Structure of input is defined in input_schema.json33const { startUrls = ['https://apify.com'], maxRequestsPerCrawl = 100 } =34 (await Actor.getInput<Input>()) ?? ({} as Input);35
36// `checkAccess` flag ensures the proxy credentials are valid, but the check can take a few hundred milliseconds.37// Disable it for short runs if you are sure your proxy configuration is correct38const proxyConfiguration = await Actor.createProxyConfiguration({ checkAccess: true });39
40const crawler = new PlaywrightCrawler({41 proxyConfiguration,42 maxRequestsPerCrawl,43 requestHandler: router,44 launchContext: {45 launcher: firefox,46 launchOptions: await camoufoxLaunchOptions({47 headless: true,48 proxy: await proxyConfiguration?.newUrl(),49 geoip: true,50 // fonts: ['Times New Roman'] // <- custom Camoufox options51 }),52 },53});54
55await crawler.run(startUrls);56
57// Exit successfully58await Actor.exit();This template is a production-ready boilerplate for developing an Actor with PlaywrightCrawler. It has Camoufox - a stealthy fork of Firefox - preinstalled. Note that Camoufox might consume more resources than the default Playwright-bundled Chromium or Firefox.
Use this template 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 scraped data using Apify API
- A short guide on how to build web scrapers using code templates:
TypeScript 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.
TypeScript one-page scraper
Get data from one web page with Cheerio. The simplest way to start scraping.
TypeScript Puppeteer scraper
A headless Chrome scraper that renders JavaScript before extracting data. Good for social feeds, dashboards, or single-page apps.
TypeScript Playwright scraper
A Playwright-based browser scraper supporting multiple browsers and contexts.
Playwright test runner
An automated browser test runner with results you can access via API.
Empty TypeScript Actor
An Actor with the Apify SDK set up, so you can build any tool you need.