Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -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
24 changes: 16 additions & 8 deletions docs/guides/impit-http-client/impit-http-client.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 16 additions & 2 deletions vitest.config.mts
Original file line number Diff line number Diff line change
@@ -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;

Expand All @@ -10,7 +11,7 @@ if (isCI) {
threads = { minThreads: 1, maxThreads: 1 };
}

export default defineConfig({
const baseConfig = defineConfig({
esbuild: {
target: 'es2022',
keepNames: true,
Expand Down Expand Up @@ -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;
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading