AdaptivePlaywrightCrawler <ContextExtension, ExtendedContext, Routes, StatisticStateExtension>
Hierarchy
- BasicCrawler<AdaptivePlaywrightCrawlerContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension>
- AdaptivePlaywrightCrawler
Index
Constructors
Properties
Accessors
Methods
Constructors
constructor
- experimental
Parameters
options: AdaptivePlaywrightCrawlerOptions<ContextExtension, ExtendedContext, Routes, StatisticStateExtension> = {}
Returns AdaptivePlaywrightCrawler<ContextExtension, ExtendedContext, Routes, StatisticStateExtension>
Properties
optionalreadonlyinheritedproxyConfigurationexperimental
A reference to the underlying IProxyConfiguration instance that manages the crawler's proxies. Only available if used by the crawler.
readonlyinheritedrouterexperimental
Default Router instance that will be used if we don't specify any requestHandler.
See router.addHandler() and router.addDefaultHandler().
Accessors
inheritedbasicContextPipeline
- experimental
The basic part of the context pipeline. Unlike the subclass pipeline, this part has no major side effects (e.g. launching a browser). It also makes typing more explicit, as subclass pipelines expect the basic crawler fields to already be present in the context at runtime.
Context built with this pipeline can be passed into multiple crawler pipelines at once. This is used e.g. in the
AdaptivePlaywrightCrawler.Returns ContextPipeline<{ request: CrawleeRequest<Dictionary> }, CrawlingContext<Dictionary>>
inheritedconcurrencySystem
- experimental
The concurrency governor the run in progress is booking its requests against — either the
concurrencySystemthat was injected, or the default the crawler built for itself. Read it for telemetry:desiredConcurrency,currentConcurrency,isRunning.NOTE:
undefinedoutside a run, and a crawler-owned default is rebuilt for every run — so read it during a run rather than caching it across runs.IConcurrencySystem is deliberately read-only. Tuning concurrency while a crawl is running means owning the instance: build a ConcurrencySystem yourself and inject it, then set
minConcurrency/maxConcurrency/desiredConcurrencyon your own reference.Returns undefined | IConcurrencySystem
inheritedcontextPipeline
- experimental
Returns ContextPipeline<CrawlingContext<Dictionary>, ExtendedContext>
inheritedhasFinishedBefore
- experimental
Whether a
run()on this instance has already finished - a repeated one continues where it left off.Returns boolean
inFlightRenderingTypeDetectionCount
- experimental
Number of rendering type detections that have not settled yet, including results the predictor is still persisting.
Returns number
inheritedlog
- experimental
Returns CrawleeLogger
inheritedrunning
- experimental
Whether a
run()is in progress on this instance.Returns boolean
inheritedsessionPool
- experimental
A reference to the underlying session pool that manages the crawler's sessions. Typed as ISessionPool so custom implementations can be plugged in via the
sessionPoolconstructor option.Returns ISessionPool
inheritedstatistics
- experimental
The statistics instance collecting the crawler's run statistics - either the injected
statisticsoption or a crawler-built default. Typed as IStatistics so custom implementations can be plugged in.Returns IStatistics<StatisticStateExtension>
Methods
inherited[asyncDispose]
- experimental
Returns Promise<void>
inheritedaddRequests
- experimental
Adds requests to the queue in batches. By default, it will resolve after the initial batch is added, and continue adding the rest in background. You can configure the batch size via
batchSizeoption and the sleep time in between the batches viawaitBetweenBatchesMillis. If you want to wait for all batches to be added to the queue, you can use thewaitForAllRequestsToBeAddedpromise you get in the response object.Optionally, the requests can be filtered using
include/excludeglob or regexp patterns and an enqueuestrategy(both AND-ed together, same asenqueueLinks), relative tobaseUrl. UnlikeenqueueLinks, there is no implicit "current page" to anchor the strategy to, sostrategydefaults toallhere.This is an alias for calling
addRequestsBatched()on the implicitRequestQueuefor this crawler instance.Parameters
requests: ReadonlyDeep<TypedRequestsLike<Routes>>
The requests to add
options: CrawlerAddRequestsOptions = {}
Options for the request queue
Returns Promise<CrawlerAddRequestsResult>
destroy
- experimental
Releases what the crawler owns beyond a single run — in the browser crawlers, the browser pool. A finished
run()has already released everything a run owns, so this is only needed before dropping a crawler you could otherwise have run again.Returns Promise<void>
drainRenderingDetections
- experimental
Waits for in-flight rendering type detections to settle, bounded by
timeoutMillis(defaults to the internal timeout).Parameters
__namedParameters: { timeoutMillis?: number } = {}
optionaltimeoutMillis: number
Returns Promise<void>
inheritedexportData
- experimental
Retrieves all the data from the default crawler Dataset and exports them to the specified format. Supported formats are currently 'json' and 'csv', and will be inferred from the
pathautomatically.Parameters
path: string
optionalformat: json | csv
optionaloptions: DatasetExportOptions
Returns Promise<Data[]>
inheritedgetData
- experimental
Retrieves data from the default crawler Dataset by calling Dataset.getData.
Parameters
rest...args: [options: DatasetDataOptions]
Returns Promise<DatasetContent<Dictionary>>
inheritedgetDataset
- experimental
Parameters
optionalidentifier: string | StorageIdentifier
Returns Promise<Dataset<Dictionary>>
inheritedgetRequestManager
- experimental
Returns the crawler's request manager, opening the default RequestQueue if none has been configured or opened yet.
Returns Promise<IRequestManager>
inheritedgetRequestQueue
- experimental
Returns Promise<IRequestManager>
Deprecated - Use
getRequestManager()instead. This returns the crawler's request manager, which is no longer guaranteed to be a RequestQueue.
inheritedpause
- experimental
Stops dispatching new requests, letting the in-progress ones finish. Resolves once they have settled, or rejects after
timeoutSecsif they take too long. Unlikestop(), this does not end the run —run()stays pending untilresume().NOTE: The concurrency system keeps monitoring and autoscaling throughout, since a shared one may still be serving other crawlers.
Parameters
optionaltimeoutSecs: number
Returns Promise<void>
inheritedpushData
- experimental
Pushes data to the specified Dataset, or the default crawler Dataset by calling Dataset.pushData.
Parameters
data: Dictionary | Dictionary[]
optionaldatasetIdentifier: string | StorageIdentifier
Returns Promise<void>
inheritedresume
- experimental
Resumes a run suspended with
pause(), letting the crawler dispatch requests again. A no-op on a crawler that is not paused.Returns void
inheritedrun
- experimental
Runs the crawler. Returns a promise that resolves once every request has been processed and the crawler's finished-check (
taskLoopOptions.isFinishedFunction, or the default "the request manager is empty") reports that the crawl is over.We can use the
requestsparameter to enqueue the initial requests — it is a shortcut for runningcrawler.addRequests()beforecrawler.run().Calling
run()again on the same instance keeps crawling the same request manager - requests the previous run handled (a failed one counts as handled) are not processed again. Purge the queue or open a fresh one if that is what you want.Parameters
optionalrequests: TypedRequestsLike<Routes>
The requests to add.
optionaloptions: CrawlerRunOptions
Options for adding the initial requests.
Returns Promise<FinalStatistics>
inheritedsetStatusMessage
- experimental
Sets the status message for the current crawler run.
This method is periodically called by the crawler, every
statusMessageLoggingIntervalseconds.The message is logged and broadcast via the
statusMessageevent. Integrations such as the Apify SDK subscribe to that event and forward the message to their status-reporting backend (e.g. the Apify platform).Parameters
message: string
options: SetStatusMessageOptions = {}
Returns void
inheritedstop
- experimental
Gracefully stops the current run of the crawler.
All the tasks active at the time of calling this method will be allowed to finish.
To stop the crawler immediately, use
crawler.teardown()instead.Parameters
reason: string = 'The crawler has been gracefully stopped.'
Returns void
teardown
- experimental
Stops the crawler immediately, but not before rendering type detections already under way (and results the predictor is still persisting) have settled - see
drainRenderingDetections(). Requests that are still running are not waited for, unlikestop().Returns Promise<void>
inheriteduseState
- experimental
Parameters
defaultValue: State = ...
Returns Promise<State>
An extension of PlaywrightCrawler that uses a more limited request handler interface so that it is able to switch to HTTP-only crawling when it detects it may be possible.
Example usage: