Interface IContext

Hierarchy

  • IContext

Properties

counter: ICounter

You can have customized counters that collect with each task. You can have up to 100 counters for each task. Counters are not shared between tasks and task retries.

retryContext: IRetryContext
task: ITask

Methods

  • Adds a div to the dom with data provided by the user.

    Parameters

    Returns Promise<void>

  • Function that starts capturing Network Requests happening in the background while the browser is loading the page. This function is required to be called if you want to use searchForRequest function.

    Returns Promise<void>

  • Checks to see if current page is getting blocked. Uses internal block detection and can be called at anytime

    Parameters

    • Optional statusCode: number

    Returns Promise<boolean>

  • This method fetches an element with selector, scrolls it into view if needed, and then uses page.mouse to click in the center of the element. If there's no element matching selector, the method throws an error.

    Bear in mind that if click() triggers a navigation event and there's a separate page.waitForNavigation() promise to be resolved, you may end up with a race condition that yields unexpected results. The correct pattern for click and wait for navigation is the following:

    const [response] = await Promise.all([
    context.waitForNavigation(waitOptions),
    context.click(selector, clickOptions),
    ]);

    Parameters

    • selector: string
    • Optional options: {}

      Returns Promise<void>

    • Parameters

      • selector: string
      • Optional clickOptions: object
      • Optional navigationOptions: IWaitOptions

      Returns Promise<void>

    • Gets the full HTML contents of the page, may include the doctype.

      Returns Promise<string>

    • Returns all cookies the current page

      Returns Promise<ICookie[]>

    • Enable network debugger

      Returns Promise<void>

    • Executes a function in the website's browser context If the function passed to evaluate returns a Promise, then evaluate would wait for the promise to resolve and return its value.

      Parameters

      • pageFunction: (() => any)
          • (): any
          • Returns any

      • Rest ...args: Json[]

      Returns Promise<Json>

    • Executes a function in the specified context

      Parameters

      • context: string
      • pageFunction: (() => any)
          • (): any
          • Returns any

      • Rest ...args: Json[]

      Returns Promise<void | Json>

    • Carry out an extraction, and merge with the data that should be returned

      Parameters

      Returns Promise<any>

    • Function that generates time based Two-Factor Authentication tokens. It uses the secret code as input, to generate those tokens. This code is usually available in form of a QR code * when enabling the two-factor auth on a given website. This can be used to bypass two factor auth on websites.

      Parameters

      • secret: string

      Returns string

    • Immediately throws a caught exception to stop processing without it being an extraction error.

      Parameters

      • ignoreData: boolean

      Returns void

    • Refresh the page

      Returns Promise<void>

    • Report if the extractor got blocked on the target site. When the target site starts blocking connections, or throwing captchas, and there is no way to bypass it, extractor should report that it got blocked. That way the system will know that the proxy used in this connection should be taken out of rotation for the particular domain, and that this extractor should get a new proxy information on the next attempt.

      Parameters

      • code: number
      • Optional details: string

      Returns Promise<any>

    • Report that the site is reporting a different country from expected

      Returns Promise<any>

    • Adds json in a script tag, with data provided by the user.

      Parameters

      • id: string
      • data: any

      Returns Promise<void>

    • Take a screenshot.

      Use this sparingly, or consdier if you need it at all.

      Parameters

      • Optional options: {
            fullPage?: boolean;
            type?: ScreenshotType;
        }

      Returns Promise<undefined | string>

    • Scrolls page to bottom. Can be used for infinite scrolling pages.

      Parameters

      Returns Promise<void>

    • searchAllRequests will return all matching requests, regardless whether it finished or not.

      Parameters

      • urlPattern: string
      • method: string
      • pastTimestamp: number

      Returns Promise<any>

    • Searches for a Network Request that was performed on the website, and allows gathering details of that request. Requires captureRequests to be called or used during goto

      Parameters

      • urlPattern: string
      • method: string
      • pastTimestamp: number
      • timeout: number

      Returns Promise<any>

    • Set select element values

      Parameters

      • selector: string
      • Rest ...values: string[]

      Returns Promise<void>

    • Mocks browser APIs commonly used to fingerprint a user. Defaults to true. Must be called before goto.

      Parameters

      • antiFingerPrint: boolean

      Returns void

    • Block advertisments and trackers

      Must be set before calling goto.

      Parameters

      • enabled: boolean

      Returns void

    • Must be set before calling goto

      Parameters

      • enabled: boolean

      Returns void

    • Must be set before calling goto

      Parameters

      • enabled: boolean

      Returns void

    • Sets size limit for file downloads, default is 150e6 or 150Mb

      Parameters

      • downloadLimit: number

      Returns void

    • Sets retry attempts for file downloads, default is 3

      Parameters

      • downloadRetries: number

      Returns void

    • Sets timeout for file downloads, default is 240e3 or 4 minutes

      Parameters

      • downloadTimeout: number

      Returns void

    • Must be set before calling goto

      Parameters

      • headers: Record<string, string>

      Returns void

    • Timeout between start to 'did-navigate'. Defaults to 20 seconds, but can be extended. This method must be called before goto

      Parameters

      • firstRequestTimeout: number

      Returns void

    • Set the value of an input element

      Parameters

      • selector: string
      • value: string

      Returns Promise<void>

    • Must be set before calling goto

      Parameters

      • enabled: boolean

      Returns void

    • Must be set before calling goto. Default false.

      Parameters

      • enabled: boolean

      Returns void

    • Must be set before calling goto. Default false.

      Parameters

      • enabled: boolean

      Returns void

    • Specifies whether or not to use relay proxy in this extractor

      Parameters

      • useRelayProxy: boolean

      Returns void

    • Must be set before calling goto

      Parameters

      • ua: string

      Returns void

    • Must be set before calling goto

      Parameters

      • viewport: {
            height: number;
            width: number;
        }
        • height: number
        • width: number

      Returns void

    • Function allowing solving Captchas found on the page. It takes an options argument that defines an element on the page that contains the Captcha, and the type of Captcha it is.

      Parameters

      Returns Promise<any>

    • Stop the page (window.stop)

      Returns Promise<void>

    • Parameters

      • predicate: string | (() => any)
      • Optional options: ITimeoutable
      • Rest ...args: Json[]

      Returns Promise<void>

    • Wait for a subtree modification

      Parameters

      Returns Promise<void>

    • This will return a promise of a promise when the hook is in place to detect the page change

      Parameters

      Returns Promise<(() => Promise<void>)>

    • Parameters

      Returns Promise<void>

    • Parameters

      Returns Promise<void>