@crawlee/core 4.0.0-beta.7 → 4.0.0-beta.70
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/autoscaling/autoscaled_pool.d.ts +3 -5
- package/autoscaling/autoscaled_pool.d.ts.map +1 -1
- package/autoscaling/autoscaled_pool.js +3 -9
- package/autoscaling/autoscaled_pool.js.map +1 -1
- package/autoscaling/snapshotter.d.ts +3 -13
- package/autoscaling/snapshotter.d.ts.map +1 -1
- package/autoscaling/snapshotter.js +18 -29
- package/autoscaling/snapshotter.js.map +1 -1
- package/autoscaling/system_status.d.ts +0 -3
- package/autoscaling/system_status.d.ts.map +1 -1
- package/autoscaling/system_status.js +2 -3
- package/autoscaling/system_status.js.map +1 -1
- package/configuration.d.ts +88 -227
- package/configuration.d.ts.map +1 -1
- package/configuration.js +162 -223
- package/configuration.js.map +1 -1
- package/cookie_utils.d.ts +4 -2
- package/cookie_utils.d.ts.map +1 -1
- package/cookie_utils.js +18 -12
- package/cookie_utils.js.map +1 -1
- package/crawlers/context_pipeline.d.ts +71 -0
- package/crawlers/context_pipeline.d.ts.map +1 -0
- package/crawlers/context_pipeline.js +123 -0
- package/crawlers/context_pipeline.js.map +1 -0
- package/crawlers/crawler_commons.d.ts +20 -29
- package/crawlers/crawler_commons.d.ts.map +1 -1
- package/crawlers/crawler_commons.js +12 -20
- package/crawlers/crawler_commons.js.map +1 -1
- package/crawlers/crawler_utils.d.ts +2 -2
- package/crawlers/crawler_utils.d.ts.map +1 -1
- package/crawlers/crawler_utils.js +1 -1
- package/crawlers/crawler_utils.js.map +1 -1
- package/crawlers/error_snapshotter.d.ts +3 -2
- package/crawlers/error_snapshotter.d.ts.map +1 -1
- package/crawlers/error_snapshotter.js +2 -2
- package/crawlers/error_snapshotter.js.map +1 -1
- package/crawlers/error_tracker.d.ts +2 -1
- package/crawlers/error_tracker.d.ts.map +1 -1
- package/crawlers/error_tracker.js.map +1 -1
- package/crawlers/index.d.ts +1 -1
- package/crawlers/index.d.ts.map +1 -1
- package/crawlers/index.js +1 -1
- package/crawlers/index.js.map +1 -1
- package/crawlers/internals/types.d.ts +8 -0
- package/crawlers/internals/types.d.ts.map +1 -0
- package/crawlers/internals/types.js +2 -0
- package/crawlers/internals/types.js.map +1 -0
- package/crawlers/statistics.d.ts +16 -16
- package/crawlers/statistics.d.ts.map +1 -1
- package/crawlers/statistics.js +22 -25
- package/crawlers/statistics.js.map +1 -1
- package/enqueue_links/enqueue_links.d.ts +36 -21
- package/enqueue_links/enqueue_links.d.ts.map +1 -1
- package/enqueue_links/enqueue_links.js +47 -26
- package/enqueue_links/enqueue_links.js.map +1 -1
- package/enqueue_links/shared.d.ts +25 -8
- package/enqueue_links/shared.d.ts.map +1 -1
- package/enqueue_links/shared.js +69 -37
- package/enqueue_links/shared.js.map +1 -1
- package/errors.d.ts +33 -3
- package/errors.d.ts.map +1 -1
- package/errors.js +48 -4
- package/errors.js.map +1 -1
- package/events/event_manager.d.ts +34 -7
- package/events/event_manager.d.ts.map +1 -1
- package/events/event_manager.js +8 -9
- package/events/event_manager.js.map +1 -1
- package/events/local_event_manager.d.ts +14 -4
- package/events/local_event_manager.d.ts.map +1 -1
- package/events/local_event_manager.js +33 -39
- package/events/local_event_manager.js.map +1 -1
- package/index.d.ts +4 -2
- package/index.d.ts.map +1 -1
- package/index.js +3 -1
- package/index.js.map +1 -1
- package/log.d.ts +82 -2
- package/log.d.ts.map +1 -1
- package/log.js +102 -0
- package/log.js.map +1 -1
- package/memory-storage/consts.d.ts +5 -0
- package/memory-storage/consts.d.ts.map +1 -0
- package/memory-storage/consts.js +5 -0
- package/memory-storage/consts.js.map +1 -0
- package/memory-storage/index.d.ts +2 -0
- package/memory-storage/index.d.ts.map +1 -0
- package/memory-storage/index.js +2 -0
- package/memory-storage/index.js.map +1 -0
- package/memory-storage/memory-storage.d.ts +47 -0
- package/memory-storage/memory-storage.d.ts.map +1 -0
- package/memory-storage/memory-storage.js +137 -0
- package/memory-storage/memory-storage.js.map +1 -0
- package/memory-storage/resource-clients/common/base-client.d.ts +5 -0
- package/memory-storage/resource-clients/common/base-client.d.ts.map +1 -0
- package/memory-storage/resource-clients/common/base-client.js +7 -0
- package/memory-storage/resource-clients/common/base-client.js.map +1 -0
- package/memory-storage/resource-clients/dataset.d.ts +41 -0
- package/memory-storage/resource-clients/dataset.d.ts.map +1 -0
- package/memory-storage/resource-clients/dataset.js +114 -0
- package/memory-storage/resource-clients/dataset.js.map +1 -0
- package/memory-storage/resource-clients/key-value-store.d.ts +64 -0
- package/memory-storage/resource-clients/key-value-store.d.ts.map +1 -0
- package/memory-storage/resource-clients/key-value-store.js +204 -0
- package/memory-storage/resource-clients/key-value-store.js.map +1 -0
- package/memory-storage/resource-clients/request-queue.d.ts +97 -0
- package/memory-storage/resource-clients/request-queue.d.ts.map +1 -0
- package/memory-storage/resource-clients/request-queue.js +422 -0
- package/memory-storage/resource-clients/request-queue.js.map +1 -0
- package/memory-storage/utils.d.ts +12 -0
- package/memory-storage/utils.d.ts.map +1 -0
- package/memory-storage/utils.js +28 -0
- package/memory-storage/utils.js.map +1 -0
- package/package.json +12 -10
- package/proxy_configuration.d.ts +14 -148
- package/proxy_configuration.d.ts.map +1 -1
- package/proxy_configuration.js +19 -167
- package/proxy_configuration.js.map +1 -1
- package/recoverable_state.d.ts +121 -0
- package/recoverable_state.d.ts.map +1 -0
- package/recoverable_state.js +142 -0
- package/recoverable_state.js.map +1 -0
- package/request.d.ts +84 -12
- package/request.d.ts.map +1 -1
- package/request.js +107 -27
- package/request.js.map +1 -1
- package/router.d.ts.map +1 -1
- package/router.js.map +1 -1
- package/serialization.js +1 -1
- package/serialization.js.map +1 -1
- package/service_locator.d.ts +157 -0
- package/service_locator.d.ts.map +1 -0
- package/service_locator.js +239 -0
- package/service_locator.js.map +1 -0
- package/session_pool/consts.d.ts +1 -1
- package/session_pool/consts.d.ts.map +1 -1
- package/session_pool/consts.js +1 -1
- package/session_pool/consts.js.map +1 -1
- package/session_pool/fingerprint.d.ts +10 -0
- package/session_pool/fingerprint.d.ts.map +1 -0
- package/session_pool/fingerprint.js +31 -0
- package/session_pool/fingerprint.js.map +1 -0
- package/session_pool/index.d.ts +0 -1
- package/session_pool/index.d.ts.map +1 -1
- package/session_pool/index.js +0 -1
- package/session_pool/index.js.map +1 -1
- package/session_pool/session.d.ts +35 -72
- package/session_pool/session.d.ts.map +1 -1
- package/session_pool/session.js +46 -98
- package/session_pool/session.js.map +1 -1
- package/session_pool/session_pool.d.ts +71 -71
- package/session_pool/session_pool.d.ts.map +1 -1
- package/session_pool/session_pool.js +111 -99
- package/session_pool/session_pool.js.map +1 -1
- package/storages/access_checking.d.ts.map +1 -1
- package/storages/access_checking.js +5 -1
- package/storages/access_checking.js.map +1 -1
- package/storages/dataset.d.ts +98 -47
- package/storages/dataset.d.ts.map +1 -1
- package/storages/dataset.js +166 -123
- package/storages/dataset.js.map +1 -1
- package/storages/index.d.ts +8 -6
- package/storages/index.d.ts.map +1 -1
- package/storages/index.js +6 -6
- package/storages/index.js.map +1 -1
- package/storages/key_value_store.d.ts +163 -33
- package/storages/key_value_store.d.ts.map +1 -1
- package/storages/key_value_store.js +267 -119
- package/storages/key_value_store.js.map +1 -1
- package/storages/key_value_store_codec.d.ts +33 -0
- package/storages/key_value_store_codec.d.ts.map +1 -0
- package/storages/key_value_store_codec.js +114 -0
- package/storages/key_value_store_codec.js.map +1 -0
- package/storages/request_list.d.ts +32 -81
- package/storages/request_list.d.ts.map +1 -1
- package/storages/request_list.js +49 -39
- package/storages/request_list.js.map +1 -1
- package/storages/request_loader.d.ts +97 -0
- package/storages/request_loader.d.ts.map +1 -0
- package/storages/request_loader.js +2 -0
- package/storages/request_loader.js.map +1 -0
- package/storages/request_manager.d.ts +34 -0
- package/storages/request_manager.d.ts.map +1 -0
- package/storages/request_manager.js +2 -0
- package/storages/request_manager.js.map +1 -0
- package/storages/request_manager_tandem.d.ts +107 -0
- package/storages/request_manager_tandem.d.ts.map +1 -0
- package/storages/request_manager_tandem.js +198 -0
- package/storages/request_manager_tandem.js.map +1 -0
- package/storages/request_queue.d.ts +282 -45
- package/storages/request_queue.d.ts.map +1 -1
- package/storages/request_queue.js +592 -213
- package/storages/request_queue.js.map +1 -1
- package/storages/{sitemap_request_list.d.ts → sitemap_request_loader.d.ts} +29 -24
- package/storages/sitemap_request_loader.d.ts.map +1 -0
- package/storages/{sitemap_request_list.js → sitemap_request_loader.js} +50 -46
- package/storages/sitemap_request_loader.js.map +1 -0
- package/storages/storage_instance_manager.d.ts +92 -0
- package/storages/storage_instance_manager.d.ts.map +1 -0
- package/storages/storage_instance_manager.js +261 -0
- package/storages/storage_instance_manager.js.map +1 -0
- package/storages/storage_stats.d.ts +49 -0
- package/storages/storage_stats.d.ts.map +1 -0
- package/storages/storage_stats.js +30 -0
- package/storages/storage_stats.js.map +1 -0
- package/storages/utils.d.ts +51 -5
- package/storages/utils.d.ts.map +1 -1
- package/storages/utils.js +60 -8
- package/storages/utils.js.map +1 -1
- package/typedefs.d.ts +1 -1
- package/typedefs.d.ts.map +1 -1
- package/validators.d.ts +8 -0
- package/validators.d.ts.map +1 -1
- package/validators.js +8 -0
- package/validators.js.map +1 -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/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/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/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_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.map +0 -1
- 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/tsconfig.build.tsbuildinfo +0 -1
|
@@ -1,555 +0,0 @@
|
|
|
1
|
-
import { inspect } from 'node:util';
|
|
2
|
-
import { chunk, downloadListOfUrls, sleep } from '@crawlee/utils';
|
|
3
|
-
import ow from 'ow';
|
|
4
|
-
import { ListDictionary, LruCache } from '@apify/datastructures';
|
|
5
|
-
import { cryptoRandomObjectId } from '@apify/utilities';
|
|
6
|
-
import { Configuration } from '../configuration.js';
|
|
7
|
-
import { log } from '../log.js';
|
|
8
|
-
import { Request } from '../request.js';
|
|
9
|
-
import { checkStorageAccess } from './access_checking.js';
|
|
10
|
-
import { StorageManager } from './storage_manager.js';
|
|
11
|
-
import { getRequestId, purgeDefaultStorages, QUERY_HEAD_MIN_LENGTH } from './utils.js';
|
|
12
|
-
export class RequestProvider {
|
|
13
|
-
config;
|
|
14
|
-
id;
|
|
15
|
-
name;
|
|
16
|
-
timeoutSecs = 30;
|
|
17
|
-
clientKey = cryptoRandomObjectId();
|
|
18
|
-
client;
|
|
19
|
-
proxyConfiguration;
|
|
20
|
-
log;
|
|
21
|
-
internalTimeoutMillis = 5 * 60_000; // defaults to 5 minutes, will be overridden by BasicCrawler
|
|
22
|
-
requestLockSecs = 3 * 60; // defaults to 3 minutes, will be overridden by BasicCrawler
|
|
23
|
-
// We can trust these numbers only in a case that queue is used by a single client.
|
|
24
|
-
// This information is returned by getHead() under the hadMultipleClients property.
|
|
25
|
-
assumedTotalCount = 0;
|
|
26
|
-
assumedHandledCount = 0;
|
|
27
|
-
initialCount = 0;
|
|
28
|
-
queueHeadIds = new ListDictionary();
|
|
29
|
-
requestCache;
|
|
30
|
-
recentlyHandledRequestsCache;
|
|
31
|
-
queuePausedForMigration = false;
|
|
32
|
-
lastActivity = new Date();
|
|
33
|
-
isFinishedCalledWhileHeadWasNotEmpty = 0;
|
|
34
|
-
inProgressRequestBatchCount = 0;
|
|
35
|
-
constructor(options, config = Configuration.getGlobalConfig()) {
|
|
36
|
-
this.config = config;
|
|
37
|
-
this.id = options.id;
|
|
38
|
-
this.name = options.name;
|
|
39
|
-
this.client = options.client.requestQueue(this.id, {
|
|
40
|
-
clientKey: this.clientKey,
|
|
41
|
-
timeoutSecs: this.timeoutSecs,
|
|
42
|
-
});
|
|
43
|
-
this.proxyConfiguration = options.proxyConfiguration;
|
|
44
|
-
this.requestCache = new LruCache({ maxLength: options.requestCacheMaxSize });
|
|
45
|
-
this.recentlyHandledRequestsCache = new LruCache({ maxLength: options.recentlyHandledRequestsMaxSize });
|
|
46
|
-
this.log = log.child({ prefix: `${options.logPrefix}(${this.id}, ${this.name ?? 'no-name'})` });
|
|
47
|
-
const eventManager = config.getEventManager();
|
|
48
|
-
eventManager.on("migrating" /* EventType.MIGRATING */, async () => {
|
|
49
|
-
this.queuePausedForMigration = true;
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
/**
|
|
53
|
-
* Returns an offline approximation of the total number of requests in the queue (i.e. pending + handled).
|
|
54
|
-
*
|
|
55
|
-
* Survives restarts and actor migrations.
|
|
56
|
-
*/
|
|
57
|
-
getTotalCount() {
|
|
58
|
-
return this.assumedTotalCount + this.initialCount;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Adds a request to the queue.
|
|
62
|
-
*
|
|
63
|
-
* If a request with the same `uniqueKey` property is already present in the queue,
|
|
64
|
-
* it will not be updated. You can find out whether this happened from the resulting
|
|
65
|
-
* {@link QueueOperationInfo} object.
|
|
66
|
-
*
|
|
67
|
-
* To add multiple requests to the queue by extracting links from a webpage,
|
|
68
|
-
* see the {@link enqueueLinks} helper function.
|
|
69
|
-
*
|
|
70
|
-
* @param requestLike {@link Request} object or vanilla object with request data.
|
|
71
|
-
* Note that the function sets the `uniqueKey` and `id` fields to the passed Request.
|
|
72
|
-
* @param [options] Request queue operation options.
|
|
73
|
-
*/
|
|
74
|
-
async addRequest(requestLike, options = {}) {
|
|
75
|
-
checkStorageAccess();
|
|
76
|
-
this.lastActivity = new Date();
|
|
77
|
-
ow(requestLike, ow.object);
|
|
78
|
-
ow(options, ow.object.exactShape({
|
|
79
|
-
forefront: ow.optional.boolean,
|
|
80
|
-
}));
|
|
81
|
-
const { forefront = false } = options;
|
|
82
|
-
if ('requestsFromUrl' in requestLike) {
|
|
83
|
-
const requests = await this._fetchRequestsFromUrl(requestLike);
|
|
84
|
-
const processedRequests = await this._addFetchedRequests(requestLike, requests, options);
|
|
85
|
-
return { ...processedRequests[0], forefront };
|
|
86
|
-
}
|
|
87
|
-
ow(requestLike, ow.object.partialShape({
|
|
88
|
-
url: ow.string,
|
|
89
|
-
id: ow.undefined,
|
|
90
|
-
}));
|
|
91
|
-
const request = requestLike instanceof Request ? requestLike : new Request(requestLike);
|
|
92
|
-
const cacheKey = getRequestId(request.uniqueKey);
|
|
93
|
-
const cachedInfo = this.requestCache.get(cacheKey);
|
|
94
|
-
if (cachedInfo) {
|
|
95
|
-
request.id = cachedInfo.id;
|
|
96
|
-
return {
|
|
97
|
-
wasAlreadyPresent: true,
|
|
98
|
-
// We may assume that if request is in local cache then also the information if the
|
|
99
|
-
// request was already handled is there because just one client should be using one queue.
|
|
100
|
-
wasAlreadyHandled: cachedInfo.isHandled,
|
|
101
|
-
requestId: cachedInfo.id,
|
|
102
|
-
uniqueKey: cachedInfo.uniqueKey,
|
|
103
|
-
forefront,
|
|
104
|
-
};
|
|
105
|
-
}
|
|
106
|
-
const queueOperationInfo = {
|
|
107
|
-
...(await this.client.addRequest(request, { forefront })),
|
|
108
|
-
uniqueKey: request.uniqueKey,
|
|
109
|
-
forefront,
|
|
110
|
-
};
|
|
111
|
-
const { requestId, wasAlreadyPresent } = queueOperationInfo;
|
|
112
|
-
this._cacheRequest(cacheKey, queueOperationInfo);
|
|
113
|
-
if (!wasAlreadyPresent && !this.recentlyHandledRequestsCache.get(requestId)) {
|
|
114
|
-
this.assumedTotalCount++;
|
|
115
|
-
// Performance optimization: add request straight to head if possible
|
|
116
|
-
this._maybeAddRequestToQueueHead(requestId, forefront);
|
|
117
|
-
}
|
|
118
|
-
return queueOperationInfo;
|
|
119
|
-
}
|
|
120
|
-
/**
|
|
121
|
-
* Adds requests to the queue in batches of 25. This method will wait till all the requests are added
|
|
122
|
-
* to the queue before resolving. You should prefer using `queue.addRequestsBatched()` or `crawler.addRequests()`
|
|
123
|
-
* if you don't want to block the processing, as those methods will only wait for the initial 1000 requests,
|
|
124
|
-
* start processing right after that happens, and continue adding more in the background.
|
|
125
|
-
*
|
|
126
|
-
* If a request passed in is already present due to its `uniqueKey` property being the same,
|
|
127
|
-
* it will not be updated. You can find out whether this happened by finding the request in the resulting
|
|
128
|
-
* {@link BatchAddRequestsResult} object.
|
|
129
|
-
*
|
|
130
|
-
* @param requestsLike {@link Request} objects or vanilla objects with request data.
|
|
131
|
-
* Note that the function sets the `uniqueKey` and `id` fields to the passed requests if missing.
|
|
132
|
-
* @param [options] Request queue operation options.
|
|
133
|
-
*/
|
|
134
|
-
async addRequests(requestsLike, options = {}) {
|
|
135
|
-
checkStorageAccess();
|
|
136
|
-
this.lastActivity = new Date();
|
|
137
|
-
ow(requestsLike, ow.array);
|
|
138
|
-
ow(options, ow.object.exactShape({
|
|
139
|
-
forefront: ow.optional.boolean,
|
|
140
|
-
cache: ow.optional.boolean,
|
|
141
|
-
}));
|
|
142
|
-
const { forefront = false, cache = true } = options;
|
|
143
|
-
const uniqueKeyToCacheKey = new Map();
|
|
144
|
-
const getCachedRequestId = (uniqueKey) => {
|
|
145
|
-
const cached = uniqueKeyToCacheKey.get(uniqueKey);
|
|
146
|
-
if (cached)
|
|
147
|
-
return cached;
|
|
148
|
-
const newCacheKey = getRequestId(uniqueKey);
|
|
149
|
-
uniqueKeyToCacheKey.set(uniqueKey, newCacheKey);
|
|
150
|
-
return newCacheKey;
|
|
151
|
-
};
|
|
152
|
-
const results = {
|
|
153
|
-
processedRequests: [],
|
|
154
|
-
unprocessedRequests: [],
|
|
155
|
-
};
|
|
156
|
-
for (const requestLike of requestsLike) {
|
|
157
|
-
if ('requestsFromUrl' in requestLike) {
|
|
158
|
-
const requests = await this._fetchRequestsFromUrl(requestLike);
|
|
159
|
-
await this._addFetchedRequests(requestLike, requests, options);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
const requests = requestsLike
|
|
163
|
-
.filter((requestLike) => !('requestsFromUrl' in requestLike))
|
|
164
|
-
.map((requestLike) => {
|
|
165
|
-
return requestLike instanceof Request ? requestLike : new Request(requestLike);
|
|
166
|
-
});
|
|
167
|
-
const requestsToAdd = new Map();
|
|
168
|
-
for (const request of requests) {
|
|
169
|
-
const cacheKey = getCachedRequestId(request.uniqueKey);
|
|
170
|
-
const cachedInfo = this.requestCache.get(cacheKey);
|
|
171
|
-
if (cachedInfo) {
|
|
172
|
-
request.id = cachedInfo.id;
|
|
173
|
-
results.processedRequests.push({
|
|
174
|
-
wasAlreadyPresent: true,
|
|
175
|
-
// We may assume that if request is in local cache then also the information if the
|
|
176
|
-
// request was already handled is there because just one client should be using one queue.
|
|
177
|
-
wasAlreadyHandled: cachedInfo.isHandled,
|
|
178
|
-
requestId: cachedInfo.id,
|
|
179
|
-
uniqueKey: cachedInfo.uniqueKey,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
else if (!requestsToAdd.has(request.uniqueKey)) {
|
|
183
|
-
requestsToAdd.set(request.uniqueKey, request);
|
|
184
|
-
}
|
|
185
|
-
}
|
|
186
|
-
// Early exit if all provided requests were already added
|
|
187
|
-
if (!requestsToAdd.size) {
|
|
188
|
-
return results;
|
|
189
|
-
}
|
|
190
|
-
const apiResults = await this.client.batchAddRequests([...requestsToAdd.values()], { forefront });
|
|
191
|
-
// Report unprocessed requests
|
|
192
|
-
results.unprocessedRequests = apiResults.unprocessedRequests;
|
|
193
|
-
// Add all new requests to the requestCache
|
|
194
|
-
for (const newRequest of apiResults.processedRequests) {
|
|
195
|
-
// Add the new request to the processed list
|
|
196
|
-
results.processedRequests.push(newRequest);
|
|
197
|
-
const cacheKey = getCachedRequestId(newRequest.uniqueKey);
|
|
198
|
-
const { requestId, wasAlreadyPresent } = newRequest;
|
|
199
|
-
if (cache) {
|
|
200
|
-
this._cacheRequest(cacheKey, { ...newRequest, forefront });
|
|
201
|
-
}
|
|
202
|
-
if (!wasAlreadyPresent && !this.recentlyHandledRequestsCache.get(requestId)) {
|
|
203
|
-
this.assumedTotalCount++;
|
|
204
|
-
// Performance optimization: add request straight to head if possible
|
|
205
|
-
this._maybeAddRequestToQueueHead(requestId, forefront);
|
|
206
|
-
}
|
|
207
|
-
}
|
|
208
|
-
return results;
|
|
209
|
-
}
|
|
210
|
-
/**
|
|
211
|
-
* Adds requests to the queue in batches. By default, it will resolve after the initial batch is added, and continue
|
|
212
|
-
* adding the rest in the background. You can configure the batch size via `batchSize` option and the sleep time in between
|
|
213
|
-
* the batches via `waitBetweenBatchesMillis`. If you want to wait for all batches to be added to the queue, you can use
|
|
214
|
-
* the `waitForAllRequestsToBeAdded` promise you get in the response object.
|
|
215
|
-
*
|
|
216
|
-
* @param requests The requests to add
|
|
217
|
-
* @param options Options for the request queue
|
|
218
|
-
*/
|
|
219
|
-
async addRequestsBatched(requests, options = {}) {
|
|
220
|
-
checkStorageAccess();
|
|
221
|
-
this.lastActivity = new Date();
|
|
222
|
-
ow(options, ow.object.exactShape({
|
|
223
|
-
forefront: ow.optional.boolean,
|
|
224
|
-
waitForAllRequestsToBeAdded: ow.optional.boolean,
|
|
225
|
-
batchSize: ow.optional.number,
|
|
226
|
-
waitBetweenBatchesMillis: ow.optional.number,
|
|
227
|
-
}));
|
|
228
|
-
// The `requests` array can be huge, and `ow` is very slow for anything more complex.
|
|
229
|
-
// This explicit iteration takes a few milliseconds, while the ow check can take tens of seconds.
|
|
230
|
-
// ow(requests, ow.array.ofType(ow.any(
|
|
231
|
-
// ow.string,
|
|
232
|
-
// ow.object.partialShape({ url: ow.string, id: ow.undefined }),
|
|
233
|
-
// ow.object.partialShape({ requestsFromUrl: ow.string, regex: ow.optional.regExp }),
|
|
234
|
-
// )));
|
|
235
|
-
for (const request of requests) {
|
|
236
|
-
if (typeof request === 'string') {
|
|
237
|
-
continue;
|
|
238
|
-
}
|
|
239
|
-
if (typeof request === 'object' && request !== null) {
|
|
240
|
-
if (typeof request.url === 'string' && typeof request.id === 'undefined') {
|
|
241
|
-
continue;
|
|
242
|
-
}
|
|
243
|
-
if (typeof request.requestsFromUrl === 'string') {
|
|
244
|
-
continue;
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
throw new Error(`Request options are not valid, provide either a URL or an object with 'url' property (but without 'id' property), or an object with 'requestsFromUrl' property. Input: ${inspect(request)}`);
|
|
248
|
-
}
|
|
249
|
-
const { batchSize = 1000, waitBetweenBatchesMillis = 1000 } = options;
|
|
250
|
-
const sources = [];
|
|
251
|
-
for (const opts of requests) {
|
|
252
|
-
if (opts && typeof opts === 'object' && 'requestsFromUrl' in opts) {
|
|
253
|
-
await this.addRequest(opts, { forefront: options.forefront });
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
sources.push(typeof opts === 'string' ? { url: opts } : opts);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
const attemptToAddToQueueAndAddAnyUnprocessed = async (providedRequests, cache = true) => {
|
|
260
|
-
const resultsToReturn = [];
|
|
261
|
-
const apiResult = await this.addRequests(providedRequests, { forefront: options.forefront, cache });
|
|
262
|
-
resultsToReturn.push(...apiResult.processedRequests);
|
|
263
|
-
if (apiResult.unprocessedRequests.length) {
|
|
264
|
-
await sleep(waitBetweenBatchesMillis);
|
|
265
|
-
resultsToReturn.push(...(await attemptToAddToQueueAndAddAnyUnprocessed(providedRequests.filter((r) => !apiResult.processedRequests.some((pr) => pr.uniqueKey === r.uniqueKey)), false)));
|
|
266
|
-
}
|
|
267
|
-
return resultsToReturn;
|
|
268
|
-
};
|
|
269
|
-
const initialChunk = sources.splice(0, batchSize);
|
|
270
|
-
// Add initial batch of `batchSize` to process them right away
|
|
271
|
-
const addedRequests = await attemptToAddToQueueAndAddAnyUnprocessed(initialChunk);
|
|
272
|
-
// If we have no more requests to add, return early
|
|
273
|
-
if (!sources.length) {
|
|
274
|
-
return {
|
|
275
|
-
addedRequests,
|
|
276
|
-
waitForAllRequestsToBeAdded: Promise.resolve([]),
|
|
277
|
-
};
|
|
278
|
-
}
|
|
279
|
-
// eslint-disable-next-line no-async-promise-executor
|
|
280
|
-
const promise = new Promise(async (resolve) => {
|
|
281
|
-
const chunks = chunk(sources, batchSize);
|
|
282
|
-
const finalAddedRequests = [];
|
|
283
|
-
for (const requestChunk of chunks) {
|
|
284
|
-
finalAddedRequests.push(...(await attemptToAddToQueueAndAddAnyUnprocessed(requestChunk, false)));
|
|
285
|
-
await sleep(waitBetweenBatchesMillis);
|
|
286
|
-
}
|
|
287
|
-
resolve(finalAddedRequests);
|
|
288
|
-
});
|
|
289
|
-
this.inProgressRequestBatchCount += 1;
|
|
290
|
-
void promise.finally(() => {
|
|
291
|
-
this.inProgressRequestBatchCount -= 1;
|
|
292
|
-
});
|
|
293
|
-
// If the user wants to wait for all the requests to be added, we wait for the promise to resolve for them
|
|
294
|
-
if (options.waitForAllRequestsToBeAdded) {
|
|
295
|
-
addedRequests.push(...(await promise));
|
|
296
|
-
}
|
|
297
|
-
return {
|
|
298
|
-
addedRequests,
|
|
299
|
-
waitForAllRequestsToBeAdded: promise,
|
|
300
|
-
};
|
|
301
|
-
}
|
|
302
|
-
/**
|
|
303
|
-
* Gets the request from the queue specified by ID.
|
|
304
|
-
*
|
|
305
|
-
* @param id ID of the request.
|
|
306
|
-
* @returns Returns the request object, or `null` if it was not found.
|
|
307
|
-
*/
|
|
308
|
-
async getRequest(id) {
|
|
309
|
-
checkStorageAccess();
|
|
310
|
-
ow(id, ow.string);
|
|
311
|
-
const requestOptions = await this.client.getRequest(id);
|
|
312
|
-
if (!requestOptions)
|
|
313
|
-
return null;
|
|
314
|
-
return new Request(requestOptions);
|
|
315
|
-
}
|
|
316
|
-
/**
|
|
317
|
-
* Marks a request that was previously returned by the
|
|
318
|
-
* {@link RequestQueue.fetchNextRequest}
|
|
319
|
-
* function as handled after successful processing.
|
|
320
|
-
* Handled requests will never again be returned by the `fetchNextRequest` function.
|
|
321
|
-
*/
|
|
322
|
-
async markRequestHandled(request) {
|
|
323
|
-
checkStorageAccess();
|
|
324
|
-
this.lastActivity = new Date();
|
|
325
|
-
ow(request, ow.object.partialShape({
|
|
326
|
-
id: ow.string,
|
|
327
|
-
uniqueKey: ow.string,
|
|
328
|
-
handledAt: ow.optional.string,
|
|
329
|
-
}));
|
|
330
|
-
const forefront = this.requestCache.get(getRequestId(request.uniqueKey))?.forefront ?? false;
|
|
331
|
-
const handledAt = request.handledAt ?? new Date().toISOString();
|
|
332
|
-
const queueOperationInfo = {
|
|
333
|
-
...(await this.client.updateRequest({
|
|
334
|
-
...request,
|
|
335
|
-
handledAt,
|
|
336
|
-
})),
|
|
337
|
-
uniqueKey: request.uniqueKey,
|
|
338
|
-
forefront,
|
|
339
|
-
};
|
|
340
|
-
request.handledAt = handledAt;
|
|
341
|
-
this.recentlyHandledRequestsCache.add(request.id, true);
|
|
342
|
-
if (!queueOperationInfo.wasAlreadyHandled) {
|
|
343
|
-
this.assumedHandledCount++;
|
|
344
|
-
}
|
|
345
|
-
this.queueHeadIds.remove(request.id);
|
|
346
|
-
this._cacheRequest(getRequestId(request.uniqueKey), queueOperationInfo);
|
|
347
|
-
return queueOperationInfo;
|
|
348
|
-
}
|
|
349
|
-
/**
|
|
350
|
-
* Reclaims a failed request back to the queue, so that it can be returned for processing later again
|
|
351
|
-
* by another call to {@link RequestQueue.fetchNextRequest}.
|
|
352
|
-
* The request record in the queue is updated using the provided `request` parameter.
|
|
353
|
-
* For example, this lets you store the number of retries or error messages for the request.
|
|
354
|
-
*/
|
|
355
|
-
async reclaimRequest(request, options = {}) {
|
|
356
|
-
checkStorageAccess();
|
|
357
|
-
this.lastActivity = new Date();
|
|
358
|
-
ow(request, ow.object.partialShape({
|
|
359
|
-
id: ow.string,
|
|
360
|
-
uniqueKey: ow.string,
|
|
361
|
-
}));
|
|
362
|
-
ow(options, ow.object.exactShape({
|
|
363
|
-
forefront: ow.optional.boolean,
|
|
364
|
-
}));
|
|
365
|
-
const { forefront = false } = options;
|
|
366
|
-
// TODO: If request hasn't been changed since the last getRequest(),
|
|
367
|
-
// we don't need to call updateRequest() and thus improve performance.
|
|
368
|
-
const queueOperationInfo = {
|
|
369
|
-
...(await this.client.updateRequest(request, {
|
|
370
|
-
forefront,
|
|
371
|
-
})),
|
|
372
|
-
uniqueKey: request.uniqueKey,
|
|
373
|
-
forefront,
|
|
374
|
-
};
|
|
375
|
-
this._cacheRequest(getRequestId(request.uniqueKey), queueOperationInfo);
|
|
376
|
-
return queueOperationInfo;
|
|
377
|
-
}
|
|
378
|
-
/**
|
|
379
|
-
* Resolves to `true` if the next call to {@link RequestQueue.fetchNextRequest}
|
|
380
|
-
* would return `null`, otherwise it resolves to `false`.
|
|
381
|
-
* Note that even if the queue is empty, there might be some pending requests currently being processed.
|
|
382
|
-
* If you need to ensure that there is no activity in the queue, use {@link RequestQueue.isFinished}.
|
|
383
|
-
*/
|
|
384
|
-
async isEmpty() {
|
|
385
|
-
await this.ensureHeadIsNonEmpty();
|
|
386
|
-
return this.queueHeadIds.length() === 0;
|
|
387
|
-
}
|
|
388
|
-
_reset() {
|
|
389
|
-
this.lastActivity = new Date();
|
|
390
|
-
this.queueHeadIds.clear();
|
|
391
|
-
this.recentlyHandledRequestsCache.clear();
|
|
392
|
-
this.assumedTotalCount = 0;
|
|
393
|
-
this.assumedHandledCount = 0;
|
|
394
|
-
this.requestCache.clear();
|
|
395
|
-
}
|
|
396
|
-
/**
|
|
397
|
-
* Caches information about request to beware of unneeded addRequest() calls.
|
|
398
|
-
*/
|
|
399
|
-
_cacheRequest(cacheKey, queueOperationInfo) {
|
|
400
|
-
// Remove the previous entry, as otherwise our cache will never update 👀
|
|
401
|
-
this.requestCache.remove(cacheKey);
|
|
402
|
-
this.requestCache.add(cacheKey, {
|
|
403
|
-
id: queueOperationInfo.requestId,
|
|
404
|
-
isHandled: queueOperationInfo.wasAlreadyHandled,
|
|
405
|
-
uniqueKey: queueOperationInfo.uniqueKey,
|
|
406
|
-
hydrated: null,
|
|
407
|
-
lockExpiresAt: null,
|
|
408
|
-
forefront: queueOperationInfo.forefront,
|
|
409
|
-
});
|
|
410
|
-
}
|
|
411
|
-
/**
|
|
412
|
-
* Adds a request straight to the queueHeadDict, to improve performance.
|
|
413
|
-
*/
|
|
414
|
-
_maybeAddRequestToQueueHead(requestId, forefront) {
|
|
415
|
-
if (forefront) {
|
|
416
|
-
this.queueHeadIds.add(requestId, requestId, true);
|
|
417
|
-
}
|
|
418
|
-
else if (this.assumedTotalCount < QUERY_HEAD_MIN_LENGTH) {
|
|
419
|
-
this.queueHeadIds.add(requestId, requestId, false);
|
|
420
|
-
}
|
|
421
|
-
}
|
|
422
|
-
/**
|
|
423
|
-
* Removes the queue either from the Apify Cloud storage or from the local database,
|
|
424
|
-
* depending on the mode of operation.
|
|
425
|
-
*/
|
|
426
|
-
async drop() {
|
|
427
|
-
checkStorageAccess();
|
|
428
|
-
await this.client.delete();
|
|
429
|
-
const manager = StorageManager.getManager(this.constructor, this.config);
|
|
430
|
-
manager.closeStorage(this);
|
|
431
|
-
}
|
|
432
|
-
/**
|
|
433
|
-
* Returns the number of handled requests.
|
|
434
|
-
*
|
|
435
|
-
* This function is just a convenient shortcut for:
|
|
436
|
-
*
|
|
437
|
-
* ```javascript
|
|
438
|
-
* const { handledRequestCount } = await queue.getInfo();
|
|
439
|
-
* ```
|
|
440
|
-
*/
|
|
441
|
-
async handledCount() {
|
|
442
|
-
// NOTE: We keep this function for compatibility with RequestList.handledCount()
|
|
443
|
-
const { handledRequestCount } = (await this.getInfo()) ?? {};
|
|
444
|
-
return handledRequestCount ?? 0;
|
|
445
|
-
}
|
|
446
|
-
/**
|
|
447
|
-
* Returns an object containing general information about the request queue.
|
|
448
|
-
*
|
|
449
|
-
* The function returns the same object as the Apify API Client's
|
|
450
|
-
* [getQueue](https://docs.apify.com/api/apify-client-js/latest#ApifyClient-requestQueues)
|
|
451
|
-
* function, which in turn calls the
|
|
452
|
-
* [Get request queue](https://apify.com/docs/api/v2#/reference/request-queues/queue/get-request-queue)
|
|
453
|
-
* API endpoint.
|
|
454
|
-
*
|
|
455
|
-
* **Example:**
|
|
456
|
-
* ```
|
|
457
|
-
* {
|
|
458
|
-
* id: "WkzbQMuFYuamGv3YF",
|
|
459
|
-
* name: "my-queue",
|
|
460
|
-
* userId: "wRsJZtadYvn4mBZmm",
|
|
461
|
-
* createdAt: new Date("2015-12-12T07:34:14.202Z"),
|
|
462
|
-
* modifiedAt: new Date("2015-12-13T08:36:13.202Z"),
|
|
463
|
-
* accessedAt: new Date("2015-12-14T08:36:13.202Z"),
|
|
464
|
-
* totalRequestCount: 25,
|
|
465
|
-
* handledRequestCount: 5,
|
|
466
|
-
* pendingRequestCount: 20,
|
|
467
|
-
* }
|
|
468
|
-
* ```
|
|
469
|
-
*/
|
|
470
|
-
async getInfo() {
|
|
471
|
-
checkStorageAccess();
|
|
472
|
-
return this.client.get();
|
|
473
|
-
}
|
|
474
|
-
/**
|
|
475
|
-
* Fetches URLs from requestsFromUrl and returns them in format of list of requests
|
|
476
|
-
*/
|
|
477
|
-
async _fetchRequestsFromUrl(source) {
|
|
478
|
-
const { requestsFromUrl, regex, ...sharedOpts } = source;
|
|
479
|
-
// Download remote resource and parse URLs.
|
|
480
|
-
let urlsArr;
|
|
481
|
-
try {
|
|
482
|
-
urlsArr = await this._downloadListOfUrls({
|
|
483
|
-
url: requestsFromUrl,
|
|
484
|
-
urlRegExp: regex,
|
|
485
|
-
proxyUrl: await this.proxyConfiguration?.newUrl(),
|
|
486
|
-
});
|
|
487
|
-
}
|
|
488
|
-
catch (err) {
|
|
489
|
-
throw new Error(`Cannot fetch a request list from ${requestsFromUrl}: ${err}`);
|
|
490
|
-
}
|
|
491
|
-
// Skip if resource contained no URLs.
|
|
492
|
-
if (!urlsArr.length) {
|
|
493
|
-
this.log.warning('The fetched list contains no valid URLs.', { requestsFromUrl, regex });
|
|
494
|
-
return [];
|
|
495
|
-
}
|
|
496
|
-
return urlsArr.map((url) => ({ url, ...sharedOpts }));
|
|
497
|
-
}
|
|
498
|
-
/**
|
|
499
|
-
* Adds all fetched requests from a URL from a remote resource.
|
|
500
|
-
*/
|
|
501
|
-
async _addFetchedRequests(source, fetchedRequests, options) {
|
|
502
|
-
const { requestsFromUrl, regex } = source;
|
|
503
|
-
const { addedRequests } = await this.addRequestsBatched(fetchedRequests, options);
|
|
504
|
-
this.log.info('Fetched and loaded Requests from a remote resource.', {
|
|
505
|
-
requestsFromUrl,
|
|
506
|
-
regex,
|
|
507
|
-
fetchedCount: fetchedRequests.length,
|
|
508
|
-
importedCount: addedRequests.length,
|
|
509
|
-
duplicateCount: fetchedRequests.length - addedRequests.length,
|
|
510
|
-
sample: JSON.stringify(fetchedRequests.slice(0, 5)),
|
|
511
|
-
});
|
|
512
|
-
return addedRequests;
|
|
513
|
-
}
|
|
514
|
-
/**
|
|
515
|
-
* @internal wraps public utility for mocking purposes
|
|
516
|
-
*/
|
|
517
|
-
async _downloadListOfUrls(options) {
|
|
518
|
-
return downloadListOfUrls(options);
|
|
519
|
-
}
|
|
520
|
-
/**
|
|
521
|
-
* Opens a request queue and returns a promise resolving to an instance
|
|
522
|
-
* of the {@link RequestQueue} class.
|
|
523
|
-
*
|
|
524
|
-
* {@link RequestQueue} represents a queue of URLs to crawl, which is stored either on local filesystem or in the cloud.
|
|
525
|
-
* The queue is used for deep crawling of websites, where you start with several URLs and then
|
|
526
|
-
* recursively follow links to other pages. The data structure supports both breadth-first
|
|
527
|
-
* and depth-first crawling orders.
|
|
528
|
-
*
|
|
529
|
-
* For more details and code examples, see the {@link RequestQueue} class.
|
|
530
|
-
*
|
|
531
|
-
* @param [queueIdOrName]
|
|
532
|
-
* ID or name of the request queue to be opened. If `null` or `undefined`,
|
|
533
|
-
* the function returns the default request queue associated with the crawler run.
|
|
534
|
-
* @param [options] Open Request Queue options.
|
|
535
|
-
*/
|
|
536
|
-
static async open(queueIdOrName, options = {}) {
|
|
537
|
-
checkStorageAccess();
|
|
538
|
-
ow(queueIdOrName, ow.optional.any(ow.string, ow.null));
|
|
539
|
-
ow(options, ow.object.exactShape({
|
|
540
|
-
config: ow.optional.object.instanceOf(Configuration),
|
|
541
|
-
storageClient: ow.optional.object,
|
|
542
|
-
proxyConfiguration: ow.optional.object,
|
|
543
|
-
}));
|
|
544
|
-
options.config ??= Configuration.getGlobalConfig();
|
|
545
|
-
options.storageClient ??= options.config.getStorageClient();
|
|
546
|
-
await purgeDefaultStorages({ onlyPurgeOnce: true, client: options.storageClient, config: options.config });
|
|
547
|
-
const manager = StorageManager.getManager(this, options.config);
|
|
548
|
-
const queue = await manager.openStorage(queueIdOrName, options.storageClient);
|
|
549
|
-
queue.proxyConfiguration = options.proxyConfiguration;
|
|
550
|
-
// eslint-disable-next-line dot-notation
|
|
551
|
-
queue['initialCount'] = (await queue.client.get())?.totalRequestCount ?? 0;
|
|
552
|
-
return queue;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
//# sourceMappingURL=request_provider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"request_provider.js","sourceRoot":"","sources":["../../src/storages/request_provider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AAWpC,OAAO,EAAE,KAAK,EAAE,kBAAkB,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AAClE,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC;AAEjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAEpD,OAAO,EAAE,GAAG,EAAE,MAAM,WAAW,CAAC;AAGhC,OAAO,EAAE,OAAO,EAAE,MAAM,eAAe,CAAC;AAExC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AACtD,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAEvF,MAAM,OAAgB,eAAe;IAkCpB;IAjCb,EAAE,CAAS;IACX,IAAI,CAAU;IACd,WAAW,GAAG,EAAE,CAAC;IACjB,SAAS,GAAG,oBAAoB,EAAE,CAAC;IACnC,MAAM,CAAqB;IACjB,kBAAkB,CAAsB;IAElD,GAAG,CAAM;IACT,qBAAqB,GAAG,CAAC,GAAG,MAAM,CAAC,CAAC,4DAA4D;IAChG,eAAe,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC,4DAA4D;IAEtF,mFAAmF;IACnF,mFAAmF;IACnF,iBAAiB,GAAG,CAAC,CAAC;IACtB,mBAAmB,GAAG,CAAC,CAAC;IAEhB,YAAY,GAAG,CAAC,CAAC;IAEf,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AC,GAAG,EAAE,CAAC,EAAE,iBAAiB,IAAI,CAAC,CAAC;QAE3E,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ"}
|
|
@@ -1,87 +0,0 @@
|
|
|
1
|
-
import type { BatchAddRequestsResult, Dictionary } from '@crawlee/types';
|
|
2
|
-
import { Configuration } from '../configuration.js';
|
|
3
|
-
import type { Request, Source } from '../request.js';
|
|
4
|
-
import type { RequestProviderOptions, RequestQueueOperationInfo, RequestQueueOperationOptions } from './request_provider.js';
|
|
5
|
-
import { RequestProvider } from './request_provider.js';
|
|
6
|
-
/**
|
|
7
|
-
* Represents a queue of URLs to crawl, which is used for deep crawling of websites
|
|
8
|
-
* where you start with several URLs and then recursively
|
|
9
|
-
* follow links to other pages. The data structure supports both breadth-first and depth-first crawling orders.
|
|
10
|
-
*
|
|
11
|
-
* Each URL is represented using an instance of the {@link Request} class.
|
|
12
|
-
* The queue can only contain unique URLs. More precisely, it can only contain {@link Request} instances
|
|
13
|
-
* with distinct `uniqueKey` properties. By default, `uniqueKey` is generated from the URL, but it can also be overridden.
|
|
14
|
-
* To add a single URL multiple times to the queue,
|
|
15
|
-
* corresponding {@link Request} objects will need to have different `uniqueKey` properties.
|
|
16
|
-
*
|
|
17
|
-
* Do not instantiate this class directly, use the {@link RequestQueue.open} function instead.
|
|
18
|
-
*
|
|
19
|
-
* `RequestQueue` is used by {@link BasicCrawler}, {@link CheerioCrawler}, {@link PuppeteerCrawler}
|
|
20
|
-
* and {@link PlaywrightCrawler} as a source of URLs to crawl.
|
|
21
|
-
* Unlike {@link RequestList}, `RequestQueue` supports dynamic adding and removing of requests.
|
|
22
|
-
* On the other hand, the queue is not optimized for operations that add or remove a large number of URLs in a batch.
|
|
23
|
-
*
|
|
24
|
-
* **Example usage:**
|
|
25
|
-
*
|
|
26
|
-
* ```javascript
|
|
27
|
-
* // Open the default request queue associated with the crawler run
|
|
28
|
-
* const queue = await RequestQueue.open();
|
|
29
|
-
*
|
|
30
|
-
* // Open a named request queue
|
|
31
|
-
* const queueWithName = await RequestQueue.open('some-name');
|
|
32
|
-
*
|
|
33
|
-
* // Enqueue few requests
|
|
34
|
-
* await queue.addRequest({ url: 'http://example.com/aaa' });
|
|
35
|
-
* await queue.addRequest({ url: 'http://example.com/bbb' });
|
|
36
|
-
* await queue.addRequest({ url: 'http://example.com/foo/bar' }, { forefront: true });
|
|
37
|
-
* ```
|
|
38
|
-
* @category Sources
|
|
39
|
-
*/
|
|
40
|
-
export declare class RequestQueue extends RequestProvider {
|
|
41
|
-
private listHeadAndLockPromise;
|
|
42
|
-
private queueHasLockedRequests;
|
|
43
|
-
private shouldCheckForForefrontRequests;
|
|
44
|
-
private dequeuedRequestCount;
|
|
45
|
-
constructor(options: RequestProviderOptions, config?: Configuration);
|
|
46
|
-
/**
|
|
47
|
-
* Caches information about request to beware of unneeded addRequest() calls.
|
|
48
|
-
*/
|
|
49
|
-
protected _cacheRequest(cacheKey: string, queueOperationInfo: RequestQueueOperationInfo): void;
|
|
50
|
-
/**
|
|
51
|
-
* @inheritDoc
|
|
52
|
-
*/
|
|
53
|
-
addRequest(requestLike: Source, options?: RequestQueueOperationOptions): Promise<RequestQueueOperationInfo>;
|
|
54
|
-
/**
|
|
55
|
-
* @inheritDoc
|
|
56
|
-
*/
|
|
57
|
-
addRequests(requestsLike: Source[], options?: RequestQueueOperationOptions): Promise<BatchAddRequestsResult>;
|
|
58
|
-
/**
|
|
59
|
-
* @inheritDoc
|
|
60
|
-
*/
|
|
61
|
-
fetchNextRequest<T extends Dictionary = Dictionary>(): Promise<Request<T> | null>;
|
|
62
|
-
/**
|
|
63
|
-
* @inheritDoc
|
|
64
|
-
*/
|
|
65
|
-
markRequestHandled(request: Request): Promise<RequestQueueOperationInfo | null>;
|
|
66
|
-
/**
|
|
67
|
-
* @inheritDoc
|
|
68
|
-
*/
|
|
69
|
-
isFinished(): Promise<boolean>;
|
|
70
|
-
/**
|
|
71
|
-
* @inheritDoc
|
|
72
|
-
*/
|
|
73
|
-
reclaimRequest(...args: Parameters<RequestProvider['reclaimRequest']>): ReturnType<RequestProvider['reclaimRequest']>;
|
|
74
|
-
protected ensureHeadIsNonEmpty(): Promise<void>;
|
|
75
|
-
private giveUpLock;
|
|
76
|
-
private _listHeadAndLock;
|
|
77
|
-
private getOrHydrateRequest;
|
|
78
|
-
private _prolongRequestLock;
|
|
79
|
-
protected _reset(): void;
|
|
80
|
-
protected _maybeAddRequestToQueueHead(): void;
|
|
81
|
-
protected _clearPossibleLocks(): Promise<void>;
|
|
82
|
-
/**
|
|
83
|
-
* @inheritDoc
|
|
84
|
-
*/
|
|
85
|
-
static open(...args: Parameters<typeof RequestProvider.open>): Promise<RequestQueue>;
|
|
86
|
-
}
|
|
87
|
-
//# sourceMappingURL=request_queue_v2.d.ts.map
|