@crawlee/core 3.16.1-beta.8 → 3.17.0
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/autoscaling/autoscaled_pool.d.ts +2 -1
- package/autoscaling/autoscaled_pool.js +10 -1
- package/autoscaling/client_load_signal.d.ts +25 -0
- package/autoscaling/client_load_signal.js +39 -0
- package/autoscaling/cpu_load_signal.d.ts +28 -0
- package/autoscaling/cpu_load_signal.js +26 -0
- package/autoscaling/event_loop_load_signal.d.ts +23 -0
- package/autoscaling/event_loop_load_signal.js +38 -0
- package/autoscaling/index.d.ts +5 -1
- package/autoscaling/index.js +5 -1
- package/autoscaling/load_signal.d.ts +99 -0
- package/autoscaling/load_signal.js +150 -0
- package/autoscaling/memory_load_signal.d.ts +43 -0
- package/autoscaling/memory_load_signal.js +158 -0
- package/autoscaling/snapshotter.d.ts +26 -61
- package/autoscaling/snapshotter.js +76 -226
- package/autoscaling/system_status.d.ts +21 -33
- package/autoscaling/system_status.js +46 -93
- package/configuration.d.ts +0 -1
- package/configuration.js +0 -1
- package/cookie_utils.d.ts +0 -1
- package/cookie_utils.js +0 -1
- package/crawlers/crawler_commons.d.ts +0 -1
- package/crawlers/crawler_commons.js +0 -1
- package/crawlers/crawler_extension.d.ts +0 -1
- package/crawlers/crawler_extension.js +0 -1
- package/crawlers/crawler_utils.d.ts +0 -1
- package/crawlers/crawler_utils.js +0 -1
- package/crawlers/error_snapshotter.d.ts +0 -1
- package/crawlers/error_snapshotter.js +0 -1
- package/crawlers/error_tracker.d.ts +0 -1
- package/crawlers/error_tracker.js +0 -1
- package/crawlers/index.d.ts +0 -1
- package/crawlers/index.js +0 -1
- package/crawlers/statistics.d.ts +0 -1
- package/crawlers/statistics.js +0 -1
- package/enqueue_links/enqueue_links.d.ts +8 -1
- package/enqueue_links/enqueue_links.js +9 -9
- package/enqueue_links/index.d.ts +0 -1
- package/enqueue_links/index.js +0 -1
- package/enqueue_links/shared.d.ts +0 -1
- package/enqueue_links/shared.js +0 -1
- package/errors.d.ts +0 -1
- package/errors.js +0 -1
- package/events/event_manager.d.ts +0 -1
- package/events/event_manager.js +0 -1
- package/events/index.d.ts +0 -1
- package/events/index.js +0 -1
- package/events/local_event_manager.d.ts +1 -1
- package/events/local_event_manager.js +8 -8
- package/http_clients/base-http-client.d.ts +0 -1
- package/http_clients/base-http-client.js +0 -1
- package/http_clients/form-data-like.d.ts +0 -1
- package/http_clients/form-data-like.js +0 -1
- package/http_clients/got-scraping-http-client.d.ts +0 -1
- package/http_clients/got-scraping-http-client.js +0 -1
- package/http_clients/index.d.ts +0 -1
- package/http_clients/index.js +0 -1
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/index.mjs +6 -0
- package/log.d.ts +0 -1
- package/log.js +0 -1
- package/package.json +6 -6
- package/proxy_configuration.d.ts +0 -1
- package/proxy_configuration.js +0 -1
- package/recoverable_state.d.ts +0 -1
- package/recoverable_state.js +0 -1
- package/request.d.ts +0 -1
- package/request.js +0 -1
- package/router.d.ts +0 -1
- package/router.js +0 -1
- package/serialization.d.ts +0 -1
- package/serialization.js +0 -1
- package/session_pool/consts.d.ts +0 -1
- package/session_pool/consts.js +0 -1
- package/session_pool/errors.d.ts +0 -1
- package/session_pool/errors.js +0 -1
- package/session_pool/events.d.ts +0 -1
- package/session_pool/events.js +0 -1
- package/session_pool/index.d.ts +0 -1
- package/session_pool/index.js +0 -1
- package/session_pool/session.d.ts +0 -1
- package/session_pool/session.js +0 -1
- package/session_pool/session_pool.d.ts +0 -1
- package/session_pool/session_pool.js +0 -1
- package/storages/access_checking.d.ts +0 -1
- package/storages/access_checking.js +0 -1
- package/storages/dataset.d.ts +1 -2
- package/storages/dataset.js +0 -1
- package/storages/index.d.ts +0 -1
- package/storages/index.js +0 -1
- package/storages/key_value_store.d.ts +0 -1
- package/storages/key_value_store.js +0 -1
- package/storages/request_list.d.ts +0 -1
- package/storages/request_list.js +0 -1
- package/storages/request_list_adapter.d.ts +0 -1
- package/storages/request_list_adapter.js +0 -1
- package/storages/request_manager_tandem.d.ts +0 -1
- package/storages/request_manager_tandem.js +0 -1
- package/storages/request_provider.d.ts +17 -1
- package/storages/request_provider.js +46 -18
- package/storages/request_queue.d.ts +0 -1
- package/storages/request_queue.js +0 -1
- package/storages/request_queue_v2.d.ts +0 -1
- package/storages/request_queue_v2.js +0 -2
- package/storages/sitemap_request_list.d.ts +0 -1
- package/storages/sitemap_request_list.js +0 -1
- package/storages/storage_manager.d.ts +0 -1
- package/storages/storage_manager.js +21 -18
- package/storages/utils.d.ts +0 -1
- package/storages/utils.js +0 -1
- package/typedefs.d.ts +0 -1
- package/typedefs.js +0 -1
- package/validators.d.ts +0 -1
- package/validators.js +0 -1
- package/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/autoscaling/autoscaled_pool.js.map +0 -1
- package/autoscaling/index.d.ts.map +0 -1
- package/autoscaling/index.js.map +0 -1
- package/autoscaling/snapshotter.d.ts.map +0 -1
- package/autoscaling/snapshotter.js.map +0 -1
- package/autoscaling/system_status.d.ts.map +0 -1
- package/autoscaling/system_status.js.map +0 -1
- package/configuration.d.ts.map +0 -1
- package/configuration.js.map +0 -1
- package/cookie_utils.d.ts.map +0 -1
- package/cookie_utils.js.map +0 -1
- package/crawlers/crawler_commons.d.ts.map +0 -1
- package/crawlers/crawler_commons.js.map +0 -1
- package/crawlers/crawler_extension.d.ts.map +0 -1
- package/crawlers/crawler_extension.js.map +0 -1
- package/crawlers/crawler_utils.d.ts.map +0 -1
- package/crawlers/crawler_utils.js.map +0 -1
- package/crawlers/error_snapshotter.d.ts.map +0 -1
- package/crawlers/error_snapshotter.js.map +0 -1
- package/crawlers/error_tracker.d.ts.map +0 -1
- package/crawlers/error_tracker.js.map +0 -1
- package/crawlers/index.d.ts.map +0 -1
- package/crawlers/index.js.map +0 -1
- package/crawlers/statistics.d.ts.map +0 -1
- package/crawlers/statistics.js.map +0 -1
- package/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/enqueue_links/enqueue_links.js.map +0 -1
- package/enqueue_links/index.d.ts.map +0 -1
- package/enqueue_links/index.js.map +0 -1
- package/enqueue_links/shared.d.ts.map +0 -1
- package/enqueue_links/shared.js.map +0 -1
- package/errors.d.ts.map +0 -1
- package/errors.js.map +0 -1
- package/events/event_manager.d.ts.map +0 -1
- package/events/event_manager.js.map +0 -1
- package/events/index.d.ts.map +0 -1
- package/events/index.js.map +0 -1
- package/events/local_event_manager.d.ts.map +0 -1
- package/events/local_event_manager.js.map +0 -1
- package/http_clients/base-http-client.d.ts.map +0 -1
- package/http_clients/base-http-client.js.map +0 -1
- package/http_clients/form-data-like.d.ts.map +0 -1
- package/http_clients/form-data-like.js.map +0 -1
- package/http_clients/got-scraping-http-client.d.ts.map +0 -1
- package/http_clients/got-scraping-http-client.js.map +0 -1
- package/http_clients/index.d.ts.map +0 -1
- package/http_clients/index.js.map +0 -1
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/log.d.ts.map +0 -1
- package/log.js.map +0 -1
- package/proxy_configuration.d.ts.map +0 -1
- package/proxy_configuration.js.map +0 -1
- package/recoverable_state.d.ts.map +0 -1
- package/recoverable_state.js.map +0 -1
- package/request.d.ts.map +0 -1
- package/request.js.map +0 -1
- package/router.d.ts.map +0 -1
- package/router.js.map +0 -1
- package/serialization.d.ts.map +0 -1
- package/serialization.js.map +0 -1
- package/session_pool/consts.d.ts.map +0 -1
- package/session_pool/consts.js.map +0 -1
- package/session_pool/errors.d.ts.map +0 -1
- package/session_pool/errors.js.map +0 -1
- package/session_pool/events.d.ts.map +0 -1
- package/session_pool/events.js.map +0 -1
- package/session_pool/index.d.ts.map +0 -1
- package/session_pool/index.js.map +0 -1
- package/session_pool/session.d.ts.map +0 -1
- package/session_pool/session.js.map +0 -1
- package/session_pool/session_pool.d.ts.map +0 -1
- package/session_pool/session_pool.js.map +0 -1
- package/storages/access_checking.d.ts.map +0 -1
- package/storages/access_checking.js.map +0 -1
- package/storages/dataset.d.ts.map +0 -1
- package/storages/dataset.js.map +0 -1
- package/storages/index.d.ts.map +0 -1
- package/storages/index.js.map +0 -1
- package/storages/key_value_store.d.ts.map +0 -1
- package/storages/key_value_store.js.map +0 -1
- package/storages/request_list.d.ts.map +0 -1
- package/storages/request_list.js.map +0 -1
- package/storages/request_list_adapter.d.ts.map +0 -1
- package/storages/request_list_adapter.js.map +0 -1
- package/storages/request_manager_tandem.d.ts.map +0 -1
- package/storages/request_manager_tandem.js.map +0 -1
- package/storages/request_provider.d.ts.map +0 -1
- package/storages/request_provider.js.map +0 -1
- package/storages/request_queue.d.ts.map +0 -1
- package/storages/request_queue.js.map +0 -1
- package/storages/request_queue_v2.d.ts.map +0 -1
- package/storages/request_queue_v2.js.map +0 -1
- package/storages/sitemap_request_list.d.ts.map +0 -1
- package/storages/sitemap_request_list.js.map +0 -1
- package/storages/storage_manager.d.ts.map +0 -1
- package/storages/storage_manager.js.map +0 -1
- package/storages/utils.d.ts.map +0 -1
- package/storages/utils.js.map +0 -1
- package/typedefs.d.ts.map +0 -1
- package/typedefs.js.map +0 -1
- package/validators.d.ts.map +0 -1
- package/validators.js.map +0 -1
|
@@ -2,9 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SystemStatus = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
|
-
const utils_1 = require("@crawlee/utils");
|
|
6
5
|
const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
6
|
+
const load_signal_1 = require("./load_signal");
|
|
7
7
|
const snapshotter_1 = require("./snapshotter");
|
|
8
|
+
/** The four built-in signal names that map to typed `SystemInfo` fields. */
|
|
9
|
+
const BUILTIN_SIGNAL_NAMES = new Set(['memInfo', 'eventLoopInfo', 'cpuInfo', 'clientInfo']);
|
|
8
10
|
/**
|
|
9
11
|
* Provides a simple interface to reading system status from a {@link Snapshotter} instance.
|
|
10
12
|
* It only exposes two functions {@link SystemStatus.getCurrentStatus}
|
|
@@ -35,31 +37,24 @@ class SystemStatus {
|
|
|
35
37
|
writable: true,
|
|
36
38
|
value: void 0
|
|
37
39
|
});
|
|
38
|
-
Object.defineProperty(this, "
|
|
39
|
-
enumerable: true,
|
|
40
|
-
configurable: true,
|
|
41
|
-
writable: true,
|
|
42
|
-
value: void 0
|
|
43
|
-
});
|
|
44
|
-
Object.defineProperty(this, "maxEventLoopOverloadedRatio", {
|
|
45
|
-
enumerable: true,
|
|
46
|
-
configurable: true,
|
|
47
|
-
writable: true,
|
|
48
|
-
value: void 0
|
|
49
|
-
});
|
|
50
|
-
Object.defineProperty(this, "maxCpuOverloadedRatio", {
|
|
40
|
+
Object.defineProperty(this, "snapshotter", {
|
|
51
41
|
enumerable: true,
|
|
52
42
|
configurable: true,
|
|
53
43
|
writable: true,
|
|
54
44
|
value: void 0
|
|
55
45
|
});
|
|
56
|
-
Object.defineProperty(this, "
|
|
46
|
+
Object.defineProperty(this, "signals", {
|
|
57
47
|
enumerable: true,
|
|
58
48
|
configurable: true,
|
|
59
49
|
writable: true,
|
|
60
50
|
value: void 0
|
|
61
51
|
});
|
|
62
|
-
|
|
52
|
+
/**
|
|
53
|
+
* Per-signal ratio overrides. The built-in four get their overrides from
|
|
54
|
+
* the legacy `max*OverloadedRatio` options; custom signals use their own
|
|
55
|
+
* `overloadedRatio`.
|
|
56
|
+
*/
|
|
57
|
+
Object.defineProperty(this, "ratioOverrides", {
|
|
63
58
|
enumerable: true,
|
|
64
59
|
configurable: true,
|
|
65
60
|
writable: true,
|
|
@@ -72,15 +67,21 @@ class SystemStatus {
|
|
|
72
67
|
maxCpuOverloadedRatio: ow_1.default.optional.number,
|
|
73
68
|
maxClientOverloadedRatio: ow_1.default.optional.number,
|
|
74
69
|
snapshotter: ow_1.default.optional.object,
|
|
70
|
+
loadSignals: ow_1.default.optional.array,
|
|
75
71
|
config: ow_1.default.optional.object,
|
|
76
72
|
}));
|
|
77
|
-
const { currentHistorySecs = 5, maxMemoryOverloadedRatio = 0.2, maxEventLoopOverloadedRatio = 0.6, maxCpuOverloadedRatio = 0.4, maxClientOverloadedRatio = 0.3, snapshotter, config, } = options;
|
|
73
|
+
const { currentHistorySecs = 5, maxMemoryOverloadedRatio = 0.2, maxEventLoopOverloadedRatio = 0.6, maxCpuOverloadedRatio = 0.4, maxClientOverloadedRatio = 0.3, snapshotter, loadSignals = [], config, } = options;
|
|
78
74
|
this.currentHistoryMillis = currentHistorySecs * 1000;
|
|
79
|
-
this.maxMemoryOverloadedRatio = maxMemoryOverloadedRatio;
|
|
80
|
-
this.maxEventLoopOverloadedRatio = maxEventLoopOverloadedRatio;
|
|
81
|
-
this.maxCpuOverloadedRatio = maxCpuOverloadedRatio;
|
|
82
|
-
this.maxClientOverloadedRatio = maxClientOverloadedRatio;
|
|
83
75
|
this.snapshotter = snapshotter || new snapshotter_1.Snapshotter({ config });
|
|
76
|
+
// Built-in signals from the snapshotter + any custom signals
|
|
77
|
+
this.signals = [...this.snapshotter.getLoadSignals(), ...loadSignals];
|
|
78
|
+
// Allow legacy options to override the built-in signal ratios
|
|
79
|
+
this.ratioOverrides = {
|
|
80
|
+
memInfo: maxMemoryOverloadedRatio,
|
|
81
|
+
eventLoopInfo: maxEventLoopOverloadedRatio,
|
|
82
|
+
cpuInfo: maxCpuOverloadedRatio,
|
|
83
|
+
clientInfo: maxClientOverloadedRatio,
|
|
84
|
+
};
|
|
84
85
|
}
|
|
85
86
|
/**
|
|
86
87
|
* Returns an {@link SystemInfo} object with the following structure:
|
|
@@ -124,81 +125,33 @@ class SystemStatus {
|
|
|
124
125
|
* Returns a system status object.
|
|
125
126
|
*/
|
|
126
127
|
_isSystemIdle(sampleDurationMillis) {
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
!eventLoopInfo.isOverloaded &&
|
|
134
|
-
!cpuInfo.isOverloaded &&
|
|
135
|
-
!clientInfo.isOverloaded,
|
|
136
|
-
memInfo,
|
|
137
|
-
eventLoopInfo,
|
|
138
|
-
cpuInfo,
|
|
139
|
-
clientInfo,
|
|
128
|
+
const result = {
|
|
129
|
+
isSystemIdle: true,
|
|
130
|
+
memInfo: { isOverloaded: false, limitRatio: 0, actualRatio: 0 },
|
|
131
|
+
eventLoopInfo: { isOverloaded: false, limitRatio: 0, actualRatio: 0 },
|
|
132
|
+
cpuInfo: { isOverloaded: false, limitRatio: 0, actualRatio: 0 },
|
|
133
|
+
clientInfo: { isOverloaded: false, limitRatio: 0, actualRatio: 0 },
|
|
140
134
|
};
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
return this._isSampleOverloaded(sample, this.maxEventLoopOverloadedRatio);
|
|
157
|
-
}
|
|
158
|
-
/**
|
|
159
|
-
* Returns an object with an isOverloaded property set to true
|
|
160
|
-
* if the CPU has been overloaded in the last sampleDurationMillis.
|
|
161
|
-
*/
|
|
162
|
-
_isCpuOverloaded(sampleDurationMillis) {
|
|
163
|
-
const sample = this.snapshotter.getCpuSample(sampleDurationMillis);
|
|
164
|
-
return this._isSampleOverloaded(sample, this.maxCpuOverloadedRatio);
|
|
165
|
-
}
|
|
166
|
-
/**
|
|
167
|
-
* Returns an object with an isOverloaded property set to true
|
|
168
|
-
* if the client has been overloaded in the last sampleDurationMillis.
|
|
169
|
-
*/
|
|
170
|
-
_isClientOverloaded(sampleDurationMillis) {
|
|
171
|
-
const sample = this.snapshotter.getClientSample(sampleDurationMillis);
|
|
172
|
-
return this._isSampleOverloaded(sample, this.maxClientOverloadedRatio);
|
|
173
|
-
}
|
|
174
|
-
/**
|
|
175
|
-
* Returns an object with sample information and an isOverloaded property
|
|
176
|
-
* set to true if at least the ratio of snapshots in the sample are overloaded.
|
|
177
|
-
*/
|
|
178
|
-
_isSampleOverloaded(sample, ratio) {
|
|
179
|
-
if (sample.length === 0) {
|
|
180
|
-
return {
|
|
181
|
-
isOverloaded: false,
|
|
182
|
-
limitRatio: ratio,
|
|
183
|
-
actualRatio: 0,
|
|
184
|
-
};
|
|
135
|
+
let loadSignalInfo;
|
|
136
|
+
for (const signal of this.signals) {
|
|
137
|
+
const ratio = this.ratioOverrides[signal.name] ?? signal.overloadedRatio;
|
|
138
|
+
const sample = signal.getSample(sampleDurationMillis);
|
|
139
|
+
const info = (0, load_signal_1.evaluateLoadSignalSample)(sample, ratio);
|
|
140
|
+
if (info.isOverloaded) {
|
|
141
|
+
result.isSystemIdle = false;
|
|
142
|
+
}
|
|
143
|
+
if (BUILTIN_SIGNAL_NAMES.has(signal.name)) {
|
|
144
|
+
result[signal.name] = info;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
loadSignalInfo ?? (loadSignalInfo = {});
|
|
148
|
+
loadSignalInfo[signal.name] = info;
|
|
149
|
+
}
|
|
185
150
|
}
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
for (let i = 1; i < sample.length; i++) {
|
|
189
|
-
const previous = sample[i - 1];
|
|
190
|
-
const current = sample[i];
|
|
191
|
-
const weight = +current.createdAt - +previous.createdAt;
|
|
192
|
-
weights.push(weight || 1); // Prevent errors from 0ms long intervals (sync) between snapshots.
|
|
193
|
-
values.push(+current.isOverloaded);
|
|
151
|
+
if (loadSignalInfo) {
|
|
152
|
+
result.loadSignalInfo = loadSignalInfo;
|
|
194
153
|
}
|
|
195
|
-
|
|
196
|
-
return {
|
|
197
|
-
isOverloaded: wAvg > ratio,
|
|
198
|
-
limitRatio: ratio,
|
|
199
|
-
actualRatio: Math.round(wAvg * 1000) / 1000,
|
|
200
|
-
};
|
|
154
|
+
return result;
|
|
201
155
|
}
|
|
202
156
|
}
|
|
203
157
|
exports.SystemStatus = SystemStatus;
|
|
204
|
-
//# sourceMappingURL=system_status.js.map
|
package/configuration.d.ts
CHANGED
package/configuration.js
CHANGED
package/cookie_utils.d.ts
CHANGED
package/cookie_utils.js
CHANGED
package/crawlers/index.d.ts
CHANGED
package/crawlers/index.js
CHANGED
|
@@ -7,4 +7,3 @@ tslib_1.__exportStar(require("./crawler_utils"), exports);
|
|
|
7
7
|
tslib_1.__exportStar(require("./statistics"), exports);
|
|
8
8
|
tslib_1.__exportStar(require("./error_tracker"), exports);
|
|
9
9
|
tslib_1.__exportStar(require("./error_snapshotter"), exports);
|
|
10
|
-
//# sourceMappingURL=index.js.map
|
package/crawlers/statistics.d.ts
CHANGED
package/crawlers/statistics.js
CHANGED
|
@@ -139,6 +139,14 @@ export interface EnqueueLinksOptions extends RequestQueueOperationOptions {
|
|
|
139
139
|
* If provided, disallowed URLs will be ignored.
|
|
140
140
|
*/
|
|
141
141
|
robotsTxtFile?: Pick<RobotsTxtFile, 'isAllowed'>;
|
|
142
|
+
/**
|
|
143
|
+
* Mirrors {@link BasicCrawlerOptions.respectRobotsTxtFile}: pass `false` to disable filtering or
|
|
144
|
+
* `{ userAgent }` to evaluate rules for a specific user-agent. Defaults to `*` when
|
|
145
|
+
* {@link EnqueueLinksOptions.robotsTxtFile|`robotsTxtFile`} is provided.
|
|
146
|
+
*/
|
|
147
|
+
respectRobotsTxtFile?: boolean | {
|
|
148
|
+
userAgent?: string;
|
|
149
|
+
};
|
|
142
150
|
/**
|
|
143
151
|
* When a request is skipped for some reason, you can use this callback to act on it.
|
|
144
152
|
* This is currently fired for requests skipped
|
|
@@ -246,4 +254,3 @@ export interface ResolveBaseUrl {
|
|
|
246
254
|
originalRequestUrl: string;
|
|
247
255
|
finalRequestUrl?: string;
|
|
248
256
|
}
|
|
249
|
-
//# sourceMappingURL=enqueue_links.d.ts.map
|
|
@@ -95,6 +95,7 @@ async function enqueueLinks(options) {
|
|
|
95
95
|
urls: ow_1.default.array.ofType(ow_1.default.string),
|
|
96
96
|
requestQueue: ow_1.default.object.hasKeys('addRequestsBatched'),
|
|
97
97
|
robotsTxtFile: ow_1.default.optional.object.hasKeys('isAllowed'),
|
|
98
|
+
respectRobotsTxtFile: ow_1.default.optional.any(ow_1.default.boolean, ow_1.default.object.exactShape({ userAgent: ow_1.default.optional.string })),
|
|
98
99
|
onSkippedRequest: ow_1.default.optional.function,
|
|
99
100
|
forefront: ow_1.default.optional.boolean,
|
|
100
101
|
skipNavigation: ow_1.default.optional.boolean,
|
|
@@ -184,10 +185,11 @@ async function enqueueLinks(options) {
|
|
|
184
185
|
}
|
|
185
186
|
}
|
|
186
187
|
let requestOptions = (0, shared_1.createRequestOptions)(urls, options);
|
|
187
|
-
if (robotsTxtFile) {
|
|
188
|
+
if (robotsTxtFile && options.respectRobotsTxtFile !== false) {
|
|
189
|
+
const robotsUserAgent = typeof options.respectRobotsTxtFile === 'object' ? (options.respectRobotsTxtFile.userAgent ?? '*') : '*';
|
|
188
190
|
const skippedRequests = [];
|
|
189
191
|
requestOptions = requestOptions.filter((request) => {
|
|
190
|
-
if (robotsTxtFile.isAllowed(request.url)) {
|
|
192
|
+
if (robotsTxtFile.isAllowed(request.url, robotsUserAgent)) {
|
|
191
193
|
return true;
|
|
192
194
|
}
|
|
193
195
|
skippedRequests.push(request);
|
|
@@ -221,15 +223,14 @@ async function enqueueLinks(options) {
|
|
|
221
223
|
await reportSkippedRequests(skippedRequests.map((url) => ({ url })), 'filters');
|
|
222
224
|
return filtered;
|
|
223
225
|
}
|
|
224
|
-
|
|
225
|
-
if (typeof limit === 'number' && limit < requests.length) {
|
|
226
|
-
await reportSkippedRequests(requests.slice(limit), 'enqueueLimit');
|
|
227
|
-
requests = requests.slice(0, limit);
|
|
228
|
-
}
|
|
229
|
-
const { addedRequests } = await requestQueue.addRequestsBatched(requests, {
|
|
226
|
+
const { addedRequests, requestsOverLimit } = await requestQueue.addRequestsBatched(await createFilteredRequests(), {
|
|
230
227
|
forefront,
|
|
231
228
|
waitForAllRequestsToBeAdded,
|
|
229
|
+
maxNewRequests: limit,
|
|
232
230
|
});
|
|
231
|
+
if (requestsOverLimit?.length !== undefined && requestsOverLimit.length > 0) {
|
|
232
|
+
await reportSkippedRequests(requestsOverLimit.map((r) => ({ url: typeof r === 'string' ? r : r.url })), 'enqueueLimit');
|
|
233
|
+
}
|
|
233
234
|
return { processedRequests: addedRequests, unprocessedRequests: [] };
|
|
234
235
|
}
|
|
235
236
|
/**
|
|
@@ -272,4 +273,3 @@ function resolveBaseUrlForEnqueueLinksFiltering({ enqueueStrategy, finalRequestU
|
|
|
272
273
|
function ignoreHttpSchema(pattern) {
|
|
273
274
|
return pattern.replace(/^(https?):\/\//, 'http{s,}://');
|
|
274
275
|
}
|
|
275
|
-
//# sourceMappingURL=enqueue_links.js.map
|
package/enqueue_links/index.d.ts
CHANGED
package/enqueue_links/index.js
CHANGED
package/enqueue_links/shared.js
CHANGED
package/errors.d.ts
CHANGED
package/errors.js
CHANGED
package/events/event_manager.js
CHANGED
package/events/index.d.ts
CHANGED
package/events/index.js
CHANGED
|
@@ -96,14 +96,9 @@ class LocalEventManager extends event_manager_1.EventManager {
|
|
|
96
96
|
}
|
|
97
97
|
async createMemoryInfo() {
|
|
98
98
|
try {
|
|
99
|
-
|
|
100
|
-
const memInfo = await (0, utils_1.getMemoryInfoV2)(await this.isContainerizedWrapper());
|
|
101
|
-
return {
|
|
102
|
-
memCurrentBytes: memInfo.mainProcessBytes + memInfo.childProcessesBytes,
|
|
103
|
-
};
|
|
104
|
-
}
|
|
105
|
-
const memInfo = await (0, utils_1.getMemoryInfo)();
|
|
99
|
+
const memInfo = await this.getMemoryInfo();
|
|
106
100
|
return {
|
|
101
|
+
memTotalBytes: memInfo.totalBytes,
|
|
107
102
|
memCurrentBytes: memInfo.mainProcessBytes + memInfo.childProcessesBytes,
|
|
108
103
|
};
|
|
109
104
|
}
|
|
@@ -112,6 +107,11 @@ class LocalEventManager extends event_manager_1.EventManager {
|
|
|
112
107
|
return {};
|
|
113
108
|
}
|
|
114
109
|
}
|
|
110
|
+
async getMemoryInfo() {
|
|
111
|
+
if (this.config.get('systemInfoV2')) {
|
|
112
|
+
return (0, utils_1.getMemoryInfoV2)(await this.isContainerizedWrapper());
|
|
113
|
+
}
|
|
114
|
+
return (0, utils_1.getMemoryInfo)();
|
|
115
|
+
}
|
|
115
116
|
}
|
|
116
117
|
exports.LocalEventManager = LocalEventManager;
|
|
117
|
-
//# sourceMappingURL=local_event_manager.js.map
|
|
@@ -131,4 +131,3 @@ export interface BaseHttpClient {
|
|
|
131
131
|
*/
|
|
132
132
|
export declare function processHttpRequestOptions<TResponseType extends keyof ResponseTypes = 'text'>({ searchParams, form, json, username, password, ...request }: HttpRequestOptions<TResponseType>): HttpRequest<TResponseType>;
|
|
133
133
|
export {};
|
|
134
|
-
//# sourceMappingURL=base-http-client.d.ts.map
|
package/http_clients/index.d.ts
CHANGED
package/http_clients/index.js
CHANGED
package/index.d.ts
CHANGED
|
@@ -17,4 +17,3 @@ export * from './cookie_utils';
|
|
|
17
17
|
export * from './recoverable_state';
|
|
18
18
|
export { PseudoUrl } from '@apify/pseudo_url';
|
|
19
19
|
export { Dictionary, Awaitable, Constructor, StorageClient, Cookie, QueueOperationInfo } from '@crawlee/types';
|
|
20
|
-
//# sourceMappingURL=index.d.ts.map
|
package/index.js
CHANGED
|
@@ -21,4 +21,3 @@ tslib_1.__exportStar(require("./cookie_utils"), exports);
|
|
|
21
21
|
tslib_1.__exportStar(require("./recoverable_state"), exports);
|
|
22
22
|
var pseudo_url_1 = require("@apify/pseudo_url");
|
|
23
23
|
Object.defineProperty(exports, "PseudoUrl", { enumerable: true, get: function () { return pseudo_url_1.PseudoUrl; } });
|
|
24
|
-
//# sourceMappingURL=index.js.map
|
package/index.mjs
CHANGED
|
@@ -26,6 +26,7 @@ export const LoggerJson = mod.LoggerJson;
|
|
|
26
26
|
export const LoggerText = mod.LoggerText;
|
|
27
27
|
export const MAX_POOL_SIZE = mod.MAX_POOL_SIZE;
|
|
28
28
|
export const MAX_QUERIES_FOR_CONSISTENCY = mod.MAX_QUERIES_FOR_CONSISTENCY;
|
|
29
|
+
export const MemoryLoadSignal = mod.MemoryLoadSignal;
|
|
29
30
|
export const MissingRouteError = mod.MissingRouteError;
|
|
30
31
|
export const NonRetryableError = mod.NonRetryableError;
|
|
31
32
|
export const PERSIST_STATE_KEY = mod.PERSIST_STATE_KEY;
|
|
@@ -53,6 +54,7 @@ export const Session = mod.Session;
|
|
|
53
54
|
export const SessionError = mod.SessionError;
|
|
54
55
|
export const SessionPool = mod.SessionPool;
|
|
55
56
|
export const SitemapRequestList = mod.SitemapRequestList;
|
|
57
|
+
export const SnapshotStore = mod.SnapshotStore;
|
|
56
58
|
export const Snapshotter = mod.Snapshotter;
|
|
57
59
|
export const Statistics = mod.Statistics;
|
|
58
60
|
export const StorageManager = mod.StorageManager;
|
|
@@ -65,11 +67,15 @@ export const constructGlobObjectsFromGlobs = mod.constructGlobObjectsFromGlobs;
|
|
|
65
67
|
export const constructRegExpObjectsFromPseudoUrls = mod.constructRegExpObjectsFromPseudoUrls;
|
|
66
68
|
export const constructRegExpObjectsFromRegExps = mod.constructRegExpObjectsFromRegExps;
|
|
67
69
|
export const cookieStringToToughCookie = mod.cookieStringToToughCookie;
|
|
70
|
+
export const createClientLoadSignal = mod.createClientLoadSignal;
|
|
71
|
+
export const createCpuLoadSignal = mod.createCpuLoadSignal;
|
|
68
72
|
export const createDeserialize = mod.createDeserialize;
|
|
73
|
+
export const createEventLoopLoadSignal = mod.createEventLoopLoadSignal;
|
|
69
74
|
export const createRequestOptions = mod.createRequestOptions;
|
|
70
75
|
export const createRequests = mod.createRequests;
|
|
71
76
|
export const deserializeArray = mod.deserializeArray;
|
|
72
77
|
export const enqueueLinks = mod.enqueueLinks;
|
|
78
|
+
export const evaluateLoadSignalSample = mod.evaluateLoadSignalSample;
|
|
73
79
|
export const filterRequestsByPatterns = mod.filterRequestsByPatterns;
|
|
74
80
|
export const getCookiesFromResponse = mod.getCookiesFromResponse;
|
|
75
81
|
export const getDefaultCookieExpirationDate = mod.getDefaultCookieExpirationDate;
|
package/log.d.ts
CHANGED
package/log.js
CHANGED
|
@@ -9,4 +9,3 @@ Object.defineProperty(exports, "Logger", { enumerable: true, get: function () {
|
|
|
9
9
|
Object.defineProperty(exports, "LoggerJson", { enumerable: true, get: function () { return log_1.LoggerJson; } });
|
|
10
10
|
Object.defineProperty(exports, "LoggerText", { enumerable: true, get: function () { return log_1.LoggerText; } });
|
|
11
11
|
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return log_1.LogLevel; } });
|
|
12
|
-
//# sourceMappingURL=log.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/core",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.17.0",
|
|
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": ">=16.0.0"
|
|
@@ -59,14 +59,14 @@
|
|
|
59
59
|
"@apify/pseudo_url": "^2.0.30",
|
|
60
60
|
"@apify/timeout": "^0.3.0",
|
|
61
61
|
"@apify/utilities": "^2.7.10",
|
|
62
|
-
"@crawlee/memory-storage": "3.
|
|
63
|
-
"@crawlee/types": "3.
|
|
64
|
-
"@crawlee/utils": "3.
|
|
62
|
+
"@crawlee/memory-storage": "3.17.0",
|
|
63
|
+
"@crawlee/types": "3.17.0",
|
|
64
|
+
"@crawlee/utils": "3.17.0",
|
|
65
65
|
"@sapphire/async-queue": "^1.5.1",
|
|
66
66
|
"@vladfrangu/async_event_emitter": "^2.2.2",
|
|
67
67
|
"csv-stringify": "^6.2.0",
|
|
68
68
|
"fs-extra": "^11.0.0",
|
|
69
|
-
"got-scraping": "^4.
|
|
69
|
+
"got-scraping": "^4.2.1",
|
|
70
70
|
"json5": "^2.2.3",
|
|
71
71
|
"minimatch": "^9.0.0",
|
|
72
72
|
"ow": "^0.28.1",
|
|
@@ -83,5 +83,5 @@
|
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
85
|
},
|
|
86
|
-
"gitHead": "
|
|
86
|
+
"gitHead": "8f2663aedfd2280ca35b9185b4e287f65a2ce969"
|
|
87
87
|
}
|
package/proxy_configuration.d.ts
CHANGED
package/proxy_configuration.js
CHANGED
package/recoverable_state.d.ts
CHANGED
package/recoverable_state.js
CHANGED