CrawlerAddRequestsOptions
Hierarchy
- AddRequestsBatchedOptions
- EnqueueUrlsOptions
- CrawlerAddRequestsOptions
Index
Properties
optionalinheritedbaseUrl
A base URL that will be used to resolve relative URLs.
optionalinheritedbatchSize
optionalinheritedexclude
An array of URL patterns. Matching URLs will not be enqueued.
Accepts glob pattern strings, { glob: string } objects, RegExp instances, or { regexp: RegExp } objects.
Glob matching is always case-insensitive.
If you need case-sensitive matching, use a RegExp.
optionalinheritedforefront
If set to true:
- while adding the request to the queue: the request will be added to the foremost position in the queue.
- while reclaiming the request: the request will be placed to the beginning of the queue, so that it's returned in the next call to RequestQueue.fetchNextRequest. By default, it's put to the end of the queue.
In case the request is already present in the queue, this option has no effect.
If more requests are added with this option at once, their order in the following fetchNextRequest call
is arbitrary.
optionalinheritedinclude
An array of URL patterns that URLs must match to be enqueued.
Accepts glob pattern strings, { glob: string } objects, RegExp instances, or { regexp: RegExp } objects.
Glob matching is always case-insensitive.
If you need case-sensitive matching, use a RegExp.
The patterns are combined with the strategy using AND logic - a URL
must match at least one include pattern and satisfy the strategy to be enqueued. To match URLs across
hostnames, pass an explicit EnqueueStrategy.All strategy.
If undefined, the links are enqueued based on the strategy alone.
Passing an empty array is not allowed.
optionalinheritedlabel
Sets Request.label for newly enqueued requests.
Can be overwritten by transformRequestFunction.
optionalinheritedlimit
Limit the amount of actually enqueued URLs to this number. Useful for testing across the entire crawling scope.
optionalinheritedmaxNewRequests
If set, only this many actually new requests (i.e. not already present in the queue) will be added.
Once the budget is reached, remaining requests from the iterable will be collected in
requestsOverLimit instead.
This is useful in combination with maxRequestsPerCrawl to avoid duplicate URLs consuming the budget.
Note: Setting this option implicitly enables waitForAllRequestsToBeAdded,
since all batches must complete before leftover requests can be accurately reported.
optionalinheritedonSkippedRequest
When a request is skipped for some reason, you can use this callback to act on it. This is currently fired for requests skipped
- based on robots.txt file,
- because they don't match enqueueLinks filters,
- or because the maxRequestsPerCrawl limit has been reached
optionalinheritedsessionId
Sets Request.sessionId for newly enqueued requests.
optionalinheritedskipNavigation
If set to true, tells the crawler to skip navigation and process the request directly.
optionalinheritedstrategy
The strategy to use when enqueueing the urls.
Depending on the strategy you select, we will only check certain parts of the URLs found. Here is a diagram of each URL part and their name:
Protocol Domain
┌────┐ ┌─────────┐
https://example.crawlee.dev/...
│ └─────────────────┤
│ Hostname │
│ │
└─────────────────────────┘
Origin
optionalinheritedtransformRequestFunction
After request options are filtered by include/exclude patterns, this function can be used
to remove them or modify their contents such as userData, payload or, most importantly uniqueKey. This is useful
when you need to enqueue multiple Requests to the queue that share the same URL, but differ in methods or payloads,
or to dynamically update or create userData.
For example: by adding keepUrlFragment: true to the request options, URL fragments will not be removed
when uniqueKey is computed.
Example:
{
transformRequestFunction: (request) => {
request.userData.foo = 'bar';
request.keepUrlFragment = true;
return request;
}
}
Note that transformRequestFunction has the highest priority and can overwrite
the global label option.
The function receives a RequestOptions object and can return either:
- The modified RequestOptions object
'unchanged'to keep the original options as-is- A falsy value or
'skip'to exclude the request from the queue
optionalinheriteduserData
Sets Request.userData for newly enqueued requests.
optionalinheritedwaitBetweenBatchesMillis
optionalinheritedwaitForAllRequestsToBeAdded
Whether to wait for all the provided requests to be added, instead of waiting just for the initial batch of up to batchSize.
Options accepted by the
enqueueUrls()context helper exposed byBasicCrawler.