@crawlee/playwright 4.0.0-beta.12 → 4.0.0-beta.121

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (31) hide show
  1. package/README.md +17 -13
  2. package/index.d.ts +1 -2
  3. package/index.js +0 -1
  4. package/internals/adaptive-playwright-crawler.d.ts +114 -50
  5. package/internals/adaptive-playwright-crawler.js +316 -235
  6. package/internals/enqueue-links/click-elements.d.ts +37 -55
  7. package/internals/enqueue-links/click-elements.js +51 -43
  8. package/internals/playwright-crawler.d.ts +105 -55
  9. package/internals/playwright-crawler.js +48 -42
  10. package/internals/playwright-launcher.d.ts +6 -5
  11. package/internals/playwright-launcher.js +10 -11
  12. package/internals/utils/playwright-utils.d.ts +61 -24
  13. package/internals/utils/playwright-utils.js +100 -53
  14. package/internals/utils/rendering-type-prediction.d.ts +28 -13
  15. package/internals/utils/rendering-type-prediction.js +87 -29
  16. package/package.json +18 -13
  17. package/index.d.ts.map +0 -1
  18. package/index.js.map +0 -1
  19. package/internals/adaptive-playwright-crawler.d.ts.map +0 -1
  20. package/internals/adaptive-playwright-crawler.js.map +0 -1
  21. package/internals/enqueue-links/click-elements.d.ts.map +0 -1
  22. package/internals/enqueue-links/click-elements.js.map +0 -1
  23. package/internals/playwright-crawler.d.ts.map +0 -1
  24. package/internals/playwright-crawler.js.map +0 -1
  25. package/internals/playwright-launcher.d.ts.map +0 -1
  26. package/internals/playwright-launcher.js.map +0 -1
  27. package/internals/utils/playwright-utils.d.ts.map +0 -1
  28. package/internals/utils/playwright-utils.js.map +0 -1
  29. package/internals/utils/rendering-type-prediction.d.ts.map +0 -1
  30. package/internals/utils/rendering-type-prediction.js.map +0 -1
  31. package/tsconfig.build.tsbuildinfo +0 -1
package/README.md CHANGED
@@ -1,19 +1,23 @@
1
1
  <h1 align="center">
2
2
  <a href="https://crawlee.dev">
3
3
  <picture>
4
- <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-dark.svg?sanitize=true">
5
- <img alt="Crawlee" src="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-light.svg?sanitize=true" width="500">
4
+ <source media="(prefers-color-scheme: dark)" srcset="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-dark.svg?sanitize=true" />
5
+ <img alt="Crawlee" src="https://raw.githubusercontent.com/apify/crawlee/master/website/static/img/crawlee-light.svg?sanitize=true" width="500" />
6
6
  </picture>
7
7
  </a>
8
- <br>
8
+ <br />
9
9
  <small>A web scraping and browser automation library</small>
10
10
  </h1>
11
11
 
12
- <p align=center>
13
- <a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg" style="max-width: 100%;"></a>
14
- <a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg" style="max-width: 100%;"></a>
15
- <a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord" style="max-width: 100%;"></a>
16
- <a href="https://github.com/apify/crawlee/actions/workflows/test-ci.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-ci.yml/badge.svg?branch=master" alt="Build Status" style="max-width: 100%;"></a>
12
+ <p align="center">
13
+ <a href="https://trendshift.io/repositories/5179" target="_blank"><img src="https://trendshift.io/api/badge/repositories/5179" alt="apify%2Fcrawlee | Trendshift" width="250" height="55"/></a>
14
+ </p>
15
+
16
+ <p align="center">
17
+ <a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/v/@crawlee/core.svg" alt="NPM latest version" data-canonical-src="https://img.shields.io/npm/v/@crawlee/core/next.svg" /></a>
18
+ <a href="https://www.npmjs.com/package/@crawlee/core" rel="nofollow"><img src="https://img.shields.io/npm/dm/@crawlee/core.svg" alt="Downloads" data-canonical-src="https://img.shields.io/npm/dm/@crawlee/core.svg" /></a>
19
+ <a href="https://discord.gg/jyEM2PRvMU" rel="nofollow"><img src="https://img.shields.io/discord/801163717915574323?label=discord" alt="Chat on discord" data-canonical-src="https://img.shields.io/discord/801163717915574323?label=discord" /></a>
20
+ <a href="https://github.com/apify/crawlee/actions/workflows/test-ci.yml"><img src="https://github.com/apify/crawlee/actions/workflows/test-ci.yml/badge.svg?branch=master" alt="Build Status" /></a>
17
21
  </p>
18
22
 
19
23
  Crawlee covers your crawling and scraping end-to-end and **helps you build reliable scrapers. Fast.**
@@ -24,7 +28,7 @@ Crawlee is available as the [`crawlee`](https://www.npmjs.com/package/crawlee) N
24
28
 
25
29
  > 👉 **View full documentation, guides and examples on the [Crawlee project website](https://crawlee.dev)** 👈
26
30
 
27
- > Crawlee for Python is open for early adopters. 🐍 [👉 Checkout the source code 👈](https://github.com/apify/crawlee-python).
31
+ > Do you prefer 🐍 Python instead of JavaScript? [👉 Checkout Crawlee for Python 👈](https://github.com/apify/crawlee-python).
28
32
 
29
33
  ## Installation
30
34
 
@@ -85,7 +89,7 @@ By default, Crawlee stores data to `./storage` in the current working directory.
85
89
  We provide automated beta builds for every merged code change in Crawlee. You can find them in the npm [list of releases](https://www.npmjs.com/package/crawlee?activeTab=versions). If you want to test new features or bug fixes before we release them, feel free to install a beta build like this:
86
90
 
87
91
  ```bash
88
- npm install crawlee@3.12.3-beta.13
92
+ npm install crawlee@next
89
93
  ```
90
94
 
91
95
  If you also use the [Apify SDK](https://github.com/apify/apify-sdk-js), you need to specify dependency overrides in your `package.json` file so that you don't end up with multiple versions of Crawlee installed:
@@ -94,9 +98,9 @@ If you also use the [Apify SDK](https://github.com/apify/apify-sdk-js), you need
94
98
  {
95
99
  "overrides": {
96
100
  "apify": {
97
- "@crawlee/core": "3.12.3-beta.13",
98
- "@crawlee/types": "3.12.3-beta.13",
99
- "@crawlee/utils": "3.12.3-beta.13"
101
+ "@crawlee/core": "$crawlee",
102
+ "@crawlee/types": "$crawlee",
103
+ "@crawlee/utils": "$crawlee"
100
104
  }
101
105
  }
102
106
  }
package/index.d.ts CHANGED
@@ -6,5 +6,4 @@ export { RenderingTypePredictor } from './internals/utils/rendering-type-predict
6
6
  export * as playwrightUtils from './internals/utils/playwright-utils.js';
7
7
  export * as playwrightClickElements from './internals/enqueue-links/click-elements.js';
8
8
  export type { DirectNavigationOptions as PlaywrightDirectNavigationOptions } from './internals/utils/playwright-utils.js';
9
- export type { RenderingType } from './internals/utils/rendering-type-prediction.js';
10
- //# sourceMappingURL=index.d.ts.map
9
+ export type { IRenderingTypePredictor, RenderingType } from './internals/utils/rendering-type-prediction.js';
package/index.js CHANGED
@@ -5,4 +5,3 @@ export * from './internals/adaptive-playwright-crawler.js';
5
5
  export { RenderingTypePredictor } from './internals/utils/rendering-type-prediction.js';
6
6
  export * as playwrightUtils from './internals/utils/playwright-utils.js';
7
7
  export * as playwrightClickElements from './internals/enqueue-links/click-elements.js';
8
- //# sourceMappingURL=index.js.map
@@ -1,44 +1,54 @@
1
+ import type { BrowserHook, LoadedRequest, Request, RouterHandler, RouteSchemas, RoutesFromSchemas } from '@crawlee/browser';
2
+ import type { BasicCrawlerOptions } from '@crawlee/basic';
1
3
  import { BasicCrawler } from '@crawlee/basic';
2
- import type { BasicCrawlerOptions, BrowserHook, LoadedRequest, Request } from '@crawlee/browser';
3
- import type { BaseHttpResponseData, CrawlingContext, EnqueueLinksOptions, GetUserDataFromRequest, RouterRoutes, StatisticsOptions, StatisticState } from '@crawlee/core';
4
- import { Configuration, RequestHandlerResult, Statistics } from '@crawlee/core';
5
- import type { Dictionary } from '@crawlee/types';
6
- import { type CheerioRoot } from '@crawlee/utils';
4
+ import type { ContextPipeline, CrawlingContext, EnqueueLinksOptions, GetUserDataFromRequest, RouterRoutes, StatisticPersistedState, StatisticState, StorageTransactionView } from '@crawlee/core';
5
+ import { Statistics } from '@crawlee/core';
6
+ import type { Dictionary, Awaitable } from '@crawlee/types';
7
+ import { type CheerioRoot } from '@crawlee/utils/internal';
7
8
  import { type Cheerio } from 'cheerio';
8
9
  import type { AnyNode } from 'domhandler';
9
10
  // @ts-ignore optional peer dependency or compatibility with es2022
10
11
  import type { Page } from 'playwright';
11
12
  import type { PlaywrightCrawlingContext, PlaywrightGotoOptions } from './playwright-crawler.js';
12
- import { RenderingTypePredictor } from './utils/rendering-type-prediction.js';
13
+ import { type IRenderingTypePredictor } from './utils/rendering-type-prediction.js';
13
14
  interface AdaptivePlaywrightCrawlerStatisticState extends StatisticState {
14
15
  httpOnlyRequestHandlerRuns?: number;
15
16
  browserRequestHandlerRuns?: number;
16
17
  renderingTypeMispredictions?: number;
17
18
  }
19
+ interface AdaptivePlaywrightCrawlerPersistedStatisticState extends StatisticPersistedState {
20
+ httpOnlyRequestHandlerRuns?: number;
21
+ browserRequestHandlerRuns?: number;
22
+ renderingTypeMispredictions?: number;
23
+ }
18
24
  declare class AdaptivePlaywrightCrawlerStatistics extends Statistics {
19
- state: AdaptivePlaywrightCrawlerStatisticState;
20
- constructor(options?: StatisticsOptions);
21
- reset(): void;
22
- protected _maybeLoadStatistics(): Promise<void>;
25
+ get state(): AdaptivePlaywrightCrawlerStatisticState;
26
+ protected defaultState(): AdaptivePlaywrightCrawlerStatisticState;
27
+ protected deserializeState(persistedState: AdaptivePlaywrightCrawlerPersistedStatisticState): AdaptivePlaywrightCrawlerStatisticState;
23
28
  trackHttpOnlyRequestHandlerRun(): void;
24
29
  trackBrowserRequestHandlerRun(): void;
25
30
  trackRenderingTypeMisprediction(): void;
26
31
  }
27
- export interface AdaptivePlaywrightCrawlerContext<UserData extends Dictionary = Dictionary> extends CrawlingContext<UserData> {
32
+ export interface AdaptivePlaywrightCrawlerContext<UserData extends Dictionary = any> extends CrawlingContext<UserData> {
28
33
  request: LoadedRequest<Request<UserData>>;
29
34
  /**
30
35
  * The HTTP response, either from the HTTP client or from the initial request from playwright's navigation.
31
36
  */
32
- response: BaseHttpResponseData;
37
+ response: Response;
33
38
  /**
34
39
  * Playwright Page object. If accessed in HTTP-only rendering, this will throw an error and make the AdaptivePlaywrightCrawlerContext retry the request in a browser.
35
40
  */
36
41
  page: Page;
37
42
  /**
38
- * Wait for an element matching the selector to appear and return a Cheerio object of matched elements.
43
+ * Wait for an element matching the selector to appear and return a Cheerio object of the first matched element.
39
44
  * Timeout defaults to 5s.
40
45
  */
41
46
  querySelector(selector: string, timeoutMs?: number): Promise<Cheerio<AnyNode>>;
47
+ /**
48
+ * Wait for an element matching the selector to appear and return a Cheerio object of all matched elements.
49
+ * Timeout defaults to 5s.
50
+ */
51
+ querySelectorAll(selector: string, timeoutMs?: number): Promise<Cheerio<AnyNode>>;
42
52
  /**
43
53
  * Wait for an element matching the selector to appear.
44
54
  * Timeout defaults to 5s.
@@ -66,53 +76,77 @@ export interface AdaptivePlaywrightCrawlerContext<UserData extends Dictionary =
66
76
  * ```
67
77
  */
68
78
  parseWithCheerio(selector?: string, timeoutMs?: number): Promise<CheerioRoot>;
69
- enqueueLinks(options?: EnqueueLinksOptions): Promise<void>;
79
+ enqueueLinks(options?: EnqueueLinksOptions): Promise<unknown>;
70
80
  }
71
- interface AdaptiveHook extends BrowserHook<Pick<AdaptivePlaywrightCrawlerContext, 'id' | 'session' | 'proxyInfo' | 'log'> & {
81
+ interface AdaptiveHookContext extends Pick<AdaptivePlaywrightCrawlerContext, 'id' | 'session' | 'proxyInfo' | 'log'> {
72
82
  page?: Page;
73
83
  request: Request;
74
- }, PlaywrightGotoOptions> {
84
+ gotoOptions?: PlaywrightGotoOptions;
75
85
  }
76
- export interface AdaptivePlaywrightCrawlerOptions<ExtendedContext extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext> extends Omit<BasicCrawlerOptions<AdaptivePlaywrightCrawlerContext, ExtendedContext>, 'preNavigationHooks' | 'postNavigationHooks'> {
86
+ type AdaptiveHook<ContextExtension = Dictionary<never>> = BrowserHook<AdaptiveHookContext, ContextExtension>;
87
+ type AdaptivePostNavigationHook<ContextExtension = Dictionary<never>> = BrowserHook<Omit<AdaptiveHookContext, 'request'> & {
88
+ request: LoadedRequest<Request>;
89
+ }, ContextExtension>;
90
+ export interface AdaptivePlaywrightCrawlerOptions<ContextExtension = Dictionary<never>, ExtendedContext extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<AdaptivePlaywrightCrawlerContext['request']>>> extends Omit<BasicCrawlerOptions<AdaptivePlaywrightCrawlerContext, ContextExtension, ExtendedContext, Routes>, 'preNavigationHooks' | 'postNavigationHooks'> {
77
91
  /**
78
92
  * Async functions that are sequentially evaluated before the navigation. Good for setting additional cookies.
79
93
  * The function accepts a subset of the crawling context. If you attempt to access the `page` property during HTTP-only crawling,
80
94
  * an exception will be thrown. If it's not caught, the request will be transparently retried in a browser.
95
+ *
96
+ * A hook may optionally return a partial object whose properties are merged into the crawling context,
97
+ * allowing the hook to override context members for subsequent hooks and pipeline stages.
81
98
  */
82
- preNavigationHooks?: AdaptiveHook[];
99
+ preNavigationHooks?: AdaptiveHook<ContextExtension>[];
83
100
  /**
84
101
  * Async functions that are sequentially evaluated after the navigation. Good for checking if the navigation was successful.
85
102
  * The function accepts a subset of the crawling context. If you attempt to access the `page` property during HTTP-only crawling,
86
103
  * an exception will be thrown. If it's not caught, the request will be transparently retried in a browser.
104
+ *
105
+ * A hook may optionally return a partial object whose properties are merged into the crawling context
106
+ * (e.g. to override `response` after solving a challenge).
87
107
  */
88
- postNavigationHooks?: AdaptiveHook[];
108
+ postNavigationHooks?: AdaptivePostNavigationHook<ContextExtension>[];
89
109
  /**
90
110
  * Specifies the frequency of rendering type detection checks - 0.1 means roughly 10% of requests.
91
111
  * Defaults to 0.1 (so 10%).
92
112
  */
93
113
  renderingTypeDetectionRatio?: number;
94
114
  /**
95
- * An optional callback that is called on dataset items found by the request handler in plain HTTP mode.
115
+ * An optional callback that is called on the storage writes recorded by the request handler in plain
116
+ * HTTP mode (exposed as a read-only {@link StorageTransactionView}).
96
117
  * If it returns false, the request is retried in a browser.
97
- * If no callback is specified, every dataset item is considered valid.
118
+ * If no callback is specified, every result is considered valid.
98
119
  */
99
- resultChecker?: (result: RequestHandlerResult) => boolean;
120
+ resultChecker?: (result: StorageTransactionView) => boolean;
121
+ /**
122
+ * An optional callback that decides whether an error thrown during the plain HTTP request handler
123
+ * should be propagated (instead of falling back to browser navigation).
124
+ *
125
+ * If the callback returns `true`, the error is thrown, triggering the standard retry mechanism.
126
+ * If the callback returns `false` (or is not provided), the error is logged and the crawler
127
+ * falls back to browser navigation (default behavior).
128
+ *
129
+ * @default () => false
130
+ */
131
+ shouldPropagateError?: (error: Error, context: PlaywrightCrawlingContext) => Awaitable<boolean>;
100
132
  /**
101
133
  * An optional callback used in rendering type detection. On each detection, the result of the plain HTTP run is compared to that of the browser one.
102
- * If the callback returns true, the results are considered equal and the target site is considered static.
134
+ * If a callback is provided, the contract is as follows:
135
+ * It the callback returns true or 'equal', the results are considered equal and the target site is considered static.
136
+ * If it returns false or 'different', the target site is considered client-rendered.
137
+ * If it returns 'inconclusive', the detection result won't be used.
103
138
  * If no result comparator is specified, but there is a `resultChecker`, any site where the `resultChecker` returns true is considered static.
104
139
  * If neither `resultComparator` nor `resultChecker` are specified, a deep comparison of returned dataset items is used as a default.
140
+ *
141
+ * For a stricter, ready-made comparator that also takes enqueued requests and key-value store changes into account, see {@link fullResultComparator}.
105
142
  */
106
- resultComparator?: (resultA: RequestHandlerResult, resultB: RequestHandlerResult) => boolean;
107
- /**
108
- * A custom rendering type predictor
109
- */
110
- renderingTypePredictor?: Pick<RenderingTypePredictor, 'predict' | 'storeResult'>;
143
+ resultComparator?: (resultA: StorageTransactionView, resultB: StorageTransactionView) => boolean | 'equal' | 'different' | 'inconclusive';
111
144
  /**
112
- * Prevent direct access to storage in request handlers (only allow using context helpers).
113
- * Defaults to `true`
145
+ * A custom rendering type predictor. A predictor passed here is borrowed - the crawler never drives its
146
+ * lifecycle, so set it up yourself (the built-in {@link RenderingTypePredictor} needs `initialize()`).
147
+ * Omit the option and the crawler builds its own from `renderingTypeDetectionRatio` - and initializes it.
114
148
  */
115
- preventDirectStorageAccess?: boolean;
149
+ renderingTypePredictor?: IRenderingTypePredictor;
116
150
  }
117
151
  /**
118
152
  * An extension of {@link PlaywrightCrawler} that uses a more limited request handler interface so that it is able to switch to HTTP-only crawling when it detects it may be possible.
@@ -143,29 +177,59 @@ export interface AdaptivePlaywrightCrawlerOptions<ExtendedContext extends Adapti
143
177
  *
144
178
  * @experimental
145
179
  */
146
- export declare class AdaptivePlaywrightCrawler<ExtendedContext extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext> extends BasicCrawler<AdaptivePlaywrightCrawlerContext, ExtendedContext> {
147
- readonly config: Configuration;
148
- private renderingTypePredictor;
149
- private resultChecker;
150
- private resultComparator;
151
- private preventDirectStorageAccess;
152
- private staticContextPipeline;
153
- private browserContextPipeline;
154
- private individualRequestHandlerTimeoutMillis;
155
- readonly stats: AdaptivePlaywrightCrawlerStatistics;
156
- private resultObjects;
157
- private teardownHooks;
158
- constructor(options?: AdaptivePlaywrightCrawlerOptions<ExtendedContext>, config?: Configuration);
180
+ export declare class AdaptivePlaywrightCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<AdaptivePlaywrightCrawlerContext['request']>>> extends BasicCrawler<AdaptivePlaywrightCrawlerContext, ContextExtension, ExtendedContext, Routes> {
181
+ #private;
182
+ get stats(): AdaptivePlaywrightCrawlerStatistics;
183
+ constructor(options?: AdaptivePlaywrightCrawlerOptions<ContextExtension, ExtendedContext, Routes>);
184
+ protected init(): Promise<void>;
185
+ protected buildContextPipeline(): ContextPipeline<CrawlingContext<Dictionary>, CrawlingContext<Dictionary> & {
186
+ readonly request: LoadedRequest<Request<Dictionary>>;
187
+ readonly response: Response;
188
+ readonly page: Page;
189
+ readonly querySelector: AdaptivePlaywrightCrawlerContext["querySelector"];
190
+ readonly querySelectorAll: AdaptivePlaywrightCrawlerContext["querySelectorAll"];
191
+ readonly waitForSelector: AdaptivePlaywrightCrawlerContext["waitForSelector"];
192
+ readonly parseWithCheerio: AdaptivePlaywrightCrawlerContext["parseWithCheerio"];
193
+ }>;
159
194
  private adaptCheerioContext;
160
195
  private adaptPlaywrightContext;
196
+ /**
197
+ * Runs one request handler attempt inside its own {@link StorageTransaction}, wrapping the inner
198
+ * (static or browser) context pipeline. The transaction is pushed to `transactions` *at creation
199
+ * time, before the `try`* - the `ok: false` branch of the returned {@link Result} carries no
200
+ * result, and failed attempts are routine here. The caller owns the outcome and disposal.
201
+ */
161
202
  private crawlOne;
162
- protected runRequestHandler(crawlingContext: PlaywrightCrawlingContext): Promise<void>;
163
- protected commitResult(crawlingContext: PlaywrightCrawlingContext, { calls, keyValueStoreChanges }: RequestHandlerResult): Promise<void>;
164
- protected allowStorageAccess<R, TArgs extends any[]>(func: (...args: TArgs) => Promise<R>): (...args: TArgs) => Promise<R>;
203
+ protected runRequestHandler(crawlingContext: CrawlingContext): Promise<void>;
204
+ private enqueueLinks;
165
205
  private createLogProxy;
166
206
  teardown(): Promise<void>;
167
207
  }
168
- // @ts-ignore optional peer dependency or compatibility with es2022
169
- export declare function createAdaptivePlaywrightRouter<Context extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, UserData>): import("@crawlee/basic").RouterHandler<Context>;
208
+ export declare function createAdaptivePlaywrightRouter<Context extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<Context['request']>>>(routes?: RouterRoutes<Context, Routes>): RouterHandler<Context, Routes>;
209
+ export declare function createAdaptivePlaywrightRouter<Context extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext, UserData extends Dictionary = GetUserDataFromRequest<Context['request']>>(routes?: RouterRoutes<Context, Record<string, UserData>>): RouterHandler<Context, Record<string, UserData>>;
210
+ export declare function createAdaptivePlaywrightRouter<Context extends AdaptivePlaywrightCrawlerContext = AdaptivePlaywrightCrawlerContext, const Schemas extends RouteSchemas = RouteSchemas>(schemas: Schemas): RouterHandler<Context, RoutesFromSchemas<Schemas>>;
211
+ /**
212
+ * An opt-in {@link AdaptivePlaywrightCrawlerOptions.resultComparator|`resultComparator`} that considers two
213
+ * request handler results equal only if *all* of their observable effects match - the pushed dataset items, the
214
+ * enqueued requests, and the key-value store changes. This is stricter than the default comparator, which only
215
+ * compares dataset items.
216
+ *
217
+ * **Beware:** enqueued URLs are compared exactly. The same page rendered in a browser and via plain HTTP often
218
+ * yields links that differ only in tracking query parameters, for example:
219
+ * - `https://sdk.apify.com/docs/guides/getting-started`
220
+ * - `https://sdk.apify.com/docs/guides/getting-started?__hsfp=1136113150&__hssc=7591405.1.173549427712`
221
+ *
222
+ * Such links are treated as *different*, which will make the crawler favor browser rendering for those pages.
223
+ *
224
+ * **Example usage:**
225
+ * ```ts
226
+ * const crawler = new AdaptivePlaywrightCrawler({
227
+ * resultComparator: fullResultComparator,
228
+ * async requestHandler({ pushData, enqueueLinks }) {
229
+ * // ...
230
+ * },
231
+ * });
232
+ * ```
233
+ */
234
+ export declare function fullResultComparator(resultA: StorageTransactionView, resultB: StorageTransactionView): boolean;
170
235
  export {};
171
- //# sourceMappingURL=adaptive-playwright-crawler.d.ts.map