Skip to main content
Version: 3.11

ErrorSnapshotter

ErrorSnapshotter class is used to capture a screenshot of the page and a snapshot of the HTML when an error occurs during web crawling.

This functionality is opt-in, and can be enabled via the crawler options:

const crawler = new BasicCrawler({
// ...
statisticsOptions: {
saveErrorSnapshots: true,
},
});

Index

Constructors

constructor

Properties

staticreadonlyBASE_MESSAGE

BASE_MESSAGE: An error occurred = 'An error occurred'

staticreadonlyMAX_ERROR_CHARACTERS

MAX_ERROR_CHARACTERS: 30 = 30

staticreadonlyMAX_FILENAME_LENGTH

MAX_FILENAME_LENGTH: 250 = 250

staticreadonlyMAX_HASH_LENGTH

MAX_HASH_LENGTH: 30 = 30

staticreadonlySNAPSHOT_PREFIX

SNAPSHOT_PREFIX: ERROR_SNAPSHOT = 'ERROR_SNAPSHOT'

Methods

captureSnapshot

  • Capture a snapshot of the error context.


    Parameters

    Returns Promise<ErrorSnapshot>

contextCaptureSnapshot

  • contextCaptureSnapshot(context: BrowserCrawlingContext, fileName: string): Promise<undefined | SnapshotResult>
  • Captures a snapshot of the current page using the context.saveSnapshot function. This function is applicable for browser contexts only. Returns an object containing the filenames of the screenshot and HTML file.


    Parameters

    • context: BrowserCrawlingContext
    • fileName: string

    Returns Promise<undefined | SnapshotResult>

generateFilename

  • Generate a unique fileName for each error snapshot.


    Parameters

    Returns string

saveHTMLSnapshot

  • saveHTMLSnapshot(html: string, keyValueStore: KeyValueStore, fileName: string): Promise<undefined | string>
  • Save the HTML snapshot of the page, and return the fileName with the extension.


    Parameters

    Returns Promise<undefined | string>