@crawlee/basic 3.0.0-alpha.2 → 3.0.0-alpha.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/index.d.ts +4 -0
- package/index.d.ts.map +1 -0
- package/index.js.map +1 -0
- package/internals/basic-crawler.d.ts +377 -0
- package/internals/basic-crawler.d.ts.map +1 -0
- package/internals/basic-crawler.js +687 -0
- package/internals/basic-crawler.js.map +1 -0
- package/internals/constants.d.ts +6 -0
- package/internals/constants.d.ts.map +1 -0
- package/internals/constants.js +9 -0
- package/internals/constants.js.map +1 -0
- package/package.json +2 -5
- package/tsconfig.build.tsbuildinfo +1 -0
package/index.d.ts
ADDED
package/index.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,2BAA2B,CAAC;AAC1C,cAAc,uBAAuB,CAAC"}
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,wDAA8B;AAC9B,oEAA0C;AAC1C,gEAAsC"}
|
|
@@ -0,0 +1,377 @@
|
|
|
1
|
+
import { Log } from '@apify/log';
|
|
2
|
+
import { AutoscaledPool, AutoscaledPoolOptions, EnqueueLinksOptions, CrawlerHandleFailedRequestInput, ProxyInfo, QueueOperationInfo, Request, RequestList, RequestQueue, Session, SessionPool, SessionPoolOptions, Statistics, type CrawlingContext, RequestOptions, RequestQueueOperationOptions, Configuration, EventManager, FinalStatistics } from '@crawlee/core';
|
|
3
|
+
import { Awaitable } from '@crawlee/utils';
|
|
4
|
+
export interface BasicCrawlerCrawlingContext extends CrawlingContext {
|
|
5
|
+
crawler: BasicCrawler;
|
|
6
|
+
enqueueLinks: (options: BasicCrawlerEnqueueLinksOptions) => Promise<QueueOperationInfo[]>;
|
|
7
|
+
}
|
|
8
|
+
export interface BasicCrawlerHandleFailedRequestInput extends CrawlerHandleFailedRequestInput {
|
|
9
|
+
crawler: BasicCrawler;
|
|
10
|
+
}
|
|
11
|
+
/** @internal */
|
|
12
|
+
export declare type BasicCrawlerEnqueueLinksOptions = Omit<EnqueueLinksOptions, 'requestQueue'>;
|
|
13
|
+
export declare type RequestHandler<Context extends CrawlingContext = BasicCrawlerCrawlingContext> = (inputs: Context) => Awaitable<void>;
|
|
14
|
+
export declare type FailedRequestHandler<Inputs extends CrawlerHandleFailedRequestInput = BasicCrawlerHandleFailedRequestInput> = (inputs: Inputs) => Awaitable<void>;
|
|
15
|
+
export interface BasicCrawlerOptions<Context extends CrawlingContext = BasicCrawlerCrawlingContext, ErrorContext extends CrawlerHandleFailedRequestInput = BasicCrawlerHandleFailedRequestInput> {
|
|
16
|
+
/**
|
|
17
|
+
* User-provided function that performs the logic of the crawler. It is called for each URL to crawl.
|
|
18
|
+
*
|
|
19
|
+
* The function receives the following object as an argument:
|
|
20
|
+
* ```
|
|
21
|
+
* {
|
|
22
|
+
* request: Request,
|
|
23
|
+
* session: Session,
|
|
24
|
+
* crawler: BasicCrawler,
|
|
25
|
+
* }
|
|
26
|
+
* ```
|
|
27
|
+
* where the {@link Request} instance represents the URL to crawl.
|
|
28
|
+
*
|
|
29
|
+
* The function must return a promise, which is then awaited by the crawler.
|
|
30
|
+
*
|
|
31
|
+
* If the function throws an exception, the crawler will try to re-crawl the
|
|
32
|
+
* request later, up to `option.maxRequestRetries` times.
|
|
33
|
+
* If all the retries fail, the crawler calls the function
|
|
34
|
+
* provided to the `handleFailedRequestFunction` parameter.
|
|
35
|
+
* To make this work, you should **always**
|
|
36
|
+
* let your function throw exceptions rather than catch them.
|
|
37
|
+
* The exceptions are logged to the request using the
|
|
38
|
+
* {@link Request.pushErrorMessage} function.
|
|
39
|
+
*/
|
|
40
|
+
requestHandler: RequestHandler<Context>;
|
|
41
|
+
/**
|
|
42
|
+
* User-provided function that performs the logic of the crawler. It is called for each URL to crawl.
|
|
43
|
+
*
|
|
44
|
+
* The function receives the following object as an argument:
|
|
45
|
+
* ```
|
|
46
|
+
* {
|
|
47
|
+
* request: Request,
|
|
48
|
+
* session: Session,
|
|
49
|
+
* crawler: BasicCrawler,
|
|
50
|
+
* }
|
|
51
|
+
* ```
|
|
52
|
+
* where the {@link Request} instance represents the URL to crawl.
|
|
53
|
+
*
|
|
54
|
+
* The function must return a promise, which is then awaited by the crawler.
|
|
55
|
+
*
|
|
56
|
+
* If the function throws an exception, the crawler will try to re-crawl the
|
|
57
|
+
* request later, up to `option.maxRequestRetries` times.
|
|
58
|
+
* If all the retries fail, the crawler calls the function
|
|
59
|
+
* provided to the `handleFailedRequestFunction` parameter.
|
|
60
|
+
* To make this work, you should **always**
|
|
61
|
+
* let your function throw exceptions rather than catch them.
|
|
62
|
+
* The exceptions are logged to the request using the
|
|
63
|
+
* {@link Request.pushErrorMessage} function.
|
|
64
|
+
*
|
|
65
|
+
* @deprecated `handleRequestFunction` has been renamed to `requestHandler` and will be removed in a future version.
|
|
66
|
+
*/
|
|
67
|
+
handleRequestFunction?: RequestHandler<Context>;
|
|
68
|
+
/**
|
|
69
|
+
* Static list of URLs to be processed.
|
|
70
|
+
* Either `requestList` or `requestQueue` option must be provided (or both).
|
|
71
|
+
*/
|
|
72
|
+
requestList?: RequestList;
|
|
73
|
+
/**
|
|
74
|
+
* Dynamic queue of URLs to be processed. This is useful for recursive crawling of websites.
|
|
75
|
+
* Either `requestList` or `requestQueue` option must be provided (or both).
|
|
76
|
+
*/
|
|
77
|
+
requestQueue?: RequestQueue;
|
|
78
|
+
/**
|
|
79
|
+
* Timeout in which the function passed as `requestHandler` needs to finish, in seconds.
|
|
80
|
+
* @default 60
|
|
81
|
+
*/
|
|
82
|
+
requestHandlerTimeoutSecs?: number;
|
|
83
|
+
/**
|
|
84
|
+
* Timeout in which the function passed as `requestHandler` needs to finish, in seconds.
|
|
85
|
+
* @default 60
|
|
86
|
+
* @deprecated `handleRequestTimeoutSecs` has been renamed to `requestHandlerTimeoutSecs` and will be removed in a future version.
|
|
87
|
+
*/
|
|
88
|
+
handleRequestTimeoutSecs?: number;
|
|
89
|
+
/**
|
|
90
|
+
* A function to handle requests that failed more than `option.maxRequestRetries` times.
|
|
91
|
+
*
|
|
92
|
+
* The function receives the following object as an argument:
|
|
93
|
+
* ```
|
|
94
|
+
* {
|
|
95
|
+
* request: Request,
|
|
96
|
+
* error: Error,
|
|
97
|
+
* session: Session,
|
|
98
|
+
* crawler: BasicCrawler,
|
|
99
|
+
* }
|
|
100
|
+
* ```
|
|
101
|
+
* where the {@link Request} instance corresponds to the failed request, and the `Error` instance
|
|
102
|
+
* represents the last error thrown during processing of the request.
|
|
103
|
+
*
|
|
104
|
+
* See
|
|
105
|
+
* [source code](https://github.com/apify/apify-js/blob/master/src/crawlers/basic_crawler.js#L11)
|
|
106
|
+
* for the default implementation of this function.
|
|
107
|
+
*/
|
|
108
|
+
failedRequestHandler?: FailedRequestHandler<ErrorContext>;
|
|
109
|
+
/**
|
|
110
|
+
* A function to handle requests that failed more than `option.maxRequestRetries` times.
|
|
111
|
+
*
|
|
112
|
+
* The function receives the following object as an argument:
|
|
113
|
+
* ```
|
|
114
|
+
* {
|
|
115
|
+
* request: Request,
|
|
116
|
+
* error: Error,
|
|
117
|
+
* session: Session,
|
|
118
|
+
* crawler: BasicCrawler,
|
|
119
|
+
* }
|
|
120
|
+
* ```
|
|
121
|
+
* where the {@link Request} instance corresponds to the failed request, and the `Error` instance
|
|
122
|
+
* represents the last error thrown during processing of the request.
|
|
123
|
+
*
|
|
124
|
+
* See
|
|
125
|
+
* [source code](https://github.com/apify/apify-js/blob/master/src/crawlers/basic_crawler.js#L11)
|
|
126
|
+
* for the default implementation of this function.
|
|
127
|
+
*
|
|
128
|
+
* @deprecated `handleFailedRequestFunction` has been renamed to `failedRequestHandler` and will be removed in a future version.
|
|
129
|
+
*/
|
|
130
|
+
handleFailedRequestFunction?: FailedRequestHandler<ErrorContext>;
|
|
131
|
+
/**
|
|
132
|
+
* Indicates how many times the request is retried if {@link requestHandler} or {@link handlePageFunction} fails.
|
|
133
|
+
* @default 3
|
|
134
|
+
*/
|
|
135
|
+
maxRequestRetries?: number;
|
|
136
|
+
/**
|
|
137
|
+
* Maximum number of pages that the crawler will open. The crawl will stop when this limit is reached.
|
|
138
|
+
* Always set this value in order to prevent infinite loops in misconfigured crawlers.
|
|
139
|
+
* Note that in cases of parallel crawling, the actual number of pages visited might be slightly higher than this value.
|
|
140
|
+
*/
|
|
141
|
+
maxRequestsPerCrawl?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Custom options passed to the underlying {@link AutoscaledPool} constructor.
|
|
144
|
+
* Note that the `runTaskFunction` and `isTaskReadyFunction` options
|
|
145
|
+
* are provided by the crawler and cannot be overridden.
|
|
146
|
+
* However, you can provide a custom implementation of `isFinishedFunction`.
|
|
147
|
+
*/
|
|
148
|
+
autoscaledPoolOptions?: AutoscaledPoolOptions;
|
|
149
|
+
/**
|
|
150
|
+
* Sets the minimum concurrency (parallelism) for the crawl. Shortcut to the corresponding {@link AutoscaledPool} option.
|
|
151
|
+
*
|
|
152
|
+
* *WARNING:* If you set this value too high with respect to the available system memory and CPU, your crawler will run extremely slow or crash.
|
|
153
|
+
* If you're not sure, just keep the default value and the concurrency will scale up automatically.
|
|
154
|
+
*/
|
|
155
|
+
minConcurrency?: number;
|
|
156
|
+
/**
|
|
157
|
+
* Sets the maximum concurrency (parallelism) for the crawl. Shortcut to the corresponding {@link AutoscaledPool} option.
|
|
158
|
+
*/
|
|
159
|
+
maxConcurrency?: number;
|
|
160
|
+
/**
|
|
161
|
+
* Basic crawler will initialize the {@link SessionPool} with the corresponding `sessionPoolOptions`.
|
|
162
|
+
* The session instance will be than available in the `handleRequestFunction`.
|
|
163
|
+
*/
|
|
164
|
+
useSessionPool?: boolean;
|
|
165
|
+
/**
|
|
166
|
+
* The configuration options for {@link SessionPool} to use.
|
|
167
|
+
*/
|
|
168
|
+
sessionPoolOptions?: SessionPoolOptions;
|
|
169
|
+
/** @internal */
|
|
170
|
+
log?: Log;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Provides a simple framework for parallel crawling of web pages.
|
|
174
|
+
* The URLs to crawl are fed either from a static list of URLs
|
|
175
|
+
* or from a dynamic queue of URLs enabling recursive crawling of websites.
|
|
176
|
+
*
|
|
177
|
+
* `BasicCrawler` is a low-level tool that requires the user to implement the page
|
|
178
|
+
* download and data extraction functionality themselves.
|
|
179
|
+
* If you want a crawler that already facilitates this functionality,
|
|
180
|
+
* please consider using {@link CheerioCrawler}, {@link PuppeteerCrawler} or {@link PlaywrightCrawler}.
|
|
181
|
+
*
|
|
182
|
+
* `BasicCrawler` invokes the user-provided {@link BasicCrawlerOptions.requestHandler}
|
|
183
|
+
* for each {@link Request} object, which represents a single URL to crawl.
|
|
184
|
+
* The {@link Request} objects are fed from the {@link RequestList} or the {@link RequestQueue}
|
|
185
|
+
* instances provided by the {@link BasicCrawlerOptions.requestList} or {@link BasicCrawlerOptions.requestQueue}
|
|
186
|
+
* constructor options, respectively.
|
|
187
|
+
*
|
|
188
|
+
* If both {@link BasicCrawlerOptions.requestList} and {@link BasicCrawlerOptions.requestQueue} options are used,
|
|
189
|
+
* the instance first processes URLs from the {@link RequestList} and automatically enqueues all of them
|
|
190
|
+
* to {@link RequestQueue} before it starts their processing. This ensures that a single URL is not crawled multiple times.
|
|
191
|
+
*
|
|
192
|
+
* The crawler finishes if there are no more {@link Request} objects to crawl.
|
|
193
|
+
*
|
|
194
|
+
* New requests are only dispatched when there is enough free CPU and memory available,
|
|
195
|
+
* using the functionality provided by the {@link AutoscaledPool} class.
|
|
196
|
+
* All {@link AutoscaledPool} configuration options can be passed to the `autoscaledPoolOptions`
|
|
197
|
+
* parameter of the `BasicCrawler` constructor. For user convenience, the `minConcurrency` and `maxConcurrency`
|
|
198
|
+
* {@link AutoscaledPool} options are available directly in the `BasicCrawler` constructor.
|
|
199
|
+
*
|
|
200
|
+
* **Example usage:**
|
|
201
|
+
*
|
|
202
|
+
* ```javascript
|
|
203
|
+
* const { gotScraping } = require('got-scraping');
|
|
204
|
+
*
|
|
205
|
+
* // Prepare a list of URLs to crawl
|
|
206
|
+
* const requestList = new RequestList({
|
|
207
|
+
* sources: [
|
|
208
|
+
* { url: 'http://www.example.com/page-1' },
|
|
209
|
+
* { url: 'http://www.example.com/page-2' },
|
|
210
|
+
* ],
|
|
211
|
+
* });
|
|
212
|
+
* await requestList.initialize();
|
|
213
|
+
*
|
|
214
|
+
* // Crawl the URLs
|
|
215
|
+
* const crawler = new BasicCrawler({
|
|
216
|
+
* requestList,
|
|
217
|
+
* handleRequestFunction: async ({ request }) => {
|
|
218
|
+
* // 'request' contains an instance of the Request class
|
|
219
|
+
* // Here we simply fetch the HTML of the page and store it to a dataset
|
|
220
|
+
* const { body } = await gotScraping({
|
|
221
|
+
* url: request.url,
|
|
222
|
+
* method: request.method,
|
|
223
|
+
* body: request.payload,
|
|
224
|
+
* headers: request.headers,
|
|
225
|
+
* });
|
|
226
|
+
*
|
|
227
|
+
* await Actor.pushData({
|
|
228
|
+
* url: request.url,
|
|
229
|
+
* html: body,
|
|
230
|
+
* })
|
|
231
|
+
* },
|
|
232
|
+
* });
|
|
233
|
+
*
|
|
234
|
+
* await crawler.run();
|
|
235
|
+
* ```
|
|
236
|
+
* @category Crawlers
|
|
237
|
+
*/
|
|
238
|
+
export declare class BasicCrawler<Context extends CrawlingContext = BasicCrawlerCrawlingContext, ErrorContext extends CrawlerHandleFailedRequestInput = BasicCrawlerHandleFailedRequestInput> {
|
|
239
|
+
readonly config: Configuration;
|
|
240
|
+
/**
|
|
241
|
+
* Static list of URLs to be processed.
|
|
242
|
+
*/
|
|
243
|
+
readonly stats: Statistics;
|
|
244
|
+
/**
|
|
245
|
+
* A reference to the underlying {@link RequestList} class that manages the crawler's {@link Request}s.
|
|
246
|
+
* Either `requestList` or `requestQueue` option must be provided (or both).
|
|
247
|
+
* Only available if used by the crawler.
|
|
248
|
+
*/
|
|
249
|
+
requestList?: RequestList;
|
|
250
|
+
/**
|
|
251
|
+
* Dynamic queue of URLs to be processed. This is useful for recursive crawling of websites.
|
|
252
|
+
* A reference to the underlying {@link RequestQueue} class that manages the crawler's {@link Request}s.
|
|
253
|
+
* Either `requestList` or `requestQueue` option must be provided (or both).
|
|
254
|
+
* Only available if used by the crawler.
|
|
255
|
+
*/
|
|
256
|
+
requestQueue?: RequestQueue;
|
|
257
|
+
/**
|
|
258
|
+
* A reference to the underlying {@link SessionPool} class that manages the crawler's {@link Session}s.
|
|
259
|
+
* Only available if used by the crawler.
|
|
260
|
+
*/
|
|
261
|
+
sessionPool?: SessionPool;
|
|
262
|
+
/**
|
|
263
|
+
* A reference to the underlying {@link AutoscaledPool} class that manages the concurrency of the crawler.
|
|
264
|
+
* Note that this property is only initialized after calling the {@link BasicCrawler.run} function.
|
|
265
|
+
* You can use it to change the concurrency settings on the fly,
|
|
266
|
+
* to pause the crawler by calling {@link AutoscaledPool.pause}
|
|
267
|
+
* or to abort it by calling {@link AutoscaledPool.abort}.
|
|
268
|
+
*/
|
|
269
|
+
autoscaledPool?: AutoscaledPool;
|
|
270
|
+
protected log: Log;
|
|
271
|
+
protected requestHandler: RequestHandler<Context>;
|
|
272
|
+
protected failedRequestHandler?: FailedRequestHandler<ErrorContext>;
|
|
273
|
+
protected requestHandlerTimeoutMillis: number;
|
|
274
|
+
protected internalTimeoutMillis: number;
|
|
275
|
+
protected maxRequestRetries: number;
|
|
276
|
+
protected handledRequestsCount: number;
|
|
277
|
+
protected sessionPoolOptions: SessionPoolOptions;
|
|
278
|
+
protected useSessionPool: boolean;
|
|
279
|
+
protected crawlingContexts: Map<string, Context>;
|
|
280
|
+
protected autoscaledPoolOptions: AutoscaledPoolOptions;
|
|
281
|
+
protected events: EventManager;
|
|
282
|
+
protected static optionsShape: {
|
|
283
|
+
requestList: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
284
|
+
requestQueue: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
285
|
+
requestHandler: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
|
|
286
|
+
handleRequestFunction: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
|
|
287
|
+
requestHandlerTimeoutSecs: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
288
|
+
handleRequestTimeoutSecs: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
289
|
+
failedRequestHandler: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
|
|
290
|
+
handleFailedRequestFunction: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
|
|
291
|
+
maxRequestRetries: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
292
|
+
maxRequestsPerCrawl: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
293
|
+
autoscaledPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
294
|
+
sessionPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
295
|
+
useSessionPool: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
296
|
+
minConcurrency: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
297
|
+
maxConcurrency: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
298
|
+
log: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
299
|
+
};
|
|
300
|
+
/**
|
|
301
|
+
* All `BasicCrawler` parameters are passed via an options object.
|
|
302
|
+
*/
|
|
303
|
+
constructor(options: BasicCrawlerOptions<Context, ErrorContext>, config?: Configuration);
|
|
304
|
+
/**
|
|
305
|
+
* Runs the crawler. Returns a promise that gets resolved once all the requests are processed.
|
|
306
|
+
*/
|
|
307
|
+
run(): Promise<FinalStatistics>;
|
|
308
|
+
getRequestQueue(): Promise<RequestQueue>;
|
|
309
|
+
/**
|
|
310
|
+
* Adds requests to be processed by the crawler
|
|
311
|
+
* @param requests The requests to add
|
|
312
|
+
* @param options Options for the request queue
|
|
313
|
+
*/
|
|
314
|
+
addRequests(requests: (string | Request | RequestOptions)[], options?: RequestQueueOperationOptions): Promise<import("packages/core/dist/storages/storage").BatchAddRequestsResult>;
|
|
315
|
+
protected _init(): Promise<void>;
|
|
316
|
+
protected _runRequestHandler(crawlingContext: Context): Promise<void>;
|
|
317
|
+
protected _pauseOnMigration(): Promise<void>;
|
|
318
|
+
/**
|
|
319
|
+
* Fetches request from either RequestList or RequestQueue. If request comes from a RequestList
|
|
320
|
+
* and RequestQueue is present then enqueues it to the queue first.
|
|
321
|
+
*/
|
|
322
|
+
protected _fetchNextRequest(): Promise<Request | null>;
|
|
323
|
+
/**
|
|
324
|
+
* Wrapper around requestHandler that fetches requests from RequestList/RequestQueue
|
|
325
|
+
* then retries them in a case of an error, etc.
|
|
326
|
+
*/
|
|
327
|
+
protected _runTaskFunction(): Promise<void>;
|
|
328
|
+
/**
|
|
329
|
+
* Run async callback with given timeout and retry.
|
|
330
|
+
* @ignore
|
|
331
|
+
*/
|
|
332
|
+
protected _timeoutAndRetry(handler: () => Promise<unknown>, timeout: number, error: Error | string, maxRetries?: number, retried?: number): Promise<void>;
|
|
333
|
+
/**
|
|
334
|
+
* Returns true if either RequestList or RequestQueue have a request ready for processing.
|
|
335
|
+
*/
|
|
336
|
+
protected _isTaskReadyFunction(): Promise<boolean>;
|
|
337
|
+
/**
|
|
338
|
+
* Returns true if both RequestList and RequestQueue have all requests finished.
|
|
339
|
+
*/
|
|
340
|
+
protected _defaultIsFinishedFunction(): Promise<boolean>;
|
|
341
|
+
/**
|
|
342
|
+
* Handles errors thrown by user provided handleRequestFunction()
|
|
343
|
+
*/
|
|
344
|
+
protected _requestFunctionErrorHandler(error: Error, crawlingContext: Context, source: RequestList | RequestQueue): Promise<void>;
|
|
345
|
+
protected _handleFailedRequestHandler(crawlingContext: ErrorContext): Promise<void>;
|
|
346
|
+
/**
|
|
347
|
+
* Updates handledRequestsCount from possibly stored counts,
|
|
348
|
+
* usually after worker migration. Since one of the stores
|
|
349
|
+
* needs to have priority when both are present,
|
|
350
|
+
* it is the request queue, because generally, the request
|
|
351
|
+
* list will first be dumped into the queue and then left
|
|
352
|
+
* empty.
|
|
353
|
+
*/
|
|
354
|
+
protected _loadHandledRequestCount(): Promise<void>;
|
|
355
|
+
protected _executeHooks<HookLike extends (...args: any[]) => Awaitable<void>>(hooks: HookLike[], ...args: Parameters<HookLike>): Promise<void>;
|
|
356
|
+
/**
|
|
357
|
+
* Function for cleaning up after all request are processed.
|
|
358
|
+
* @ignore
|
|
359
|
+
*/
|
|
360
|
+
teardown(): Promise<void>;
|
|
361
|
+
protected _handlePropertyNameChange<New, Old>({ newProperty, newName, oldProperty, oldName, propertyKey, allowUndefined, }: HandlePropertyNameChangeData<New, Old>): void;
|
|
362
|
+
}
|
|
363
|
+
export interface CreateContextOptions {
|
|
364
|
+
request: Request;
|
|
365
|
+
session?: Session;
|
|
366
|
+
proxyInfo?: ProxyInfo;
|
|
367
|
+
}
|
|
368
|
+
interface HandlePropertyNameChangeData<New, Old> {
|
|
369
|
+
oldProperty?: Old;
|
|
370
|
+
newProperty?: New;
|
|
371
|
+
oldName: string;
|
|
372
|
+
newName: string;
|
|
373
|
+
propertyKey: string;
|
|
374
|
+
allowUndefined?: boolean;
|
|
375
|
+
}
|
|
376
|
+
export {};
|
|
377
|
+
//# sourceMappingURL=basic-crawler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"basic-crawler.d.ts","sourceRoot":"","sources":["../../src/internals/basic-crawler.ts"],"names":[],"mappings":"AAAA,OAAmB,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAG7C,OAAO,EACH,cAAc,EACd,qBAAqB,EACrB,mBAAmB,EACnB,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