Crawlee—A web scraping and browser automation library for Node.js to build reliable crawlers. In JavaScript and TypeScript. Extract data for AI, LLMs, RAG, or GPTs. Download HTML, PDF, JPG, PNG, and other files from websites. Works with Puppeteer, Playwright, Cheerio, JSDOM, and raw HTTP. Both headful and headless mode. With proxy rotation.
TypeScript apifyautomationcrawlercrawlingheadlessheadless-chromejavascriptnodejsnpmplaywrightpuppeteerscraperscrapingtypescriptweb-crawlerweb-crawlingweb-scraping
Public API Report File for "@crawlee/playwright"
Do not edit this file. It is a report generated by API Extractor.
import type { AnyNode } from 'domhandler';
import type { Awaitable } from '@crawlee/types';
import { BasicCrawler } from '@crawlee/basic';
import type { BasicCrawlerOptions } from '@crawlee/basic';
import type { BatchAddRequestsResult } from '@crawlee/types';
import type { Browser } from 'playwright';
import { BrowserCrawler } from '@crawlee/browser';
import { BrowserCrawlerOptions } from '@crawlee/browser';
import type { BrowserCrawlingContext } from '@crawlee/browser';
import type { BrowserHook } from '@crawlee/browser';
import type { BrowserLaunchContext } from '@crawlee/browser';
import type { BrowserPool } from '@crawlee/browser-pool';
import type { BrowserPoolHooks } from '@crawlee/browser-pool';
import type { BrowserPoolOptions } from '@crawlee/browser-pool';
import type { BrowserType } from 'playwright';
import { Cheerio } from 'cheerio';
import { CheerioAPI } from 'cheerio';
import { Configuration } from '@crawlee/browser';
import type { CrawlerRemoteBrowserOptions } from '@crawlee/browser';
import type { CrawlingContext } from '@crawlee/basic';
import { CrawlingRequest } from '@crawlee/browser';
import type { Dictionary } from '@crawlee/types';
import type { Download } from 'playwright';
import type { EnqueueLinksOptions } from '@crawlee/basic';
import type { GetUserDataFromRequest } from '@crawlee/browser';
import type { GetUserDataFromRequest as GetUserDataFromRequest_2 } from '@crawlee/basic';
import { IRequestManager } from '@crawlee/browser';
import type { LaunchOptions } from 'playwright';
import type { LoadedRequest } from '@crawlee/browser';
import type { Page } from 'playwright';
import type { PlaywrightPlugin } from '@crawlee/browser-pool';
import type { RecoverableStatePersistenceOptions } from '@crawlee/core';
import type { Request as Request_2 } from '@crawlee/core';
import { Request as Request_3 } from '@crawlee/browser';
import type { RequestTransform } from '@crawlee/browser';
import type { Response as Response_2 } from 'playwright';
import type { RouterHandler } from '@crawlee/browser';
import type { RouterRoutes } from '@crawlee/browser';
import type { RouterRoutes as RouterRoutes_2 } from '@crawlee/basic';
import type { RouteSchemas } from '@crawlee/browser';
import type { RoutesFromSchemas } from '@crawlee/browser';
import type { SkippedRequestCallback } from '@crawlee/browser';
import type { StorageTransactionView } from '@crawlee/core';
import type { UrlPatternInput } from '@crawlee/browser';
import { z } from 'zod';
// Not exported by the entry point; reachable only as a referenced type.
// @public (undocumented)
type AdaptiveHook<ContextExtension = Dictionary<never>> = BrowserHook<AdaptiveHookContext, ContextExtension>;
// Not exported by the entry point; reachable only as a referenced type.
// @public (undocumented)
interface AdaptiveHookContext extends Pick<AdaptivePlaywrightCrawlerContext, 'id' | 'session' | 'proxyInfo' | 'log' | 'extendTimeout'> {
// (undocumented)
gotoOptions?: PlaywrightGotoOptions;
// (undocumented)
page?: Page;
// (undocumented)
request: CrawlingRequest;
}
// @public
export class AdaptivePlaywrightCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest_2<AdaptivePlaywrightCrawlerContext['request']>>, StatisticStateExtension extends AdaptivePlaywrightCrawlerStatisticState = AdaptivePlaywrightCrawlerStatisticState> extends BasicCrawler<AdaptivePlaywrightCrawlerContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension> {
constructor(options?: AdaptivePlaywrightCrawlerOptions<ContextExtension, ExtendedContext, Routes, StatisticStateExtension>);
// (undocumented)
destroy(): Promise<void>;
drainRenderingDetections(input?: {
timeoutMillis?: number;
}): Promise<void>;
get inFlightRenderingTypeDetectionCount(): number;
// (undocumented)
protected init(): Promise<void>;
// (undocumented)
protected runRequestHandler(crawlingContext: CrawlingContext): Promise<void>;
teardown(): Promise<void>;
}
// @public (undocumented)
export interface AdaptivePlaywrightCrawlerContext<UserData extends Dictionary = any> extends CrawlingContext<UserData> {
// (undocumented)
enqueueLinks(options?: EnqueueLinksOptions): Promise<unknown>;
page: Page;
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<CheerioAPI>;
querySelectorAll(selector: string, timeoutMs?: number): Promise<Cheerio<AnyNode>>;
querySelectorOne(selector: string, timeoutMs?: number): Promise<Cheerio<AnyNode>>;
// (undocumented)
request: LoadedRequest<CrawlingRequest<UserData>>;
response: Response;
waitForSelector(selector: string, timeoutMs?: number): Promise<void>;
}
// @public (undocumented)
export interface AdaptivePlaywrightCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest_2<AdaptivePlaywrightCrawlerContext['request']>>, StatisticStateExtension extends AdaptivePlaywrightCrawlerStatisticState = AdaptivePlaywrightCrawlerStatisticState> extends Omit<BasicCrawlerOptions<AdaptivePlaywrightCrawlerContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension>, 'preNavigationHooks' | 'postNavigationHooks' | 'contextPipelineBuilder'>, Pick<PlaywrightCrawlerOptions, 'launchContext' | 'headless' | 'browserPool' | 'remoteBrowser'> {
navigationTimeoutSecs?: number;
postNavigationHooks?: AdaptivePostNavigationHook<ContextExtension>[];
preNavigationHooks?: AdaptiveHook<ContextExtension>[];
renderingTypeDetectionRatio?: number;
renderingTypePredictor?: IRenderingTypePredictor;
resultChecker?: (result: StorageTransactionView, context: AdaptiveResultContext) => boolean;
resultComparator?: (resultA: StorageTransactionView, resultB: StorageTransactionView, context: AdaptiveResultContext) => boolean | 'equal' | 'different' | 'inconclusive';
shouldPropagateError?: (error: Error, context: PlaywrightCrawlingContext) => Awaitable<boolean>;
}
// @public
export type AdaptivePlaywrightCrawlerStatisticState = z.infer<typeof adaptiveStatisticStateSchema>;
// @public
export const adaptivePlaywrightCrawlerStatisticState: {
deserialize: z.ZodObject<{
httpOnlyRequestHandlerRuns: z.ZodDefault<z.ZodNumber>;
browserRequestHandlerRuns: z.ZodDefault<z.ZodNumber>;
renderingTypeMispredictions: z.ZodDefault<z.ZodNumber>;
}, z.core.$strip>;
};
// Not exported by the entry point; reachable only as a referenced type.
// @public (undocumented)
type AdaptivePostNavigationHook<ContextExtension = Dictionary<never>> = BrowserHook<Omit<AdaptiveHookContext, 'request'> & {
request: LoadedRequest<CrawlingRequest>;
}, ContextExtension>;
// @public
export interface AdaptiveResultContext {
request: CrawlingRequest;
}
// Not exported by the entry point; reachable only as a referenced type.
// @public (undocumented)
const adaptiveStatisticStateSchema: z.ZodObject<{
httpOnlyRequestHandlerRuns: z.ZodDefault<z.ZodNumber>;
browserRequestHandlerRuns: z.ZodDefault<z.ZodNumber>;
renderingTypeMispredictions: z.ZodDefault<z.ZodNumber>;
}, z.core.$strip>;
// @public
function blockRequests(page: Page, options?: BlockRequestsOptions): Promise<void>;
// @public (undocumented)
interface BlockRequestsOptions {
extraUrlPatterns?: string[];
urlPatterns?: string[];
}
// Not exported by the entry point; reachable only as a referenced type.
// @public (undocumented)
type ClickOptions = Parameters<Page['click']>[1];
// @public (undocumented)
type CompiledScriptFunction = (params: CompiledScriptParams) => Promise<unknown>;
// @public (undocumented)
interface CompiledScriptParams {
// (undocumented)
page: Page;
// (undocumented)
request: Request_3;
}
// @public
function compileScript(scriptString: string, context?: Dictionary): CompiledScriptFunction;
// @public (undocumented)
export function createAdaptivePlaywrightRouter<Context extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest_2<Context['request']>>>(routes?: RouterRoutes_2<Context, Routes>): RouterHandler<Context, Routes>;
// @public (undocumented)
export function createAdaptivePlaywrightRouter<Context extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext, UserData extends Dictionary = GetUserDataFromRequest_2<Context['request']>>(routes?: RouterRoutes_2<Context, Record<string, UserData>>): RouterHandler<Context, Record<string, UserData>>;
// @public (undocumented)
export function createAdaptivePlaywrightRouter<Context extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext, const Schemas extends RouteSchemas = RouteSchemas>(schemas: Schemas): RouterHandler<Context, RoutesFromSchemas<Schemas>>;
// @public
export function createPlaywrightRouter<Context extends PlaywrightCrawlingContext = PlaywrightCrawlingContext, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>>(routes?: RouterRoutes<Context, Routes>): RouterHandler<Context, Routes>;
// @public (undocumented)
export function createPlaywrightRouter<Context extends PlaywrightCrawlingContext = PlaywrightCrawlingContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, Record<string, UserData>>): RouterHandler<Context, Record<string, UserData>>;
// @public (undocumented)
export function createPlaywrightRouter<Context extends PlaywrightCrawlingContext = PlaywrightCrawlingContext, const Schemas extends RouteSchemas = RouteSchemas>(schemas: Schemas): RouterHandler<Context, RoutesFromSchemas<Schemas>>;
// @public
function enqueueLinksByClickingElements(options: EnqueueLinksByClickingElementsOptions): Promise<BatchAddRequestsResult>;
// @public (undocumented)
interface EnqueueLinksByClickingElementsOptions {
clickOptions?: ClickOptions;
exclude?: readonly UrlPatternInput[];
forefront?: boolean;
include?: UrlPatternInput[];
label?: string;
maxWaitForPageIdleSecs?: number;
onSkippedRequest?: SkippedRequestCallback;
page: Page;
requestManager: IRequestManager;
selector: string;
skipNavigation?: boolean;
transformRequestFunction?: RequestTransform;
userData?: Dictionary;
waitForPageIdleSecs?: number;
}
// @public
export function fullResultComparator(resultA: StorageTransactionView, resultB: StorageTransactionView): boolean;
// @public
function gotoExtended(page: Page, request: Request_3, gotoOptions?: PlaywrightDirectNavigationOptions): Promise<Response_2 | null>;
// @public
function handleCloudflareChallenge(page: Page, url: string, options?: HandleCloudflareChallengeOptions): Promise<Response_2 | undefined>;
// @public
export function handleCloudflareChallengeHook(options?: HandleCloudflareChallengeOptions): PlaywrightHook;
// @public (undocumented)
interface HandleCloudflareChallengeOptions {
clickCallback?: (page: Page, boundingBox: {
x: number;
y: number;
}) => Promise<void>;
clickPositionCallback?: (page: Page) => Promise<{
x: number;
y: number;
} | null>;
isBlockedCallback?: (page: Page) => Promise<boolean>;
isChallengeCallback?: (page: Page) => Promise<boolean>;
preChallengeSleepSecs?: number;
sleepSecs?: number;
verbose?: boolean;
}
// @public
function infiniteScroll(page: Page, options?: InfiniteScrollOptions): Promise<void>;
// @public (undocumented)
interface InfiniteScrollOptions {
buttonSelector?: string;
maxScrollHeight?: number;
scrollDownAndUp?: boolean;
stopScrollCallback?: () => unknown | Promise<unknown>;
timeoutSecs?: number;
waitForSecs?: number;
}
// @public
function injectFile(page: Page, filePath: string, options?: InjectFileOptions): Promise<unknown>;
// @public (undocumented)
interface InjectFileOptions {
surviveNavigations?: boolean;
}
// @public
function injectJQuery(page: Page, options?: {
surviveNavigations?: boolean;
}): Promise<unknown>;
// @public
export interface IRenderingTypePredictor {
predict(request: Request_2): Awaitable<{
renderingType: RenderingType;
detectionProbabilityRecommendation: number;
}>;
storeResult(requests: Request_2 | Request_2[], renderingType: RenderingType): Awaitable<void>;
}
// @public
export function launchPlaywright(launchContext?: PlaywrightLaunchContext, configuration?: Configuration): Promise<Browser>;
// @public
function parseWithCheerio(page: Page, ignoreShadowRoots?: boolean, ignoreIframes?: boolean): Promise<CheerioAPI>;
// @public
export type PlaywrightBrowserPool = BrowserPool<{
browserPlugins: [PlaywrightPlugin];
}, [PlaywrightPlugin]>;
// @public
export function playwrightBrowserPool(options?: PlaywrightBrowserPoolOptions): PlaywrightBrowserPool;
// @public (undocumented)
export interface PlaywrightBrowserPoolOptions extends Omit<BrowserPoolOptions, 'browserPlugins'>, BrowserPoolHooks<ReturnType<PlaywrightPlugin['createController']>, ReturnType<PlaywrightPlugin['createLaunchContext']>, Page> {
configuration?: Configuration;
headless?: boolean;
launchContext?: PlaywrightLaunchContext;
remoteBrowser?: PlaywrightRemoteBrowserOptions;
}
declare namespace playwrightClickElements {
export {
enqueueLinksByClickingElements,
clickElementsAndInterceptNavigationRequests,
clickElements,
EnqueueLinksByClickingElementsOptions
}
}
// @public (undocumented)
interface PlaywrightContextUtils {
blockRequests(options?: BlockRequestsOptions): Promise<void>;
compileScript(scriptString: string, ctx?: Dictionary): CompiledScriptFunction;
enqueueLinksByClickingElements(options: Omit<EnqueueLinksByClickingElementsOptions, 'page' | 'requestManager'>): Promise<BatchAddRequestsResult>;
handleCloudflareChallenge(options?: HandleCloudflareChallengeOptions): Promise<Response_2 | undefined>;
infiniteScroll(options?: InfiniteScrollOptions): Promise<void>;
injectFile(filePath: string, options?: InjectFileOptions): Promise<unknown>;
injectJQuery(): Promise<unknown>;
listDownloads(): Promise<Download[]>;
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<CheerioAPI>;
querySelectorAll(selector: string, timeoutMs?: number): Promise<Cheerio<AnyNode>>;
querySelectorOne(selector: string, timeoutMs?: number): Promise<Cheerio<AnyNode>>;
saveSnapshot(options?: SaveSnapshotOptions): Promise<void>;
waitForSelector(selector: string, timeoutMs?: number): Promise<void>;
}
// @public
export class PlaywrightCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends PlaywrightCrawlingContext = PlaywrightCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<PlaywrightCrawlingContext['request']>>, StatisticStateExtension extends object = {}> extends BrowserCrawler<Page, Response_2, PlaywrightCrawlingContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension> {
constructor(options?: PlaywrightCrawlerOptions<ContextExtension, ExtendedContext, Routes, StatisticStateExtension>);
// (undocumented)
protected navigationHandler(crawlingContext: PlaywrightCrawlingContext, gotoOptions: PlaywrightDirectNavigationOptions): Promise<Response_2 | null>;
}
// @public (undocumented)
export interface PlaywrightCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends PlaywrightCrawlingContext = PlaywrightCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<PlaywrightCrawlingContext['request']>>, StatisticStateExtension extends object = {}> extends BrowserCrawlerOptions<Page, Response_2, PlaywrightCrawlingContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension> {
headless?: boolean;
launchContext?: PlaywrightLaunchContext;
postNavigationHooks?: BrowserHook<PlaywrightCrawlingContext<GetUserDataFromRequest<ExtendedContext['request']>>, ContextExtension>[];
preNavigationHooks?: BrowserHook<PlaywrightCrawlingContext<GetUserDataFromRequest<ExtendedContext['request']>>, ContextExtension>[];
remoteBrowser?: PlaywrightRemoteBrowserOptions;
}
// @public (undocumented)
export interface PlaywrightCrawlingContext<UserData extends Dictionary = any> extends BrowserCrawlingContext<Page, Response_2, UserData, PlaywrightGotoOptions>, PlaywrightContextUtils {
}
// @public (undocumented)
export interface PlaywrightDirectNavigationOptions {
referer?: string;
timeout?: number;
waitUntil?: 'domcontentloaded' | 'load' | 'networkidle';
}
// @public (undocumented)
export type PlaywrightGotoOptions = NonNullable<Parameters<Page['goto']>[1]>;
// @public (undocumented)
export type PlaywrightHook<UserData extends Dictionary = any> = BrowserHook<PlaywrightCrawlingContext<UserData>>;
// @public
export interface PlaywrightLaunchContext extends BrowserLaunchContext<LaunchOptions, BrowserType> {
launcher?: BrowserType;
launchOptions?: LaunchOptions & Parameters<BrowserType['launchPersistentContext']>[1];
proxyUrl?: string;
useChrome?: boolean;
useIncognitoPages?: boolean;
userDataDir?: string;
}
// @public
export interface PlaywrightRemoteBrowserOptions extends CrawlerRemoteBrowserOptions {
protocol?: 'cdp' | 'playwright';
}
declare namespace playwrightUtils {
export {
injectFile,
injectJQuery,
gotoExtended,
blockRequests,
compileScript,
infiniteScroll,
saveSnapshot,
parseWithCheerio,
handleCloudflareChallenge,
InjectFileOptions,
BlockRequestsOptions,
PlaywrightDirectNavigationOptions as DirectNavigationOptions,
CompiledScriptParams,
CompiledScriptFunction,
InfiniteScrollOptions,
SaveSnapshotOptions,
HandleCloudflareChallengeOptions,
PlaywrightContextUtils,
enqueueLinksByClickingElements
}
}
// @public (undocumented)
export type RenderingType = 'clientOnly' | 'static';
// @public
export class RenderingTypePredictor implements IRenderingTypePredictor {
// (undocumented)
[Symbol.asyncDispose](): Promise<void>;
constructor(input: RenderingTypePredictorOptions);
initialize(): Promise<void>;
predict(input: Request_2): {
renderingType: RenderingType;
detectionProbabilityRecommendation: number;
};
storeResult(requests: Request_2 | Request_2[], renderingType: RenderingType): void;
teardown(): Promise<void>;
}
// Not exported by the entry point; reachable only as a referenced type.
// @public (undocumented)
interface RenderingTypePredictorOptions {
detectionRatio: number;
// (undocumented)
persistenceOptions?: Partial<RecoverableStatePersistenceOptions>;
}
// @public
function saveSnapshot(page: Page, options?: SaveSnapshotOptions): Promise<void>;
// @public (undocumented)
interface SaveSnapshotOptions {
configuration?: Configuration;
key?: string;
keyValueStoreName?: string | null;
saveHtml?: boolean;
saveScreenshot?: boolean;
screenshotQuality?: number;
}
export * from "@crawlee/browser";
// (No @packageDocumentation comment for this package)