diff --git a/docs/guides/avoid_blocking.mdx b/docs/guides/avoid_blocking.mdx index ed10846f51e6..7a61fca9f5df 100644 --- a/docs/guides/avoid_blocking.mdx +++ b/docs/guides/avoid_blocking.mdx @@ -13,6 +13,7 @@ import PuppeteerSource from '!!raw-loader!./avoid_blocking_puppeteer'; import PlaywrightFingerprintsOffSource from '!!raw-loader!./avoid_blocking_playwright_fingerprints_off.ts'; import PuppeteerFingerprintsOffSource from '!!raw-loader!./avoid_blocking_puppeteer_fingerprints_off.ts'; import PlaywrightCamoufox from '!!raw-loader!./avoid_blocking_camoufox.ts'; +import PlaywrightCloakBrowser from '!!raw-loader!./avoid_blocking_cloakbrowser.ts'; A scraper might get blocked for numerous reasons. Let's narrow it down to the two main ones. The first is a bad or blocked IP address. You can learn about this topic in the [proxy management guide](./proxy-management). The second reason is [browser fingerprints](https://pixelprivacy.com/resources/browser-fingerprinting/) (or signatures), which we will explore more in this guide. Check the [Apify Academy anti-scraping course](https://docs.apify.com/academy/anti-scraping) to gain a deeper theoretical understanding of blocking and learn a few tips and tricks. @@ -64,6 +65,14 @@ For some protections, using our integrated solutions is not enough, one example {PlaywrightCamoufox} +## CloakBrowser + +For sites with aggressive anti-bot protection, [CloakBrowser](https://github.com/CloakHQ/CloakBrowser) takes a different approach. Instead of overriding fingerprints at the JavaScript level (which anti-bot scripts can detect as tampering), CloakBrowser ships a custom Chromium binary with fingerprints modified directly in the C++ source code. It is also Chromium-based, which can matter when a target site behaves differently with Firefox than with Chrome. Install it separately with `npm install cloakbrowser` — the binary auto-downloads on first run. + + + {PlaywrightCloakBrowser} + + **Related links** - [Fingerprint Suite Docs](https://github.com/apify/fingerprint-suite) diff --git a/docs/guides/avoid_blocking_cloakbrowser.ts b/docs/guides/avoid_blocking_cloakbrowser.ts new file mode 100644 index 000000000000..937b5ab3fa11 --- /dev/null +++ b/docs/guides/avoid_blocking_cloakbrowser.ts @@ -0,0 +1,23 @@ +import { PlaywrightCrawler } from 'crawlee'; +import { ensureBinary, getDefaultStealthArgs } from 'cloakbrowser'; +import { chromium } from 'playwright'; + +// CloakBrowser is a stealth Chromium binary with source-level C++ fingerprint patches. +// Install: npm install cloakbrowser (binary auto-downloads on first run) +const executablePath = await ensureBinary(); +const stealthArgs = getDefaultStealthArgs(); + +const crawler = new PlaywrightCrawler({ + browserPoolOptions: { + // Disable the default fingerprint spoofing to avoid conflicts with CloakBrowser. + useFingerprints: false, + }, + launchContext: { + launcher: chromium, + launchOptions: { + executablePath, + args: stealthArgs, + }, + }, + // ... +});