I was thinking about another solution: you can create a
BasicCrawler and manage your browser page by yourself, for example:
import { chromium } from 'playwright';
import { newInjectedContext } from 'fingerprint-injector';
const BROWSER_URL = 'http://127.0.0.1:9222'; // or something like 'ws://127.0.0.1:36775/devtools/browser/a292f96c-7332-4ce8-82a9-7411f3bd280a'
// ... inside your BasicCrawler
async requestHandler({ request, sendRequest, log }) {
// Initialize your browser
const browser = await chromium.connectOverCDP(BROWSER_URL);
const context = await newInjectedContext(browser); // See https://github.com/apify/fingerprint-suite
const page = await context.newPage();
try {
await page.goto(request.url, {timeout: 20000});
// ... extract data here
} finally {
await page.close();
await context.close();
await browser.close();
}
}