Skip to main content
Version: Next

LinkeDOMCrawlerEnqueueLinksOptions

Hierarchy

Index

Properties

optionalinheritedbaseUrl

baseUrl?: string

A base URL that will be used to resolve relative URLs when using Cheerio. Ignored when using Puppeteer, since the relative URL resolution is done inside the browser automatically.

optionalinheritedexclude

exclude?: readonly (GlobInput | RegExpInput)[]

An array of glob pattern strings, regexp patterns or plain objects containing patterns matching URLs that will never be enqueued.

The plain objects must include either the glob property or the regexp property. All remaining keys will be used as request options for the corresponding enqueued Request objects.

Glob matching is always case-insensitive. If you need case-sensitive matching, provide a regexp.

optionalinheritedforefront

forefront?: boolean = false

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.

optionalinheritedglobs

globs?: readonly GlobInput[]

An array of glob pattern strings or plain objects containing glob pattern strings matching the URLs to be enqueued.

The plain objects must include at least the glob property, which holds the glob pattern string. All remaining keys will be used as request options for the corresponding enqueued Request objects.

The matching is always case-insensitive. If you need case-sensitive matching, use regexps property directly.

If globs is an empty array or undefined, and regexps are also not defined, then the function enqueues the links with the same subdomain.

optionalinheritedlabel

label?: string

Sets Request.label for newly enqueued requests.

optionalinheritedlimit

limit?: number

Limit the amount of actually enqueued URLs to this number. Useful for testing across the entire crawling scope.

optionalinheritedpseudoUrls

pseudoUrls?: readonly PseudoUrlInput[]

NOTE: In future versions of SDK the options will be removed. Please use globs or regexps instead.

An array of PseudoUrl strings or plain objects containing PseudoUrl strings matching the URLs to be enqueued.

The plain objects must include at least the purl property, which holds the pseudo-URL string. All remaining keys will be used as request options for the corresponding enqueued Request objects.

With a pseudo-URL string, the matching is always case-insensitive. If you need case-sensitive matching, use regexps property directly.

If pseudoUrls is an empty array or undefined, then the function enqueues the links with the same subdomain.

@deprecated

prefer using globs or regexps instead

optionalinheritedregexps

regexps?: readonly RegExpInput[]

An array of regular expressions or plain objects containing regular expressions matching the URLs to be enqueued.

The plain objects must include at least the regexp property, which holds the regular expression. All remaining keys will be used as request options for the corresponding enqueued Request objects.

If regexps is an empty array or undefined, and globs are also not defined, then the function enqueues the links with the same subdomain.

optionalinheritedselector

selector?: string

A CSS selector matching links to be enqueued.

optionalinheritedskipNavigation

skipNavigation?: boolean = false

If set to true, tells the crawler to skip navigation and process the request directly.

optionalinheritedstrategy

strategy?: EnqueueStrategy | all | same-domain | same-hostname | same-origin = EnqueueStrategy | all | same-domain | same-hostname | same-origin

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

transformRequestFunction?: RequestTransform

Just before a new Request is constructed and enqueued to the RequestQueue, this function can be used to remove it or modify its 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 object, 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 a priority over request options specified in globs, regexps, or pseudoUrls objects, and thus some options could be over-written by transformRequestFunction.

optionalinheriteduserData

userData?: Dictionary

Sets Request.userData for newly enqueued requests.

optionalinheritedwaitForAllRequestsToBeAdded

waitForAllRequestsToBeAdded?: boolean

By default, only the first batch (1000) of found requests will be added to the queue before resolving the call. You can use this option to wait for adding all of them.