@crawlee/browser
Provides a simple framework for parallel crawling of web pages using headless browsers with Puppeteer and Playwright. The URLs to crawl are fed either from a static list of URLs or from a dynamic queue of URLs enabling recursive crawling of websites.
Since BrowserCrawler uses headless (or even headful) browsers to download web pages and extract data, it is useful for crawling of websites that require to execute JavaScript. If the target website doesn't need JavaScript, we should consider using the CheerioCrawler, which downloads the pages using raw HTTP requests and is about 10x faster.
The source URLs are represented by the Request objects that are fed from the RequestList or RequestQueue instances provided by the requestList or requestQueue constructor options, respectively. If neither requestList nor requestQueue options are provided, the crawler will open the default request queue either when the crawler.addRequests() function is called, or if requests parameter (representing the initial requests) of the crawler.run() function is provided.
If both requestList and requestQueue options are used, the instance first processes URLs from the RequestList and automatically enqueues all of them to the RequestQueue before it starts their processing. This ensures that a single URL is not crawled multiple times.
The crawler finishes when there are no more Request objects to crawl.
BrowserCrawler opens a new browser page (i.e. tab or window) for each Request object to crawl and then calls the function provided by user as the requestHandler option.
New pages are only opened when there is enough free CPU and memory available, as judged by the crawler's ConcurrencySystem.
Concurrency is tuned via the minConcurrency, maxConcurrency and maxRequestsPerMinute options of the BrowserCrawler constructor, or, for finer control, by injecting a pre-configured concurrencySystem.
NOTE: the pool of browser instances is internally managed by the BrowserPool class.
Index
Crawlers
Other
- AddRequestsBatchedOptions
- AddRequestsBatchedResult
- ApifyLogAdapter
- ArgumentValidationError
- BaseCrawleeLogger
- BasicCrawler
- BasicCrawlerOptions
- BasicCrawlingContext
- BLOCKED_STATUS_CODES
- CalculatedStatistics
- coerceBoolean
- coerceNumber
- ConcurrencyConsumer
- ConcurrencySystem
- ConcurrencySystemOptions
- ConfigField
- Configuration
- ConfigurationInput
- ConfigurationOptions
- ContextMiddleware
- ContextPipeline
- ContextPipelineCleanupError
- ContextPipelineInitializationError
- ContextPipelineInterruptedError
- CpuLoadSignal
- CpuLoadSignalOptions
- crawleeConfigFields
- CrawleeLogger
- CrawleeLoggerOptions
- CrawlerAddRequestsOptions
- CrawlerAddRequestsResult
- CrawlerRunOptions
- CrawlingContext
- createBasicRouter
- CreateContextOptions
- CreateSession
- createStorageTransaction
- CriticalError
- Dataset
- DatasetConsumer
- DatasetContent
- DatasetDataOptions
- DatasetExportOptions
- DatasetExportToOptions
- DatasetIteratorOptions
- DatasetJournalEntry
- DatasetMapper
- DatasetOptions
- DatasetReducer
- DatasetStats
- defaultRoute
- DefaultRouteUserData
- DefaultStorageIdentifier
- EnqueueLinksOptions
- EnqueueStrategy
- EnqueueStrategyOption
- EnqueueUrlsOptions
- ErrnoException
- ErrorHandler
- ErrorSnapshotter
- ErrorTracker
- ErrorTrackerOptions
- EventLoopLoadSignal
- EventLoopLoadSignalOptions
- EventManager
- EventManagerOptions
- EventStatusMessageData
- EventType
- EventTypeName
- ExplicitStorageIdentifier
- ExtractLinksOptions
- field
- FieldsInput
- FieldsOutput
- FinalStatistics
- GetUserDataFromRequest
- GlobInput
- GlobObject
- IConcurrencySystem
- IProxyConfiguration
- IRequestLoader
- IRequestManager
- IStatistics
- IStorage
- JournaledRequest
- JournalEntry
- KeyConsumer
- KeyValueStore
- KeyValueStoreIteratorOptions
- KeyValueStoreJournalEntry
- KeyValueStoreOptions
- KeyValueStoreRawRecord
- KeyValueStoreStats
- LabeledSource
- LoadedRequest
- LoadSignal
- LoadSignalInfo
- LoadSignalsOptions
- LoadSignalStartContext
- LoadSnapshot
- LocalEventManager
- LocalEventManagerOptions
- log
- Log
- Logger
- LoggerJson
- LoggerOptions
- LoggerText
- LogLevel
- MAX_POOL_SIZE
- MemoryLoadSignal
- MemoryLoadSignalOptions
- MemoryStorageBackend
- MemoryStorageOptions
- MissingSessionError
- NavigationSkippedError
- NonRetryableError
- PacingScope
- PacingSignal
- parseRetryAfterHeader
- parseValue
- PERSIST_STATE_KEY
- PersistenceOptions
- PersistentRateLimitError
- ProxyConfiguration
- ProxyConfigurationFunction
- ProxyConfigurationOptions
- purgeDefaultStorages
- PushErrorMessageOptions
- RecordOptions
- RecoverableState
- RecoverableStateOptions
- RecoverableStatePersistenceOptions
- RegExpInput
- RegExpObject
- Request
- RequestHandler
- RequestHandlerError
- RequestList
- RequestListOptions
- RequestListSourcesFunction
- RequestListState
- RequestLoaderStatus
- RequestManagerOpener
- RequestManagerTandem
- RequestOptions
- RequestQueue
- RequestQueueJournalEntry
- RequestQueueOperationInfo
- RequestQueueOperationOptions
- RequestQueueOptions
- RequestQueueStats
- RequestsLike
- RequestSourceStatus
- RequestState
- RequestThrottledError
- RequestTransform
- RequestValidationError
- RequireContextPipeline
- ResolvedConfigValues
- resolveStorageIdentifier
- ResponseLike
- RestrictedCrawlingContext
- RetryRequestError
- RouteOptions
- Router
- RouterHandler
- RouterHandlerContext
- RouterLabel
- RouterRoutes
- RouteSchemas
- RoutesFromSchemas
- SchemaIssue
- serializeValue
- ServiceConflictError
- serviceLocator
- ServiceLocator
- Session
- SessionError
- SessionOptions
- SessionPool
- SessionPoolOptions
- SessionReuseStrategy
- SitemapRequestLoader
- SitemapRequestLoaderOptions
- SkippedRequestCallback
- SkippedRequestReason
- SnapshotResult
- SnapshotStore
- Source
- StateConversion
- StateValidationError
- StatisticPersistedState
- Statistics
- StatisticsOptions
- StatisticState
- StatisticStateExtensionOptions
- StatusMessageCallback
- StatusMessageCallbackParams
- StorageBackend
- StorageBackendLoadSignal
- StorageBackendLoadSignalOptions
- StorageIdentifier
- StorageInstanceManager
- StorageOpenOptions
- StorageStatsTracker
- StorageTransaction
- StorageTransactionOptions
- StorageTransactionState
- StorageTransactionView
- StorageWriteMode
- StorageWritePolicy
- SyncStateConversion
- SystemInfo
- TaskLoopOptions
- TaskLoopPredicates
- ThrottlingRequestManager
- ThrottlingRequestManagerOptions
- TypedContextAddRequests
- TypedContextEnqueueLinks
- UrlPatternInput
- UrlPatternObject
- useState
- UseStateOptions
- withDirectStorageAccess
- WithRequired
- withStorageTransaction
- BrowserCrawlerOptions
- BrowserCrawlingContext
- BrowserLaunchContext
- BrowserHook
- LauncherBrowserPoolOptions
- LauncherRemoteBrowserPoolOptions
- OwnedBrowserPool
- assertBrowserPoolNotConfigured
Other
AddRequestsBatchedOptions
AddRequestsBatchedResult
ApifyLogAdapter
ArgumentValidationError
BaseCrawleeLogger
BasicCrawler
BasicCrawlerOptions
BasicCrawlingContext
BLOCKED_STATUS_CODES
CalculatedStatistics
coerceBoolean
coerceNumber
ConcurrencyConsumer
ConcurrencySystem
ConcurrencySystemOptions
ConfigField
Configuration
ConfigurationInput
ConfigurationOptions
ContextMiddleware
ContextPipeline
ContextPipelineCleanupError
ContextPipelineInitializationError
ContextPipelineInterruptedError
CpuLoadSignal
CpuLoadSignalOptions
crawleeConfigFields
CrawleeLogger
CrawleeLoggerOptions
CrawlerAddRequestsOptions
CrawlerAddRequestsResult
CrawlerRunOptions
CrawlingContext
createBasicRouter
CreateContextOptions
CreateSession
createStorageTransaction
CriticalError
Dataset
DatasetConsumer
DatasetContent
DatasetDataOptions
DatasetExportOptions
DatasetExportToOptions
DatasetIteratorOptions
DatasetJournalEntry
DatasetMapper
DatasetOptions
DatasetReducer
DatasetStats
defaultRoute
DefaultRouteUserData
DefaultStorageIdentifier
EnqueueLinksOptions
EnqueueStrategy
EnqueueStrategyOption
EnqueueUrlsOptions
ErrnoException
ErrorHandler
ErrorSnapshotter
ErrorTracker
ErrorTrackerOptions
EventLoopLoadSignal
EventLoopLoadSignalOptions
EventManager
EventManagerOptions
EventStatusMessageData
EventType
EventTypeName
ExplicitStorageIdentifier
ExtractLinksOptions
field
FieldsInput
FieldsOutput
FinalStatistics
GetUserDataFromRequest
GlobInput
GlobObject
IConcurrencySystem
IProxyConfiguration
IRequestLoader
IRequestManager
IStatistics
IStorage
JournaledRequest
JournalEntry
KeyConsumer
KeyValueStore
KeyValueStoreIteratorOptions
KeyValueStoreJournalEntry
KeyValueStoreOptions
KeyValueStoreRawRecord
KeyValueStoreStats
LabeledSource
LoadedRequest
LoadSignal
LoadSignalInfo
LoadSignalsOptions
LoadSignalStartContext
LoadSnapshot
LocalEventManager
LocalEventManagerOptions
log
Log
Logger
LoggerJson
LoggerOptions
LoggerText
LogLevel
MAX_POOL_SIZE
MemoryLoadSignal
MemoryLoadSignalOptions
MemoryStorageBackend
MemoryStorageOptions
MissingSessionError
NavigationSkippedError
NonRetryableError
PacingScope
PacingSignal
parseRetryAfterHeader
parseValue
PERSIST_STATE_KEY
PersistenceOptions
PersistentRateLimitError
ProxyConfiguration
ProxyConfigurationFunction
ProxyConfigurationOptions
purgeDefaultStorages
PushErrorMessageOptions
RecordOptions
RecoverableState
RecoverableStateOptions
RecoverableStatePersistenceOptions
RegExpInput
RegExpObject
Request
RequestHandler
RequestHandlerError
RequestList
RequestListOptions
RequestListSourcesFunction
RequestListState
RequestLoaderStatus
RequestManagerOpener
RequestManagerTandem
RequestOptions
RequestQueue
RequestQueueJournalEntry
RequestQueueOperationInfo
RequestQueueOperationOptions
RequestQueueOptions
RequestQueueStats
RequestsLike
RequestSourceStatus
RequestState
RequestThrottledError
RequestTransform
RequestValidationError
RequireContextPipeline
ResolvedConfigValues
resolveStorageIdentifier
ResponseLike
RestrictedCrawlingContext
RetryRequestError
RouteOptions
Router
RouterHandler
RouterHandlerContext
RouterLabel
RouterRoutes
RouteSchemas
RoutesFromSchemas
SchemaIssue
serializeValue
ServiceConflictError
serviceLocator
ServiceLocator
Session
SessionError
SessionOptions
SessionPool
SessionPoolOptions
SessionReuseStrategy
SitemapRequestLoader
SitemapRequestLoaderOptions
SkippedRequestCallback
SkippedRequestReason
SnapshotResult
SnapshotStore
Source
StateConversion
StateValidationError
StatisticPersistedState
Statistics
StatisticsOptions
StatisticState
StatisticStateExtensionOptions
StatusMessageCallback
StatusMessageCallbackParams
StorageBackend
StorageBackendLoadSignal
StorageBackendLoadSignalOptions
StorageIdentifier
StorageInstanceManager
StorageOpenOptions
StorageStatsTracker
StorageTransaction
StorageTransactionOptions
StorageTransactionState
StorageTransactionView
StorageWriteMode
StorageWritePolicy
SyncStateConversion
SystemInfo
TaskLoopOptions
TaskLoopPredicates
ThrottlingRequestManager
ThrottlingRequestManagerOptions
TypedContextAddRequests
TypedContextEnqueueLinks
UrlPatternInput
UrlPatternObject
useState
UseStateOptions
withDirectStorageAccess
WithRequired
withStorageTransaction
BrowserHook
Type parameters
- Context = BrowserCrawlingContext
- ContextExtension = {}
Type declaration
Parameters
crawlingContext: Context & ContextExtension
Returns Awaitable<void | Partial<Context>>
LauncherBrowserPoolOptions
LauncherRemoteBrowserPoolOptions
The RemoteBrowserPool counterpart of LauncherBrowserPoolOptions.
OwnedBrowserPool
The type of a browser pool the crawler builds (and therefore owns) for itself. It's an IBrowserPool that
additionally exposes destroy() — the crawler only ever tears down pools it created, which is why IBrowserPool
itself intentionally omits destroy.
Type parameters
- Page
The BrowserPool options a launcher-built pool accepts: everything the pool itself takes except
browserPlugins, which the launcher derives from its launch context. The hooks are deliberately unconstrained - the browser they run against is only known to the concrete*BrowserPool()factory, which is where the caller-facing types are pinned down.