DOMCrawlingHelpers
Index
Methods
enqueueLinks
Parameters
optionaloptions: EnqueueLinksOptions
Returns Promise<AddRequestsBatchedResult>
extractLinks
Extracts URLs from the parsed DOM, without adding them to the request queue.
Parameters
optionaloptions: ExtractLinksOptions
Returns Promise<string[]>
parseWithCheerio
Returns Cheerio handle, allowing to work with the data same way as with CheerioCrawler. When provided with the
selectorargument, it will throw if it's not available.Example usage:
async requestHandler({ parseWithCheerio }) {const $ = await parseWithCheerio();const title = $('title').text();});Parameters
optionalselector: string
optionaltimeoutMs: number
Returns Promise<CheerioAPI>
waitForSelector
Wait for an element matching the selector to appear. The
timeoutMsonly has an effect when the parser ismutable(e.g. JSDOMCrawler withrunScripts: true); otherwise the selector is checked once and the call resolves or throws immediately. Timeout defaults to 5s.Example usage:
async requestHandler({ waitForSelector, parseWithCheerio }) {await waitForSelector('article h1');const $ = await parseWithCheerio();const title = $('title').text();});Parameters
selector: string
optionaltimeoutMs: number
Returns Promise<void>
Helper function for extracting URLs from the parsed DOM and adding them to the request queue.