@crawlee/impit-client 4.0.0-beta.230 → 4.0.0-beta.232
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.js +7 -2
- package/package.json +5 -4
package/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { serviceLocator } from '@crawlee/core';
|
|
1
2
|
import { BaseHttpClient, ResponseWithUrl } from '@crawlee/http-client';
|
|
2
3
|
import { Impit } from 'impit';
|
|
3
4
|
import { LruCache } from '@apify/datastructures';
|
|
@@ -63,7 +64,11 @@ export class ImpitHttpClient extends BaseHttpClient {
|
|
|
63
64
|
*/
|
|
64
65
|
constructor(options) {
|
|
65
66
|
super({ logger: options?.logger });
|
|
66
|
-
const { cacheClients = true, logger
|
|
67
|
+
const { cacheClients = true, logger, ...impitOptions } = options ?? {};
|
|
68
|
+
if (impitOptions.browser) {
|
|
69
|
+
(logger ?? serviceLocator.getLogger()).warningOnce('The `browser` option of ImpitHttpClient overrides the browser fingerprint of the session. ' +
|
|
70
|
+
'Using it with Crawlee crawlers can lead to incompatible Session setups.');
|
|
71
|
+
}
|
|
67
72
|
this.#impitOptions = impitOptions;
|
|
68
73
|
this.#cacheClients = cacheClients;
|
|
69
74
|
}
|
|
@@ -72,7 +77,7 @@ export class ImpitHttpClient extends BaseHttpClient {
|
|
|
72
77
|
*/
|
|
73
78
|
async fetch(request, options) {
|
|
74
79
|
const { proxyUrl, redirect, signal, fingerprint, ignoreTlsErrors } = options ?? {};
|
|
75
|
-
const impitBrowser = this.#resolveImpitBrowser(fingerprint);
|
|
80
|
+
const impitBrowser = this.#impitOptions.browser ? undefined : this.#resolveImpitBrowser(fingerprint);
|
|
76
81
|
const impit = this.#getClient({
|
|
77
82
|
...this.#impitOptions,
|
|
78
83
|
...(impitBrowser ? { browser: impitBrowser } : {}),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/impit-client",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.232",
|
|
4
4
|
"description": "impit-based HTTP client implementation for Crawlee. Impersonates browser requests to avoid bot detection.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.13.0"
|
|
@@ -48,8 +48,9 @@
|
|
|
48
48
|
},
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/datastructures": "^3.0.1",
|
|
51
|
-
"@crawlee/
|
|
52
|
-
"@crawlee/
|
|
51
|
+
"@crawlee/core": "4.0.0-beta.232",
|
|
52
|
+
"@crawlee/http-client": "4.0.0-beta.232",
|
|
53
|
+
"@crawlee/types": "4.0.0-beta.232",
|
|
53
54
|
"impit": "^0.14.2",
|
|
54
55
|
"tough-cookie": "^6.0.0"
|
|
55
56
|
},
|
|
@@ -60,5 +61,5 @@
|
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
63
|
},
|
|
63
|
-
"gitHead": "
|
|
64
|
+
"gitHead": "5eab8f877242d46d7cae13b640d8e1adbf194911"
|
|
64
65
|
}
|