Skip to main content
Version: 3.8

enqueueLinks

Callable


  • This function enqueues the urls provided to the RequestQueue provided. If you want to automatically find and enqueue links, you should use the context-aware enqueueLinks function provided on the crawler contexts.

    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.

    Example usage

    await enqueueLinks({
    urls: aListOfFoundUrls,
    requestQueue,
    selector: 'a.product-detail',
    globs: [
    'https://www.example.com/handbags/*',
    'https://www.example.com/purses/*'
    ],
    });

    Parameters

    • options: { baseUrl?: string; exclude?: readonly (GlobInput | RegExpInput)[]; forefront?: boolean; globs?: readonly GlobInput[]; label?: string; limit?: number; pseudoUrls?: readonly PseudoUrlInput[]; regexps?: readonly RegExpInput[]; requestQueue: RequestProvider; selector?: string; skipNavigation?: boolean; strategy?: EnqueueStrategy | all | same-domain | same-hostname | same-origin; transformRequestFunction?: RequestTransform; urls: readonly string[]; userData?: Dictionary }

      All enqueueLinks() parameters are passed via an options object.

    Returns Promise<BatchAddRequestsResult>

    Promise that resolves to BatchAddRequestsResult object.