Skip to main content
Version: 3.1

JSDOMCrawlingContext <UserData, JSONData>

Hierarchy

  • InternalHttpCrawlingContext<UserData, JSONData, JSDOMCrawler>
    • JSDOMCrawlingContext

Index

Properties

body

body: string | Buffer

The request body of the web page. The type depends on the Content-Type header of the web page:

  • String for text/html, application/xhtml+xml, application/xml MIME content types
  • Buffer for others MIME content types

contentType

contentType: { encoding: BufferEncoding; type: string }

Parsed Content-Type header: { type, encoding }.


Type declaration

  • encoding: BufferEncoding
  • type: string

crawler

crawler: JSDOMCrawler

enqueueLinks

enqueueLinks: (options?: EnqueueLinksOptions) => Promise<BatchAddRequestsResult>

Type declaration

id

id: string

json

json: JSONData

The parsed object from JSON string if the response contains the content type application/json.

log

log: Log

optionalproxyInfo

proxyInfo?: ProxyInfo

An object with information about currently used proxy by the crawler and configured by the ProxyConfiguration class.

request

request: Request<UserData>

The original Request object.

response

response: IncomingMessage

optionalsession

session?: Session

window

window: DOMWindow

Methods

sendRequest

  • sendRequest<Response>(overrideOptions?: Partial<OptionsInit>): Promise<Response<Response>>
  • Fires HTTP request via got-scraping, allowing to override the request options on the fly.

    This is handy when you work with a browser crawler but want to execute some requests outside it (e.g. API requests). Check the Skipping navigations for certain requests example for more detailed explanation of how to do that.

    async requestHandler({ sendRequest }) {
    const { body } = await sendRequest({
    // override headers only
    headers: { ... },
    });
    },

    Type parameters

    • Response = string

    Parameters

    • optionaloverrideOptions: Partial<OptionsInit>

    Returns Promise<Response<Response>>