diff --git a/.gitignore b/.gitignore index 586b3da964f6..77e793d8d509 100644 --- a/.gitignore +++ b/.gitignore @@ -31,3 +31,6 @@ test/e2e/**/packages # we use corepack, no need to commit yarn binary .yarn + +# Local vitest config overrides +vitest.config.local.mts diff --git a/docs/guides/impit-http-client/impit-http-client.mdx b/docs/guides/impit-http-client/impit-http-client.mdx index 533d8dfd3817..89c71e82fa5d 100644 --- a/docs/guides/impit-http-client/impit-http-client.mdx +++ b/docs/guides/impit-http-client/impit-http-client.mdx @@ -68,22 +68,30 @@ The `ImpitHttpClient` constructor accepts the following options: | Option | Type | Default | Description | |--------|------|---------|-------------| -| `browser` | `'chrome'` \| `'firefox'` | `undefined` | Browser to impersonate. Affects TLS fingerprint and default headers. | +| `browser` | `'chrome'` \| `'firefox'` \| `...` | `undefined` | Browser to impersonate. Affects TLS fingerprint and default headers. | | `http3` | `boolean` | `false` | Enable HTTP/3 (QUIC) protocol support. | | `ignoreTlsErrors` | `boolean` | `false` | Ignore TLS certificate errors. Useful for testing or self-signed certificates. | -### Browser impersonation -Use the `Browser` enum to specify which browser to impersonate: +### Available fingerprints + +Impit bundles several realistic browser fingerprints. +Using version-specific fingerprints can improve success rates against sophisticated bot detection systems that track browser versions and flag outdated signatures. + +When using generic fingerprints (`chrome` or `firefox`), Impit automatically selects an appropriate version. For most use cases, the generic options are sufficient. +However, if you're targeting a site with particularly strict bot detection, or need to match a specific browser environment, you can specify an exact version: ```ts -import { ImpitHttpClient, Browser } from '@crawlee/impit-client'; +import { ImpitHttpClient } from '@crawlee/impit-client'; + +// Use a generic Chrome fingerprint +const chromeClient = new ImpitHttpClient({ browser: 'chrome' }); -// Impersonate Firefox -const firefoxClient = new ImpitHttpClient({ browser: Browser.Firefox }); +// Use a specific Chrome version +const chrome131Client = new ImpitHttpClient({ browser: 'chrome131' }); -// Impersonate Chrome -const chromeClient = new ImpitHttpClient({ browser: Browser.Chrome }); +// Or a specific Firefox version +const firefox144Client = new ImpitHttpClient({ browser: 'firefox144' }); ``` ### Advanced configuration diff --git a/vitest.config.mts b/vitest.config.mts index c53511c82e7b..d2fe69a598c0 100644 --- a/vitest.config.mts +++ b/vitest.config.mts @@ -1,7 +1,8 @@ +import { existsSync } from 'node:fs'; import { resolve } from 'node:path'; import isCI from 'is-ci'; -import { defineConfig } from 'vitest/config'; +import { defineConfig, mergeConfig } from 'vitest/config'; let threads: { minThreads: number; maxThreads: number } | undefined; @@ -10,7 +11,7 @@ if (isCI) { threads = { minThreads: 1, maxThreads: 1 }; } -export default defineConfig({ +const baseConfig = defineConfig({ esbuild: { target: 'es2022', keepNames: true, @@ -44,3 +45,16 @@ export default defineConfig({ retry: process.env.RETRY_TESTS ? 3 : 0, }, }); + +// Check for local config override +const localConfigPath = resolve(__dirname, './vitest.config.local.mts'); +let finalConfig = baseConfig; + +if (existsSync(localConfigPath)) { + const localConfigModule = await import(localConfigPath); + const localConfig = localConfigModule.default; + console.log(`Applying local vitest config overrides`); + finalConfig = mergeConfig(baseConfig, localConfig); +} + +export default finalConfig; diff --git a/website/versioned_docs/version-3.16/guides/impit-http-client/impit-http-client.mdx b/website/versioned_docs/version-3.16/guides/impit-http-client/impit-http-client.mdx index 533d8dfd3817..89c71e82fa5d 100644 --- a/website/versioned_docs/version-3.16/guides/impit-http-client/impit-http-client.mdx +++ b/website/versioned_docs/version-3.16/guides/impit-http-client/impit-http-client.mdx @@ -68,22 +68,30 @@ The `ImpitHttpClient` constructor accepts the following options: | Option | Type | Default | Description | |--------|------|---------|-------------| -| `browser` | `'chrome'` \| `'firefox'` | `undefined` | Browser to impersonate. Affects TLS fingerprint and default headers. | +| `browser` | `'chrome'` \| `'firefox'` \| `...` | `undefined` | Browser to impersonate. Affects TLS fingerprint and default headers. | | `http3` | `boolean` | `false` | Enable HTTP/3 (QUIC) protocol support. | | `ignoreTlsErrors` | `boolean` | `false` | Ignore TLS certificate errors. Useful for testing or self-signed certificates. | -### Browser impersonation -Use the `Browser` enum to specify which browser to impersonate: +### Available fingerprints + +Impit bundles several realistic browser fingerprints. +Using version-specific fingerprints can improve success rates against sophisticated bot detection systems that track browser versions and flag outdated signatures. + +When using generic fingerprints (`chrome` or `firefox`), Impit automatically selects an appropriate version. For most use cases, the generic options are sufficient. +However, if you're targeting a site with particularly strict bot detection, or need to match a specific browser environment, you can specify an exact version: ```ts -import { ImpitHttpClient, Browser } from '@crawlee/impit-client'; +import { ImpitHttpClient } from '@crawlee/impit-client'; + +// Use a generic Chrome fingerprint +const chromeClient = new ImpitHttpClient({ browser: 'chrome' }); -// Impersonate Firefox -const firefoxClient = new ImpitHttpClient({ browser: Browser.Firefox }); +// Use a specific Chrome version +const chrome131Client = new ImpitHttpClient({ browser: 'chrome131' }); -// Impersonate Chrome -const chromeClient = new ImpitHttpClient({ browser: Browser.Chrome }); +// Or a specific Firefox version +const firefox144Client = new ImpitHttpClient({ browser: 'firefox144' }); ``` ### Advanced configuration