AdaptivePlaywrightCrawlerContext
Hierarchy
- RestrictedCrawlingContext
- AdaptivePlaywrightCrawlerContext
Index
Properties
addRequests
Type declaration
Parameters
requestsLike: readonly (string | ReadonlyObjectDeep<Partial<RequestOptions<Dictionary>> & { regex?: RegExp; requestsFromUrl?: string }> | ReadonlyObjectDeep<Request<Dictionary>>)[]
optionaloptions: ReadonlyObjectDeep<RequestQueueOperationOptions>
Options for the request queue
Returns Promise<void>
enqueueLinks
This function automatically finds and enqueues links from the current page, adding them to the RequestQueue currently used by the crawler.
Optionally, the function allows you to filter the target links' URLs using an array of globs or regular expressions and override settings of the enqueued Request objects.
Check out the Crawl a website with relative links example for more details regarding its usage.
Example usage
async requestHandler({ enqueueLinks }) {
await enqueueLinks({
globs: [
'https://www.example.com/handbags/*',
],
});
},
Type declaration
Parameters
optionaloptions: ReadonlyObjectDeep<Omit<EnqueueLinksOptions, requestQueue>>
All
enqueueLinks()
parameters are passed via an options object.
Returns Promise<unknown>
getKeyValueStore
Get a key-value store with given name or id, or the default one for the crawler.
Type declaration
Parameters
optionalidOrName: string
Returns Promise<Pick<KeyValueStore, id | name | getValue | getAutoSavedValue | setValue>>
log
A preconfigured logger for the request handler.
querySelector
Wait for an element matching the selector to appear and return a Cheerio object of matched elements.
Type declaration
Parameters
selector: string
optionaltimeoutMs: number
Returns Awaitable<Cheerio<Element>>
request
The original Request object.
useState
Returns the state - a piece of mutable persistent data shared across all the request handler runs.
Type declaration
Type parameters
- State: Dictionary = Dictionary
Parameters
optionaldefaultValue: State
Returns Promise<State>
Methods
pushData
This function allows you to push data to a Dataset specified by name, or the one currently used by the crawler.
Shortcut for
crawler.pushData()
.Parameters
optionaldata: ReadonlyDeep<Dictionary | Dictionary[]>
Data to be pushed to the default dataset.
optionaldatasetIdOrName: string
Returns Promise<void>
Add requests directly to the request queue.