@crawlee/http 4.0.0-beta.116 → 4.0.0-beta.118
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.
|
@@ -29,9 +29,14 @@ export interface HttpCrawlerOptions<Context extends InternalHttpCrawlingContext
|
|
|
29
29
|
*/
|
|
30
30
|
navigationTimeoutSecs?: number;
|
|
31
31
|
/**
|
|
32
|
-
* If set to true
|
|
32
|
+
* If set to `true`, TLS/SSL certificate errors are ignored. Forwarded to the HTTP client as
|
|
33
|
+
* {@link SendRequestOptions.ignoreTlsErrors|`ignoreTlsErrors`} on every navigation request, so custom
|
|
34
|
+
* {@link BaseHttpClient} implementations should honor that flag (the built-in impit and got-scraping
|
|
35
|
+
* clients do; the native fetch fallback cannot disable TLS verification and warns instead).
|
|
36
|
+
*
|
|
37
|
+
* @default true
|
|
33
38
|
*/
|
|
34
|
-
|
|
39
|
+
ignoreTlsErrors?: boolean;
|
|
35
40
|
/**
|
|
36
41
|
* Async functions that are sequentially evaluated before the navigation. Good for setting additional cookies
|
|
37
42
|
* or browser properties before navigation. The function accepts one parameter `crawlingContext`,
|
|
@@ -243,12 +248,11 @@ JSONData extends JsonValue = any> = RequestHandler<HttpCrawlingContext<UserData,
|
|
|
243
248
|
*/
|
|
244
249
|
export declare class HttpCrawler<Context extends InternalHttpCrawlingContext<any, any> = InternalHttpCrawlingContext, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>> extends BasicCrawler<Context, ContextExtension, ExtendedContext, Routes> {
|
|
245
250
|
#private;
|
|
246
|
-
private ignoreSslErrors;
|
|
247
251
|
protected static optionsShape: {
|
|
248
252
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
249
253
|
navigationTimeoutSecs: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
250
254
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
251
|
-
|
|
255
|
+
ignoreTlsErrors: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
252
256
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
253
257
|
additionalMimeTypes: import("ow").ArrayPredicate<string>;
|
|
254
258
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
@@ -113,15 +113,14 @@ export class HttpCrawler extends BasicCrawler {
|
|
|
113
113
|
#postNavigationHooks;
|
|
114
114
|
#saveResponseCookies;
|
|
115
115
|
#navigationTimeoutMillis;
|
|
116
|
-
|
|
117
|
-
ignoreSslErrors;
|
|
116
|
+
#ignoreTlsErrors;
|
|
118
117
|
#suggestResponseEncoding;
|
|
119
118
|
#forceResponseEncoding;
|
|
120
119
|
#supportedMimeTypes;
|
|
121
120
|
static optionsShape = {
|
|
122
121
|
...BasicCrawler.optionsShape,
|
|
123
122
|
navigationTimeoutSecs: ow.optional.number,
|
|
124
|
-
|
|
123
|
+
ignoreTlsErrors: ow.optional.boolean,
|
|
125
124
|
additionalMimeTypes: ow.optional.array.ofType(ow.string),
|
|
126
125
|
suggestResponseEncoding: ow.optional.string,
|
|
127
126
|
forceResponseEncoding: ow.optional.string,
|
|
@@ -134,7 +133,7 @@ export class HttpCrawler extends BasicCrawler {
|
|
|
134
133
|
*/
|
|
135
134
|
constructor(options = {}) {
|
|
136
135
|
ow(options, 'HttpCrawlerOptions', ow.object.exactShape(HttpCrawler.optionsShape));
|
|
137
|
-
const { navigationTimeoutSecs = 30,
|
|
136
|
+
const { navigationTimeoutSecs = 30, ignoreTlsErrors = true, additionalMimeTypes = [], suggestResponseEncoding, forceResponseEncoding, saveResponseCookies = true, preNavigationHooks = [], postNavigationHooks = [],
|
|
138
137
|
// BasicCrawler
|
|
139
138
|
contextPipelineBuilder, ...basicCrawlerOptions } = options;
|
|
140
139
|
super({
|
|
@@ -149,7 +148,7 @@ export class HttpCrawler extends BasicCrawler {
|
|
|
149
148
|
this.log.warning('Both forceResponseEncoding and suggestResponseEncoding options are set. Using forceResponseEncoding.');
|
|
150
149
|
}
|
|
151
150
|
this.#navigationTimeoutMillis = navigationTimeoutSecs * 1000;
|
|
152
|
-
this
|
|
151
|
+
this.#ignoreTlsErrors = ignoreTlsErrors;
|
|
153
152
|
this.#suggestResponseEncoding = suggestResponseEncoding;
|
|
154
153
|
this.#forceResponseEncoding = forceResponseEncoding;
|
|
155
154
|
// Cast away the extension-aware option types to the base internal storage types (see the field
|
|
@@ -436,22 +435,12 @@ export class HttpCrawler extends BasicCrawler {
|
|
|
436
435
|
timeout: this.#navigationTimeoutMillis,
|
|
437
436
|
sessionToken: session,
|
|
438
437
|
headers: request.headers,
|
|
439
|
-
https: {
|
|
440
|
-
rejectUnauthorized: !this.ignoreSslErrors,
|
|
441
|
-
},
|
|
442
438
|
body: undefined,
|
|
443
439
|
};
|
|
444
440
|
if (requestOptions.headers?.cookie || requestOptions.headers?.Cookie) {
|
|
445
441
|
requestOptions.headers.Cookie = this.getCookieHeaderFromRequest(request);
|
|
446
442
|
delete requestOptions.headers.cookie;
|
|
447
443
|
}
|
|
448
|
-
// Disable SSL verification for MITM proxies
|
|
449
|
-
if (session.proxyInfo?.ignoreTlsErrors) {
|
|
450
|
-
requestOptions.https = {
|
|
451
|
-
...requestOptions.https,
|
|
452
|
-
rejectUnauthorized: false,
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
444
|
if (/PATCH|POST|PUT/.test(request.method))
|
|
456
445
|
requestOptions.body = request.payload ?? '';
|
|
457
446
|
return requestOptions;
|
|
@@ -553,6 +542,7 @@ export class HttpCrawler extends BasicCrawler {
|
|
|
553
542
|
cookieJar,
|
|
554
543
|
signal: cancelSignal,
|
|
555
544
|
timeoutMillis: cancelSignal ? undefined : opts.timeout,
|
|
545
|
+
ignoreTlsErrors: this.#ignoreTlsErrors,
|
|
556
546
|
});
|
|
557
547
|
return response;
|
|
558
548
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/http",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.118",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -49,11 +49,11 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/timeout": "^0.4.4",
|
|
51
51
|
"@apify/utilities": "^2.15.5",
|
|
52
|
-
"@crawlee/basic": "4.0.0-beta.
|
|
53
|
-
"@crawlee/core": "4.0.0-beta.
|
|
54
|
-
"@crawlee/http-client": "4.0.0-beta.
|
|
55
|
-
"@crawlee/types": "4.0.0-beta.
|
|
56
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
52
|
+
"@crawlee/basic": "4.0.0-beta.118",
|
|
53
|
+
"@crawlee/core": "4.0.0-beta.118",
|
|
54
|
+
"@crawlee/http-client": "4.0.0-beta.118",
|
|
55
|
+
"@crawlee/types": "4.0.0-beta.118",
|
|
56
|
+
"@crawlee/utils": "4.0.0-beta.118",
|
|
57
57
|
"@types/content-type": "^1.1.8",
|
|
58
58
|
"cheerio": "^1.0.0",
|
|
59
59
|
"content-type": "^1.0.5",
|
|
@@ -70,5 +70,5 @@
|
|
|
70
70
|
}
|
|
71
71
|
}
|
|
72
72
|
},
|
|
73
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "7306bd05a126662898a4f2fe7779f6b53425cadf"
|
|
74
74
|
}
|