@crawlee/core 4.0.0-beta.2 → 4.0.0-beta.200
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/README.md +17 -13
- package/byte_utils.d.ts +17 -0
- package/byte_utils.js +42 -0
- package/configuration.d.ts +88 -234
- package/configuration.js +162 -230
- package/debug.d.ts +36 -0
- package/debug.js +70 -0
- package/errors.d.ts +43 -10
- package/errors.js +57 -12
- package/events/event_manager.d.ts +35 -9
- package/events/event_manager.js +12 -13
- package/events/index.d.ts +1 -1
- package/events/index.js +0 -1
- package/events/local_event_manager.d.ts +15 -5
- package/events/local_event_manager.js +39 -42
- package/events/system_info.d.ts +38 -0
- package/events/system_info.js +1 -0
- package/index.d.ts +8 -11
- package/index.js +9 -10
- package/internal.d.ts +8 -0
- package/internal.js +9 -0
- package/iterables.d.ts +79 -0
- package/iterables.js +134 -0
- package/log.d.ts +81 -3
- package/log.js +134 -1
- package/memory-storage/consts.d.ts +4 -0
- package/memory-storage/consts.js +4 -0
- package/memory-storage/index.d.ts +1 -0
- package/memory-storage/index.js +1 -0
- package/memory-storage/memory-storage.d.ts +43 -0
- package/memory-storage/memory-storage.js +158 -0
- package/memory-storage/resource-clients/common/base-client.d.ts +4 -0
- package/memory-storage/resource-clients/common/base-client.js +6 -0
- package/memory-storage/resource-clients/dataset.d.ts +40 -0
- package/memory-storage/resource-clients/dataset.js +106 -0
- package/memory-storage/resource-clients/key-value-store.d.ts +56 -0
- package/memory-storage/resource-clients/key-value-store.js +180 -0
- package/memory-storage/resource-clients/request-queue.d.ts +77 -0
- package/memory-storage/resource-clients/request-queue.js +414 -0
- package/memory-storage/utils.d.ts +16 -0
- package/memory-storage/utils.js +41 -0
- package/owned_or_injected.d.ts +58 -0
- package/owned_or_injected.js +98 -0
- package/package.json +19 -20
- package/proxy_configuration.d.ts +29 -155
- package/proxy_configuration.js +38 -183
- package/recoverable_state.d.ts +177 -0
- package/recoverable_state.js +268 -0
- package/request.d.ts +62 -81
- package/request.js +125 -220
- package/serialization.d.ts +0 -1
- package/serialization.js +18 -18
- package/service_locator.d.ts +168 -0
- package/service_locator.js +255 -0
- package/storages/batched_adds.d.ts +37 -0
- package/storages/batched_adds.js +73 -0
- package/storages/dataset.d.ts +120 -56
- package/storages/dataset.js +299 -148
- package/storages/index.d.ts +9 -8
- package/storages/index.js +5 -8
- package/storages/key_value_store.d.ts +192 -65
- package/storages/key_value_store.js +453 -193
- package/storages/key_value_store_codec.d.ts +32 -0
- package/storages/key_value_store_codec.js +113 -0
- package/storages/request_dedup_cache.d.ts +22 -0
- package/storages/request_dedup_cache.js +48 -0
- package/storages/request_list.d.ts +55 -137
- package/storages/request_list.js +272 -245
- package/storages/request_loader.d.ts +127 -0
- package/storages/request_loader.js +36 -0
- package/storages/request_manager.d.ts +119 -0
- package/storages/request_manager.js +1 -0
- package/storages/request_manager_tandem.d.ts +94 -0
- package/storages/request_manager_tandem.js +200 -0
- package/storages/request_queue.d.ts +293 -48
- package/storages/request_queue.js +766 -216
- package/storages/storage_instance_manager.d.ts +86 -0
- package/storages/storage_instance_manager.js +256 -0
- package/storages/storage_stats.d.ts +48 -0
- package/storages/storage_stats.js +29 -0
- package/storages/transaction.d.ts +271 -0
- package/storages/transaction.js +296 -0
- package/storages/utils.d.ts +59 -11
- package/storages/utils.js +75 -15
- package/system-info/cpu-info.d.ts +67 -0
- package/system-info/cpu-info.js +216 -0
- package/system-info/memory-info.d.ts +31 -0
- package/system-info/memory-info.js +115 -0
- package/system-info/ps-tree.d.ts +17 -0
- package/system-info/ps-tree.js +144 -0
- package/system-info/runtime.d.ts +14 -0
- package/system-info/runtime.js +80 -0
- package/typedefs.d.ts +0 -6
- package/typedefs.js +0 -1
- package/url.d.ts +9 -0
- package/url.js +11 -0
- package/validators.d.ts +23 -18
- package/validators.js +14 -18
- package/autoscaling/autoscaled_pool.d.ts +0 -300
- package/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/autoscaling/autoscaled_pool.js +0 -533
- package/autoscaling/autoscaled_pool.js.map +0 -1
- package/autoscaling/index.d.ts +0 -4
- package/autoscaling/index.d.ts.map +0 -1
- package/autoscaling/index.js +0 -4
- package/autoscaling/index.js.map +0 -1
- package/autoscaling/snapshotter.d.ts +0 -189
- package/autoscaling/snapshotter.d.ts.map +0 -1
- package/autoscaling/snapshotter.js +0 -292
- package/autoscaling/snapshotter.js.map +0 -1
- package/autoscaling/system_status.d.ts +0 -181
- package/autoscaling/system_status.d.ts.map +0 -1
- package/autoscaling/system_status.js +0 -169
- 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 +0 -43
- package/cookie_utils.d.ts.map +0 -1
- package/cookie_utils.js +0 -113
- package/cookie_utils.js.map +0 -1
- package/crawlers/crawler_commons.d.ts +0 -199
- package/crawlers/crawler_commons.d.ts.map +0 -1
- package/crawlers/crawler_commons.js +0 -116
- package/crawlers/crawler_commons.js.map +0 -1
- package/crawlers/crawler_extension.d.ts +0 -12
- package/crawlers/crawler_extension.d.ts.map +0 -1
- package/crawlers/crawler_extension.js +0 -14
- package/crawlers/crawler_extension.js.map +0 -1
- package/crawlers/crawler_utils.d.ts +0 -10
- package/crawlers/crawler_utils.d.ts.map +0 -1
- package/crawlers/crawler_utils.js +0 -12
- package/crawlers/crawler_utils.js.map +0 -1
- package/crawlers/error_snapshotter.d.ts +0 -59
- package/crawlers/error_snapshotter.d.ts.map +0 -1
- package/crawlers/error_snapshotter.js +0 -118
- package/crawlers/error_snapshotter.js.map +0 -1
- package/crawlers/error_tracker.d.ts +0 -54
- package/crawlers/error_tracker.d.ts.map +0 -1
- package/crawlers/error_tracker.js +0 -309
- package/crawlers/error_tracker.js.map +0 -1
- package/crawlers/index.d.ts +0 -7
- package/crawlers/index.d.ts.map +0 -1
- package/crawlers/index.js +0 -7
- package/crawlers/index.js.map +0 -1
- package/crawlers/statistics.d.ts +0 -204
- package/crawlers/statistics.d.ts.map +0 -1
- package/crawlers/statistics.js +0 -346
- package/crawlers/statistics.js.map +0 -1
- package/enqueue_links/enqueue_links.d.ts +0 -242
- package/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/enqueue_links/enqueue_links.js +0 -250
- package/enqueue_links/enqueue_links.js.map +0 -1
- package/enqueue_links/index.d.ts +0 -3
- package/enqueue_links/index.d.ts.map +0 -1
- package/enqueue_links/index.js +0 -3
- package/enqueue_links/index.js.map +0 -1
- package/enqueue_links/shared.d.ts +0 -67
- package/enqueue_links/shared.d.ts.map +0 -1
- package/enqueue_links/shared.js +0 -190
- 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 +0 -134
- package/http_clients/base-http-client.d.ts.map +0 -1
- package/http_clients/base-http-client.js +0 -33
- package/http_clients/base-http-client.js.map +0 -1
- package/http_clients/form-data-like.d.ts +0 -67
- package/http_clients/form-data-like.d.ts.map +0 -1
- package/http_clients/form-data-like.js +0 -5
- package/http_clients/form-data-like.js.map +0 -1
- package/http_clients/got-scraping-http-client.d.ts +0 -15
- package/http_clients/got-scraping-http-client.d.ts.map +0 -1
- package/http_clients/got-scraping-http-client.js +0 -69
- package/http_clients/got-scraping-http-client.js.map +0 -1
- package/http_clients/index.d.ts +0 -3
- package/http_clients/index.d.ts.map +0 -1
- package/http_clients/index.js +0 -3
- 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/request.d.ts.map +0 -1
- package/request.js.map +0 -1
- package/router.d.ts +0 -134
- package/router.d.ts.map +0 -1
- package/router.js +0 -164
- 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 +0 -4
- package/session_pool/consts.d.ts.map +0 -1
- package/session_pool/consts.js +0 -4
- package/session_pool/consts.js.map +0 -1
- package/session_pool/errors.d.ts +0 -8
- package/session_pool/errors.d.ts.map +0 -1
- package/session_pool/errors.js +0 -12
- package/session_pool/errors.js.map +0 -1
- package/session_pool/events.d.ts +0 -3
- package/session_pool/events.d.ts.map +0 -1
- package/session_pool/events.js +0 -3
- package/session_pool/events.js.map +0 -1
- package/session_pool/index.d.ts +0 -6
- package/session_pool/index.d.ts.map +0 -1
- package/session_pool/index.js +0 -6
- package/session_pool/index.js.map +0 -1
- package/session_pool/session.d.ts +0 -199
- package/session_pool/session.d.ts.map +0 -1
- package/session_pool/session.js +0 -271
- package/session_pool/session.js.map +0 -1
- package/session_pool/session_pool.d.ts +0 -251
- package/session_pool/session_pool.d.ts.map +0 -1
- package/session_pool/session_pool.js +0 -375
- package/session_pool/session_pool.js.map +0 -1
- package/storages/access_checking.d.ts +0 -13
- package/storages/access_checking.d.ts.map +0 -1
- package/storages/access_checking.js +0 -14
- 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_provider.d.ts +0 -307
- package/storages/request_provider.d.ts.map +0 -1
- package/storages/request_provider.js +0 -555
- 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 +0 -87
- package/storages/request_queue_v2.d.ts.map +0 -1
- package/storages/request_queue_v2.js +0 -438
- package/storages/request_queue_v2.js.map +0 -1
- package/storages/sitemap_request_list.d.ts +0 -245
- package/storages/sitemap_request_list.d.ts.map +0 -1
- package/storages/sitemap_request_list.js +0 -430
- package/storages/sitemap_request_list.js.map +0 -1
- package/storages/storage_manager.d.ts +0 -58
- package/storages/storage_manager.d.ts.map +0 -1
- package/storages/storage_manager.js +0 -105
- package/storages/storage_manager.js.map +0 -1
- package/storages/utils.d.ts.map +0 -1
- package/storages/utils.js.map +0 -1
- package/tsconfig.build.tsbuildinfo +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
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { KeyValueStore } from '../storages/key_value_store.js';
|
|
2
|
-
/**
|
|
3
|
-
* A partial implementation of {@link RestrictedCrawlingContext} that stores parameters of calls to context methods for later inspection.
|
|
4
|
-
*
|
|
5
|
-
* @experimental
|
|
6
|
-
*/
|
|
7
|
-
export class RequestHandlerResult {
|
|
8
|
-
config;
|
|
9
|
-
crawleeStateKey;
|
|
10
|
-
_keyValueStoreChanges = {};
|
|
11
|
-
pushDataCalls = [];
|
|
12
|
-
addRequestsCalls = [];
|
|
13
|
-
enqueueLinksCalls = [];
|
|
14
|
-
constructor(config, crawleeStateKey) {
|
|
15
|
-
this.config = config;
|
|
16
|
-
this.crawleeStateKey = crawleeStateKey;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* A record of calls to {@link RestrictedCrawlingContext.pushData}, {@link RestrictedCrawlingContext.addRequests}, {@link RestrictedCrawlingContext.enqueueLinks} made by a request handler.
|
|
20
|
-
*/
|
|
21
|
-
get calls() {
|
|
22
|
-
return {
|
|
23
|
-
pushData: this.pushDataCalls,
|
|
24
|
-
addRequests: this.addRequestsCalls,
|
|
25
|
-
enqueueLinks: this.enqueueLinksCalls,
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* A record of changes made to key-value stores by a request handler.
|
|
30
|
-
*/
|
|
31
|
-
get keyValueStoreChanges() {
|
|
32
|
-
return this._keyValueStoreChanges;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Items added to datasets by a request handler.
|
|
36
|
-
*/
|
|
37
|
-
get datasetItems() {
|
|
38
|
-
return this.pushDataCalls.flatMap(([data, datasetIdOrName]) => (Array.isArray(data) ? data : [data]).map((item) => ({ item, datasetIdOrName })));
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* URLs enqueued to the request queue by a request handler, either via {@link RestrictedCrawlingContext.addRequests} or {@link RestrictedCrawlingContext.enqueueLinks}
|
|
42
|
-
*/
|
|
43
|
-
get enqueuedUrls() {
|
|
44
|
-
const result = [];
|
|
45
|
-
for (const [options] of this.enqueueLinksCalls) {
|
|
46
|
-
result.push(...(options?.urls?.map((url) => ({ url, label: options?.label })) ?? []));
|
|
47
|
-
}
|
|
48
|
-
for (const [requests] of this.addRequestsCalls) {
|
|
49
|
-
for (const request of requests) {
|
|
50
|
-
if (typeof request === 'object' &&
|
|
51
|
-
(!('requestsFromUrl' in request) || request.requestsFromUrl !== undefined) &&
|
|
52
|
-
request.url !== undefined) {
|
|
53
|
-
result.push({ url: request.url, label: request.label });
|
|
54
|
-
}
|
|
55
|
-
else if (typeof request === 'string') {
|
|
56
|
-
result.push({ url: request });
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return result;
|
|
61
|
-
}
|
|
62
|
-
/**
|
|
63
|
-
* URL lists enqueued to the request queue by a request handler via {@link RestrictedCrawlingContext.addRequests} using the `requestsFromUrl` option.
|
|
64
|
-
*/
|
|
65
|
-
get enqueuedUrlLists() {
|
|
66
|
-
const result = [];
|
|
67
|
-
for (const [requests] of this.addRequestsCalls) {
|
|
68
|
-
for (const request of requests) {
|
|
69
|
-
if (typeof request === 'object' &&
|
|
70
|
-
'requestsFromUrl' in request &&
|
|
71
|
-
request.requestsFromUrl !== undefined) {
|
|
72
|
-
result.push({ listUrl: request.requestsFromUrl, label: request.label });
|
|
73
|
-
}
|
|
74
|
-
}
|
|
75
|
-
}
|
|
76
|
-
return result;
|
|
77
|
-
}
|
|
78
|
-
pushData = async (data, datasetIdOrName) => {
|
|
79
|
-
this.pushDataCalls.push([data, datasetIdOrName]);
|
|
80
|
-
};
|
|
81
|
-
enqueueLinks = async (options) => {
|
|
82
|
-
this.enqueueLinksCalls.push([options]);
|
|
83
|
-
};
|
|
84
|
-
addRequests = async (requests, options = {}) => {
|
|
85
|
-
this.addRequestsCalls.push([requests, options]);
|
|
86
|
-
};
|
|
87
|
-
useState = async (defaultValue) => {
|
|
88
|
-
const store = await this.getKeyValueStore(undefined);
|
|
89
|
-
return await store.getAutoSavedValue(this.crawleeStateKey, defaultValue);
|
|
90
|
-
};
|
|
91
|
-
getKeyValueStore = async (idOrName) => {
|
|
92
|
-
const store = await KeyValueStore.open(idOrName, { config: this.config });
|
|
93
|
-
return {
|
|
94
|
-
id: this.idOrDefault(idOrName),
|
|
95
|
-
name: idOrName,
|
|
96
|
-
getValue: async (key) => this.getKeyValueStoreChangedValue(idOrName, key) ?? (await store.getValue(key)),
|
|
97
|
-
setValue: async (key, value, options) => {
|
|
98
|
-
this.setKeyValueStoreChangedValue(idOrName, key, value, options);
|
|
99
|
-
},
|
|
100
|
-
getAutoSavedValue: store.getAutoSavedValue.bind(store),
|
|
101
|
-
getPublicUrl: store.getPublicUrl.bind(store),
|
|
102
|
-
};
|
|
103
|
-
};
|
|
104
|
-
idOrDefault = (idOrName) => idOrName ?? this.config.get('defaultKeyValueStoreId');
|
|
105
|
-
getKeyValueStoreChangedValue = (idOrName, key) => {
|
|
106
|
-
const id = this.idOrDefault(idOrName);
|
|
107
|
-
this._keyValueStoreChanges[id] ??= {};
|
|
108
|
-
return this.keyValueStoreChanges[id][key]?.changedValue ?? null;
|
|
109
|
-
};
|
|
110
|
-
setKeyValueStoreChangedValue = (idOrName, key, changedValue, options) => {
|
|
111
|
-
const id = this.idOrDefault(idOrName);
|
|
112
|
-
this._keyValueStoreChanges[id] ??= {};
|
|
113
|
-
this._keyValueStoreChanges[id][key] = { changedValue, options };
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
//# sourceMappingURL=crawler_commons.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crawler_commons.js","sourceRoot":"","sources":["../../src/crawlers/crawler_commons.ts"],"names":[],"mappings":"AAWA,OAAO,EAAE,aAAa,EAAsB,MAAM,gCAAgC,CAAC;AA6JnF;;;;GAIG;AACH,MAAM,OAAO,oBAAoB;IAWjB;IACA;IAXJ,qBAAqB,GACzB,EAAE,CAAC;IAEC,aAAa,GAAwD,EAAE,CAAC;IAExE,gBAAgB,GAA2D,EAAE,CAAC;IAE9E,iBAAiB,GAA4D,EAAE,CAAC;IAExF,YACY,MAAqB,EACrB,eAAuB;QADvB,WAAM,GAAN,MAAM,CAAe;QACrB,oBAAe,GAAf,eAAe,CAAQ;IAChC,CAAC;IAEJ;;OAEG;IACH,IAAI,KAAK;QAKL,OAAO;YACH,QAAQ,EAAE,IAAI,CAAC,aAAa;YAC5B,WAAW,EAAE,IAAI,CAAC,gBAAgB;YAClC,YAAY,EAAE,IAAI,CAAC,iBAAiB;SACvC,CAAC;IACN,CAAC;IAED;;OAEG;IACH,IAAI,oBAAoB;QAGpB,OAAO,IAAI,CAAC,qBAAqB,CAAC;IACtC,CAAC;IAED;;OAEG;IACH,IAAI,YAAY;QACZ,OAAO,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,eAAe,CAAC,EAAE,EAAE,CAC1D,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,EAAE,IAAI,EAAE,eAAe,EAAE,CAAC,CAAC,CACnF,CAAC;IACN,CAAC;IAED;;O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C,GAAG,EAAE,YAAY,EAAE,OAAO,EAAE,CAAC;IACpE,CAAC,CAAC;CACL"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { type Log } from '../log.js';
|
|
2
|
-
/**
|
|
3
|
-
* Abstract class with pre-defined method to connect to the Crawlers class by the "use" crawler method.
|
|
4
|
-
* @category Crawlers
|
|
5
|
-
* @ignore
|
|
6
|
-
*/
|
|
7
|
-
export declare abstract class CrawlerExtension {
|
|
8
|
-
name: string;
|
|
9
|
-
log: Log;
|
|
10
|
-
getCrawlerOptions(): Record<string, unknown>;
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=crawler_extension.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crawler_extension.d.ts","sourceRoot":"","sources":["../../src/crawlers/crawler_extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,GAAG,EAAqB,MAAM,WAAW,CAAC;AAExD;;;;GAIG;AACH,8BAAsB,gBAAgB;IAClC,IAAI,SAAyB;IAC7B,GAAG,EAAE,GAAG,CAA2C;IAEnD,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;CAG/C"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { log as defaultLog } from '../log.js';
|
|
2
|
-
/**
|
|
3
|
-
* Abstract class with pre-defined method to connect to the Crawlers class by the "use" crawler method.
|
|
4
|
-
* @category Crawlers
|
|
5
|
-
* @ignore
|
|
6
|
-
*/
|
|
7
|
-
export class CrawlerExtension {
|
|
8
|
-
name = this.constructor.name;
|
|
9
|
-
log = defaultLog.child({ prefix: this.name });
|
|
10
|
-
getCrawlerOptions() {
|
|
11
|
-
throw new Error(`${this.name} has not implemented "getCrawlerOptions" method.`);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=crawler_extension.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crawler_extension.js","sourceRoot":"","sources":["../../src/crawlers/crawler_extension.ts"],"names":[],"mappings":"AAAA,OAAO,EAAY,GAAG,IAAI,UAAU,EAAE,MAAM,WAAW,CAAC;AAExD;;;;GAIG;AACH,MAAM,OAAgB,gBAAgB;IAClC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;IAC7B,GAAG,GAAQ,UAAU,CAAC,KAAK,CAAC,EAAE,MAAM,EAAE,IAAI,CAAC,IAAI,EAAE,CAAC,CAAC;IAEnD,iBAAiB;QACb,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,CAAC,IAAI,kDAAkD,CAAC,CAAC;IACpF,CAAC;CACJ"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import type { Session } from '../session_pool/session.js';
|
|
2
|
-
/**
|
|
3
|
-
* Handles timeout request
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export declare function handleRequestTimeout({ session, errorMessage }: {
|
|
7
|
-
session?: Session;
|
|
8
|
-
errorMessage: string;
|
|
9
|
-
}): void;
|
|
10
|
-
//# sourceMappingURL=crawler_utils.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crawler_utils.d.ts","sourceRoot":"","sources":["../../src/crawlers/crawler_utils.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAE1D;;;GAGG;AACH,wBAAgB,oBAAoB,CAAC,EAAE,OAAO,EAAE,YAAY,EAAE,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAE,QAK1G"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { TimeoutError } from '@apify/timeout';
|
|
2
|
-
/**
|
|
3
|
-
* Handles timeout request
|
|
4
|
-
* @internal
|
|
5
|
-
*/
|
|
6
|
-
export function handleRequestTimeout({ session, errorMessage }) {
|
|
7
|
-
session?.markBad();
|
|
8
|
-
const timeoutMillis = errorMessage.match(/(\d+)\s?ms/)?.[1]; // first capturing group
|
|
9
|
-
const timeoutSecs = Number(timeoutMillis) / 1000;
|
|
10
|
-
throw new TimeoutError(`Navigation timed out after ${timeoutSecs} seconds.`);
|
|
11
|
-
}
|
|
12
|
-
//# sourceMappingURL=crawler_utils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"crawler_utils.js","sourceRoot":"","sources":["../../src/crawlers/crawler_utils.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAI9C;;;GAGG;AACH,MAAM,UAAU,oBAAoB,CAAC,EAAE,OAAO,EAAE,YAAY,EAA+C;IACvG,OAAO,EAAE,OAAO,EAAE,CAAC;IACnB,MAAM,aAAa,GAAG,YAAY,CAAC,KAAK,CAAC,YAAY,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,wBAAwB;IACrF,MAAM,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC;IACjD,MAAM,IAAI,YAAY,CAAC,8BAA8B,WAAW,WAAW,CAAC,CAAC;AACjF,CAAC"}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import type { CrawlingContext } from '../crawlers/crawler_commons.js';
|
|
2
|
-
import type { KeyValueStore } from '../storages/key_value_store.js';
|
|
3
|
-
import type { ErrnoException } from './error_tracker.js';
|
|
4
|
-
interface BrowserCrawlingContext {
|
|
5
|
-
saveSnapshot: (options: {
|
|
6
|
-
key: string;
|
|
7
|
-
}) => Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
export interface SnapshotResult {
|
|
10
|
-
screenshotFileName?: string;
|
|
11
|
-
htmlFileName?: string;
|
|
12
|
-
}
|
|
13
|
-
interface ErrorSnapshot {
|
|
14
|
-
screenshotFileName?: string;
|
|
15
|
-
screenshotFileUrl?: string;
|
|
16
|
-
htmlFileName?: string;
|
|
17
|
-
htmlFileUrl?: string;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* ErrorSnapshotter class is used to capture a screenshot of the page and a snapshot of the HTML when an error occurs during web crawling.
|
|
21
|
-
*
|
|
22
|
-
* This functionality is opt-in, and can be enabled via the crawler options:
|
|
23
|
-
*
|
|
24
|
-
* ```ts
|
|
25
|
-
* const crawler = new BasicCrawler({
|
|
26
|
-
* // ...
|
|
27
|
-
* statisticsOptions: {
|
|
28
|
-
* saveErrorSnapshots: true,
|
|
29
|
-
* },
|
|
30
|
-
* });
|
|
31
|
-
* ```
|
|
32
|
-
*/
|
|
33
|
-
export declare class ErrorSnapshotter {
|
|
34
|
-
static readonly MAX_ERROR_CHARACTERS = 30;
|
|
35
|
-
static readonly MAX_HASH_LENGTH = 30;
|
|
36
|
-
static readonly MAX_FILENAME_LENGTH = 250;
|
|
37
|
-
static readonly BASE_MESSAGE = "An error occurred";
|
|
38
|
-
static readonly SNAPSHOT_PREFIX = "ERROR_SNAPSHOT";
|
|
39
|
-
/**
|
|
40
|
-
* Capture a snapshot of the error context.
|
|
41
|
-
*/
|
|
42
|
-
captureSnapshot(error: ErrnoException, context: CrawlingContext): Promise<ErrorSnapshot>;
|
|
43
|
-
/**
|
|
44
|
-
* Captures a snapshot of the current page using the context.saveSnapshot function.
|
|
45
|
-
* This function is applicable for browser contexts only.
|
|
46
|
-
* Returns an object containing the filenames of the screenshot and HTML file.
|
|
47
|
-
*/
|
|
48
|
-
contextCaptureSnapshot(context: BrowserCrawlingContext, fileName: string): Promise<SnapshotResult | undefined>;
|
|
49
|
-
/**
|
|
50
|
-
* Save the HTML snapshot of the page, and return the fileName with the extension.
|
|
51
|
-
*/
|
|
52
|
-
saveHTMLSnapshot(html: string, keyValueStore: KeyValueStore, fileName: string): Promise<string | undefined>;
|
|
53
|
-
/**
|
|
54
|
-
* Generate a unique fileName for each error snapshot.
|
|
55
|
-
*/
|
|
56
|
-
generateFilename(error: ErrnoException): string;
|
|
57
|
-
}
|
|
58
|
-
export {};
|
|
59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AAG,SAAS,CAAC;IAYtC;;OAEG;IACG,gBAAgB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC;IASjH;;OAEG;IACH,gBAAgB,CAAC,KAAK,EAAE,cAAc,GAAG,MAAM;CAyBlD"}
|
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import crypto from 'node:crypto';
|
|
2
|
-
/**
|
|
3
|
-
* ErrorSnapshotter class is used to capture a screenshot of the page and a snapshot of the HTML when an error occurs during web crawling.
|
|
4
|
-
*
|
|
5
|
-
* This functionality is opt-in, and can be enabled via the crawler options:
|
|
6
|
-
*
|
|
7
|
-
* ```ts
|
|
8
|
-
* const crawler = new BasicCrawler({
|
|
9
|
-
* // ...
|
|
10
|
-
* statisticsOptions: {
|
|
11
|
-
* saveErrorSnapshots: true,
|
|
12
|
-
* },
|
|
13
|
-
* });
|
|
14
|
-
* ```
|
|
15
|
-
*/
|
|
16
|
-
export class ErrorSnapshotter {
|
|
17
|
-
static MAX_ERROR_CHARACTERS = 30;
|
|
18
|
-
static MAX_HASH_LENGTH = 30;
|
|
19
|
-
static MAX_FILENAME_LENGTH = 250;
|
|
20
|
-
static BASE_MESSAGE = 'An error occurred';
|
|
21
|
-
static SNAPSHOT_PREFIX = 'ERROR_SNAPSHOT';
|
|
22
|
-
/**
|
|
23
|
-
* Capture a snapshot of the error context.
|
|
24
|
-
*/
|
|
25
|
-
async captureSnapshot(error, context) {
|
|
26
|
-
try {
|
|
27
|
-
const page = context?.page;
|
|
28
|
-
const body = context?.body;
|
|
29
|
-
const keyValueStore = await context?.getKeyValueStore();
|
|
30
|
-
// If the key-value store is not available, or the body and page are not available, return empty filenames
|
|
31
|
-
if (!keyValueStore || (!body && !page)) {
|
|
32
|
-
return {};
|
|
33
|
-
}
|
|
34
|
-
const fileName = this.generateFilename(error);
|
|
35
|
-
let screenshotFileName;
|
|
36
|
-
let htmlFileName;
|
|
37
|
-
if (page) {
|
|
38
|
-
const capturedFiles = await this.contextCaptureSnapshot(context, fileName);
|
|
39
|
-
if (capturedFiles) {
|
|
40
|
-
screenshotFileName = capturedFiles.screenshotFileName;
|
|
41
|
-
htmlFileName = capturedFiles.htmlFileName;
|
|
42
|
-
}
|
|
43
|
-
// If the snapshot for browsers failed to capture the HTML, try to capture it from the page content
|
|
44
|
-
if (!htmlFileName) {
|
|
45
|
-
const html = await page.content();
|
|
46
|
-
htmlFileName = html ? await this.saveHTMLSnapshot(html, keyValueStore, fileName) : undefined;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
else if (typeof body === 'string') {
|
|
50
|
-
// for non-browser contexts
|
|
51
|
-
htmlFileName = await this.saveHTMLSnapshot(body, keyValueStore, fileName);
|
|
52
|
-
}
|
|
53
|
-
return {
|
|
54
|
-
screenshotFileName,
|
|
55
|
-
screenshotFileUrl: screenshotFileName && keyValueStore.getPublicUrl(screenshotFileName),
|
|
56
|
-
htmlFileName,
|
|
57
|
-
htmlFileUrl: htmlFileName && keyValueStore.getPublicUrl(htmlFileName),
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
catch {
|
|
61
|
-
return {};
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Captures a snapshot of the current page using the context.saveSnapshot function.
|
|
66
|
-
* This function is applicable for browser contexts only.
|
|
67
|
-
* Returns an object containing the filenames of the screenshot and HTML file.
|
|
68
|
-
*/
|
|
69
|
-
async contextCaptureSnapshot(context, fileName) {
|
|
70
|
-
try {
|
|
71
|
-
await context.saveSnapshot({ key: fileName });
|
|
72
|
-
return {
|
|
73
|
-
screenshotFileName: `${fileName}.jpg`,
|
|
74
|
-
htmlFileName: `${fileName}.html`,
|
|
75
|
-
};
|
|
76
|
-
}
|
|
77
|
-
catch {
|
|
78
|
-
return undefined;
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
/**
|
|
82
|
-
* Save the HTML snapshot of the page, and return the fileName with the extension.
|
|
83
|
-
*/
|
|
84
|
-
async saveHTMLSnapshot(html, keyValueStore, fileName) {
|
|
85
|
-
try {
|
|
86
|
-
await keyValueStore.setValue(fileName, html, { contentType: 'text/html' });
|
|
87
|
-
return `${fileName}.html`;
|
|
88
|
-
}
|
|
89
|
-
catch {
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
/**
|
|
94
|
-
* Generate a unique fileName for each error snapshot.
|
|
95
|
-
*/
|
|
96
|
-
generateFilename(error) {
|
|
97
|
-
const { SNAPSHOT_PREFIX, BASE_MESSAGE, MAX_HASH_LENGTH, MAX_ERROR_CHARACTERS, MAX_FILENAME_LENGTH } = ErrorSnapshotter;
|
|
98
|
-
// Create a hash of the error stack trace
|
|
99
|
-
const errorStackHash = crypto
|
|
100
|
-
.createHash('sha1')
|
|
101
|
-
.update(error.stack || error.message || '')
|
|
102
|
-
.digest('hex')
|
|
103
|
-
.slice(0, MAX_HASH_LENGTH);
|
|
104
|
-
const errorMessagePrefix = (error.message || BASE_MESSAGE).slice(0, MAX_ERROR_CHARACTERS).trim();
|
|
105
|
-
/**
|
|
106
|
-
* Remove non-word characters from the start and end of a string.
|
|
107
|
-
*/
|
|
108
|
-
const sanitizeString = (str) => {
|
|
109
|
-
return str.replace(/^\W+|\W+$/g, '');
|
|
110
|
-
};
|
|
111
|
-
// Generate fileName and remove disallowed characters
|
|
112
|
-
const fileName = `${SNAPSHOT_PREFIX}_${sanitizeString(errorStackHash)}_${sanitizeString(errorMessagePrefix)}`
|
|
113
|
-
.replace(/\W+/g, '-') // Replace non-word characters with a dash
|
|
114
|
-
.slice(0, MAX_FILENAME_LENGTH);
|
|
115
|
-
return fileName;
|
|
116
|
-
}
|
|
117
|
-
}
|
|
118
|
-
//# sourceMappingURL=error_snapshotter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"error_snapshotter.js","sourceRoot":"","sources":["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QACrB,CAAC;IACL,CAAC;IAED;;OAEG;IACH,gBAAgB,CAAC,KAAqB;QAClC,MAAM,EAAE,eAAe,EAAE,YAAY,EAAE,eAAe,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,GAC/F,gBAAgB,CAAC;QACrB,yCAAyC;QACzC,MAAM,cAAc,GAAG,MAAM;aACxB,UAAU,CAAC,MAAM,CAAC;aAClB,MAAM,CAAC,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC;aAC1C,MAAM,CAAC,KAAK,CAAC;aACb,KAAK,CAAC,CAAC,EAAE,eAAe,CAAC,CAAC;QAC/B,MAAM,kBAAkB,GAAG,CAAC,KAAK,CAAC,OAAO,IAAI,YAAY,CAAC,CAAC,KAAK,CAAC,CAAC,EAAE,oBAAoB,CAAC,CAAC,IAAI,EAAE,CAAC;QAEjG;;WAEG;QACH,MAAM,cAAc,GAAG,CAAC,GAAW,EAAU,EAAE;YAC3C,OAAO,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC;QACzC,CAAC,CAAC;QAEF,qDAAqD;QACrD,MAAM,QAAQ,GAAG,GAAG,eAAe,IAAI,cAAc,CAAC,cAAc,CAAC,IAAI,cAAc,CAAC,kBAAkB,CAAC,EAAE;aACxG,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,0CAA0C;aAC/D,KAAK,CAAC,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAEnC,OAAO,QAAQ,CAAC;IACpB,CAAC"}
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import type { CrawlingContext } from '../crawlers/crawler_commons.js';
|
|
2
|
-
import { ErrorSnapshotter } from './error_snapshotter.js';
|
|
3
|
-
/**
|
|
4
|
-
* Node.js Error interface
|
|
5
|
-
*/
|
|
6
|
-
export interface ErrnoException extends Error {
|
|
7
|
-
errno?: number;
|
|
8
|
-
code?: string | number;
|
|
9
|
-
path?: string;
|
|
10
|
-
syscall?: string;
|
|
11
|
-
cause?: any;
|
|
12
|
-
}
|
|
13
|
-
export interface ErrorTrackerOptions {
|
|
14
|
-
showErrorCode: boolean;
|
|
15
|
-
showErrorName: boolean;
|
|
16
|
-
showStackTrace: boolean;
|
|
17
|
-
showFullStack: boolean;
|
|
18
|
-
showErrorMessage: boolean;
|
|
19
|
-
showFullMessage: boolean;
|
|
20
|
-
saveErrorSnapshots: boolean;
|
|
21
|
-
}
|
|
22
|
-
/**
|
|
23
|
-
* This class tracks errors and computes a summary of information like:
|
|
24
|
-
* - where the errors happened
|
|
25
|
-
* - what the error names are
|
|
26
|
-
* - what the error codes are
|
|
27
|
-
* - what is the general error message
|
|
28
|
-
*
|
|
29
|
-
* This is extremely useful when there are dynamic error messages, such as argument validation.
|
|
30
|
-
*
|
|
31
|
-
* Since the structure of the `tracker.result` object differs when using different options,
|
|
32
|
-
* it's typed as `Record<string, unknown>`. The most deep object has a `count` property, which is a number.
|
|
33
|
-
*
|
|
34
|
-
* It's possible to get the total amount of errors via the `tracker.total` property.
|
|
35
|
-
*/
|
|
36
|
-
export declare class ErrorTracker {
|
|
37
|
-
#private;
|
|
38
|
-
result: Record<string, unknown>;
|
|
39
|
-
total: number;
|
|
40
|
-
errorSnapshotter?: ErrorSnapshotter;
|
|
41
|
-
constructor(options?: Partial<ErrorTrackerOptions>);
|
|
42
|
-
private updateGroup;
|
|
43
|
-
add(error: ErrnoException): void;
|
|
44
|
-
/**
|
|
45
|
-
* This method is async, because it captures a snapshot of the error context.
|
|
46
|
-
* We added this new method to avoid breaking changes.
|
|
47
|
-
*/
|
|
48
|
-
addAsync(error: ErrnoException, context?: CrawlingContext): Promise<void>;
|
|
49
|
-
getUniqueErrorCount(): number;
|
|
50
|
-
getMostPopularErrors(count: number): [number, string[]][];
|
|
51
|
-
captureSnapshot(storage: Record<string, unknown>, error: ErrnoException, context: CrawlingContext): Promise<void>;
|
|
52
|
-
reset(): void;
|
|
53
|
-
}
|
|
54
|
-
//# sourceMappingURL=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