@crawlee/browser 4.0.0-beta.8 → 4.0.0-beta.81

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.
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
@@ -1,4 +1,3 @@
1
1
  export * from '@crawlee/basic';
2
2
  export * from './internals/browser-crawler.js';
3
3
  export * from './internals/browser-launcher.js';
4
- //# sourceMappingURL=index.d.ts.map
package/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from '@crawlee/basic';
2
2
  export * from './internals/browser-crawler.js';
3
3
  export * from './internals/browser-launcher.js';
4
- //# sourceMappingURL=index.js.map
@@ -1,20 +1,57 @@
1
- import type { Awaitable, BasicCrawlerOptions, CrawlingContext, Dictionary, EnqueueLinksOptions, ErrorHandler, ProxyConfiguration, RequestHandler, RequestProvider, SkippedRequestCallback } from '@crawlee/basic';
2
- import { BasicCrawler, Configuration } from '@crawlee/basic';
3
- import type { BrowserController, BrowserPlugin, BrowserPoolHooks, BrowserPoolOptions, CommonPage, InferBrowserPluginArray, LaunchContext } from '@crawlee/browser-pool';
4
- import { BrowserPool } from '@crawlee/browser-pool';
1
+ import type { Awaitable, BasicCrawlerOptions, BasicCrawlingContext, CrawlingContext, Dictionary, EnqueueLinksOptions, ErrorHandler, IRequestManager, LoadedRequest, Request, RequestHandler, SkippedRequestCallback } from '@crawlee/basic';
2
+ import { BasicCrawler, ContextPipeline } from '@crawlee/basic';
3
+ import type { BrowserController, BrowserPlugin, BrowserPoolHooks, BrowserPoolOptions, CommonPage, CrawlerRemoteBrowserOptions, InferBrowserPluginArray, LaunchContext } from '@crawlee/browser-pool';
4
+ import type { BatchAddRequestsResult, IBrowserPool } from '@crawlee/types';
5
5
  import type { RobotsTxtFile } from '@crawlee/utils';
6
6
  import type { ReadonlyDeep } from 'type-fest';
7
7
  import type { BrowserLaunchContext } from './browser-launcher.js';
8
- export interface BrowserCrawlingContext<Crawler = unknown, Page extends CommonPage = CommonPage, Response = Dictionary, ProvidedController = BrowserController, UserData extends Dictionary = Dictionary> extends CrawlingContext<Crawler, UserData> {
9
- browserController: ProvidedController;
8
+ interface BaseResponse {
9
+ status(): number;
10
+ }
11
+ export interface BrowserCrawlingContext<Page extends CommonPage = CommonPage, Response extends BaseResponse = BaseResponse, UserData extends Dictionary = Dictionary, GoToOptions extends Dictionary = Dictionary> extends CrawlingContext<UserData> {
12
+ /**
13
+ * The browser page object where the web page is loaded and rendered.
14
+ */
10
15
  page: Page;
11
- response?: Response;
16
+ /**
17
+ * The request object that was successfully loaded and navigated to, including the {@link Request.loadedUrl|`loadedUrl`} property.
18
+ */
19
+ request: LoadedRequest<Request<UserData>>;
20
+ /**
21
+ * The HTTP response object returned by the browser's navigation.
22
+ */
23
+ response: Response;
24
+ /**
25
+ * Options object passed to the underlying `page.goto()` call. `preNavigationHooks` can mutate this
26
+ * object (or return `{ gotoOptions: ... }`) to influence the navigation.
27
+ */
28
+ gotoOptions: GoToOptions;
29
+ /**
30
+ * Helper function for extracting URLs from the current page and adding them to the request queue.
31
+ */
32
+ enqueueLinks: (options?: EnqueueLinksOptions) => Promise<BatchAddRequestsResult>;
12
33
  }
13
- export type BrowserRequestHandler<Context extends BrowserCrawlingContext = BrowserCrawlingContext> = RequestHandler<Context>;
14
- export type BrowserErrorHandler<Context extends BrowserCrawlingContext = BrowserCrawlingContext> = ErrorHandler<Context>;
15
- export type BrowserHook<Context = BrowserCrawlingContext, GoToOptions extends Dictionary | undefined = Dictionary> = (crawlingContext: Context, gotoOptions: GoToOptions) => Awaitable<void>;
16
- export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext = BrowserCrawlingContext, InternalBrowserPoolOptions extends BrowserPoolOptions = BrowserPoolOptions, __BrowserPlugins extends BrowserPlugin[] = InferBrowserPluginArray<InternalBrowserPoolOptions['browserPlugins']>, __BrowserControllerReturn extends BrowserController = ReturnType<__BrowserPlugins[number]['createController']>, __LaunchContextReturn extends LaunchContext = ReturnType<__BrowserPlugins[number]['createLaunchContext']>> extends Omit<BasicCrawlerOptions, 'requestHandler' | 'failedRequestHandler' | 'errorHandler'> {
34
+ export type BrowserHook<Context = BrowserCrawlingContext> = (crawlingContext: Context) => Awaitable<void | Partial<Context>>;
35
+ export interface BrowserCrawlerOptions<Page extends CommonPage = CommonPage, Response extends BaseResponse = BaseResponse, Context extends BrowserCrawlingContext<Page, Response, Dictionary> = BrowserCrawlingContext<Page, Response, Dictionary>, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension, InternalBrowserPoolOptions extends BrowserPoolOptions = BrowserPoolOptions, __BrowserPlugins extends BrowserPlugin[] = InferBrowserPluginArray<InternalBrowserPoolOptions['browserPlugins']>, __BrowserControllerReturn extends BrowserController = ReturnType<__BrowserPlugins[number]['createController']>, __LaunchContextReturn extends LaunchContext = ReturnType<__BrowserPlugins[number]['createLaunchContext']>> extends Omit<BasicCrawlerOptions<Context, ExtendedContext>, 'requestHandler' | 'failedRequestHandler' | 'errorHandler'> {
17
36
  launchContext?: BrowserLaunchContext<any, any>;
37
+ /**
38
+ * An existing browser pool instance to use. When provided, the crawler will use this pool directly instead of
39
+ * constructing a new one from `browserPoolOptions`, enabling browser sharing across multiple crawlers. The crawler
40
+ * will not tear down a shared pool — the caller is responsible for its lifecycle.
41
+ */
42
+ browserPool?: IBrowserPool<Page>;
43
+ /**
44
+ * Connect to a remote browser service (Browserbase, Browserless, Steel, …) instead of launching locally.
45
+ *
46
+ * The crawler builds a {@link RemoteBrowserPool} around its own browser plugin, so the connection is
47
+ * always for the right browser — there is no plugin to construct and no way to mismatch the pool with the
48
+ * crawler. Supply the connection details only: a static `endpoint` URL, a function returning one per launch,
49
+ * or a {@link RemoteBrowserProvider}.
50
+ *
51
+ * Ignored when `browserPool` is set. For sharing a remote pool across crawlers, construct a
52
+ * {@link RemoteBrowserPool} yourself and pass it as `browserPool` instead.
53
+ */
54
+ remoteBrowser?: CrawlerRemoteBrowserOptions;
18
55
  /**
19
56
  * Function that is called to process each request.
20
57
  *
@@ -25,7 +62,6 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
25
62
  * - {@link BrowserCrawlingContext.page|`page`} is an instance of the
26
63
  * Puppeteer [Page](https://pptr.dev/api/puppeteer.page) or
27
64
  * Playwright [Page](https://playwright.dev/docs/api/class-page);
28
- * - {@link BrowserCrawlingContext.browserController|`browserController`} is an instance of the {@link BrowserController};
29
65
  * - {@link BrowserCrawlingContext.response|`response`} is an instance of the
30
66
  * Puppeteer [Response](https://pptr.dev/api/puppeteer.httpresponse) or
31
67
  * Playwright [Response](https://playwright.dev/docs/api/class-response),
@@ -42,7 +78,7 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
42
78
  * The exceptions are logged to the request using the
43
79
  * {@link Request.pushErrorMessage|`Request.pushErrorMessage()`} function.
44
80
  */
45
- requestHandler?: BrowserRequestHandler<Context>;
81
+ requestHandler?: RequestHandler<ExtendedContext>;
46
82
  /**
47
83
  * User-provided function that allows modifying the request object before it gets retried by the crawler.
48
84
  * It's executed before each retry for the requests that failed less than {@link BrowserCrawlerOptions.maxRequestRetries|`maxRequestRetries`} times.
@@ -53,7 +89,7 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
53
89
  * Second argument is the `Error` instance that
54
90
  * represents the last error thrown during processing of the request.
55
91
  */
56
- errorHandler?: BrowserErrorHandler<Context>;
92
+ errorHandler?: ErrorHandler<CrawlingContext, ExtendedContext>;
57
93
  /**
58
94
  * A function to handle requests that failed more than `option.maxRequestRetries` times.
59
95
  *
@@ -63,28 +99,22 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
63
99
  * Second argument is the `Error` instance that
64
100
  * represents the last error thrown during processing of the request.
65
101
  */
66
- failedRequestHandler?: BrowserErrorHandler<Context>;
102
+ failedRequestHandler?: ErrorHandler<CrawlingContext, ExtendedContext>;
67
103
  /**
68
104
  * Custom options passed to the underlying {@link BrowserPool} constructor.
69
105
  * We can tweak those to fine-tune browser management.
70
106
  */
71
107
  browserPoolOptions?: Partial<BrowserPoolOptions> & Partial<BrowserPoolHooks<__BrowserControllerReturn, __LaunchContextReturn>>;
72
- /**
73
- * If set, the crawler will be configured for all connections to use
74
- * the Proxy URLs provided and rotated according to the configuration.
75
- */
76
- proxyConfiguration?: ProxyConfiguration;
77
108
  /**
78
109
  * Async functions that are sequentially evaluated before the navigation. Good for setting additional cookies
79
- * or browser properties before navigation. The function accepts two parameters, `crawlingContext` and `gotoOptions`,
80
- * which are passed to the `page.goto()` function the crawler calls to navigate.
110
+ * or browser properties before navigation. The function receives the `crawlingContext`; the options object
111
+ * forwarded to `page.goto()` is available as `crawlingContext.gotoOptions` and can be mutated in place.
81
112
  *
82
113
  * **Example:**
83
114
  *
84
115
  * ```js
85
116
  * preNavigationHooks: [
86
- * async (crawlingContext, gotoOptions) => {
87
- * const { page } = crawlingContext;
117
+ * async ({ page, gotoOptions }) => {
88
118
  * await page.evaluate((attr) => { window.foo = attr; }, 'bar');
89
119
  * gotoOptions.timeout = 60_000;
90
120
  * gotoOptions.waitUntil = 'domcontentloaded';
@@ -92,14 +122,17 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
92
122
  * ]
93
123
  * ```
94
124
  *
95
- * Modyfing `pageOptions` is supported only in Playwright incognito.
96
- * See {@link PrePageCreateHook}
125
+ * A hook may optionally return a partial object whose properties are merged into the crawling context,
126
+ * allowing the hook to override context members for subsequent hooks and pipeline stages.
97
127
  */
98
128
  preNavigationHooks?: BrowserHook<Context>[];
99
129
  /**
100
130
  * Async functions that are sequentially evaluated after the navigation. Good for checking if the navigation was successful.
101
131
  * The function accepts `crawlingContext` as the only parameter.
102
132
  *
133
+ * A hook may optionally return a partial object whose properties are merged into the crawling context.
134
+ * This is useful for overriding context members (e.g. `response`) after solving a challenge.
135
+ *
103
136
  * **Example:**
104
137
  *
105
138
  * ```js
@@ -110,6 +143,11 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
110
143
  * await solveCaptcha(page);
111
144
  * }
112
145
  * },
146
+ * async (crawlingContext) => {
147
+ * if (await needsRevalidation(crawlingContext)) {
148
+ * return { response: await crawlingContext.page.reload() };
149
+ * }
150
+ * },
113
151
  * ]
114
152
  * ```
115
153
  */
@@ -119,10 +157,9 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
119
157
  */
120
158
  navigationTimeoutSecs?: number;
121
159
  /**
122
- * Defines whether the cookies should be persisted for sessions.
123
- * This can only be used when `useSessionPool` is set to `true`.
160
+ * Defines whether the cookies should be persisted for sessions. Enabled by default.
124
161
  */
125
- persistCookiesPerSession?: boolean;
162
+ saveResponseCookies?: boolean;
126
163
  /**
127
164
  * Whether to run browser in headless mode. Defaults to `true`.
128
165
  * Can be also set via {@link Configuration}.
@@ -151,15 +188,18 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
151
188
  * If the target website doesn't need JavaScript, we should consider using the {@link CheerioCrawler},
152
189
  * which downloads the pages using raw HTTP requests and is about 10x faster.
153
190
  *
154
- * The source URLs are represented by the {@link Request} objects that are fed from the {@link RequestList} or {@link RequestQueue} instances
155
- * provided by the {@link BrowserCrawlerOptions.requestList|`requestList`} or {@link BrowserCrawlerOptions.requestQueue|`requestQueue`}
156
- * constructor options, respectively. If neither `requestList` nor `requestQueue` options are provided,
191
+ * The source URLs are represented by the {@link Request} objects that are fed from the
192
+ * {@link IRequestManager|request manager} provided via the {@link BrowserCrawlerOptions.requestManager|`requestManager`}
193
+ * constructor option (a {@link RequestQueue} is itself a request manager). If no `requestManager` is provided,
157
194
  * the crawler will open the default request queue either when the {@link BrowserCrawler.addRequests|`crawler.addRequests()`} function is called,
158
195
  * or if `requests` parameter (representing the initial requests) of the {@link BrowserCrawler.run|`crawler.run()`} function is provided.
159
196
  *
160
- * If both {@link BrowserCrawlerOptions.requestList|`requestList`} and {@link BrowserCrawlerOptions.requestQueue|`requestQueue`} options are used,
161
- * the instance first processes URLs from the {@link RequestList} and automatically enqueues all of them
162
- * to the {@link RequestQueue} before it starts their processing. This ensures that a single URL is not crawled multiple times.
197
+ * To read from a read-only source such as a {@link RequestList} while still being able to enqueue new requests,
198
+ * combine it with a queue into a {@link RequestManagerTandem} via {@link IRequestLoader.toTandem|`requestLoader.toTandem()`}
199
+ * and pass the result as `requestManager`.
200
+ *
201
+ * > The {@link BrowserCrawlerOptions.requestList|`requestList`} and {@link BrowserCrawlerOptions.requestQueue|`requestQueue`}
202
+ * > options are deprecated; they are still accepted and folded into a single `requestManager` for back-compat.
163
203
  *
164
204
  * The crawler finishes when there are no more {@link Request} objects to crawl.
165
205
  *
@@ -178,24 +218,25 @@ export interface BrowserCrawlerOptions<Context extends BrowserCrawlingContext =
178
218
  *
179
219
  * @category Crawlers
180
220
  */
181
- export declare abstract class BrowserCrawler<InternalBrowserPoolOptions extends BrowserPoolOptions = BrowserPoolOptions, LaunchOptions extends Dictionary | undefined = Dictionary, Context extends BrowserCrawlingContext = BrowserCrawlingContext, GoToOptions extends Dictionary = Dictionary> extends BasicCrawler<Context> {
182
- readonly config: Configuration;
221
+ export declare abstract class BrowserCrawler<Page extends CommonPage = CommonPage, Response extends BaseResponse = BaseResponse, InternalBrowserPoolOptions extends BrowserPoolOptions = BrowserPoolOptions, LaunchOptions extends Dictionary | undefined = Dictionary, Context extends BrowserCrawlingContext<Page, Response, Dictionary> = BrowserCrawlingContext<Page, Response, Dictionary>, ContextExtension = Dictionary<never>, ExtendedContext extends Context = Context & ContextExtension, GoToOptions extends Dictionary = Dictionary> extends BasicCrawler<Context, ContextExtension, ExtendedContext> {
183
222
  /**
184
- * A reference to the underlying {@link ProxyConfiguration} class that manages the crawler's proxies.
185
- * Only available if used by the crawler.
223
+ * A reference to the underlying browser pool that manages the crawler's browsers. Typed as
224
+ * {@link IBrowserPool} so custom implementations can be plugged in via the `browserPool` constructor option.
186
225
  */
187
- proxyConfiguration?: ProxyConfiguration;
226
+ browserPool: IBrowserPool<Page>;
188
227
  /**
189
- * A reference to the underlying {@link BrowserPool} class that manages the crawler's browsers.
228
+ * Set when the crawler constructed its own pool (a {@link BrowserPool}, or a {@link RemoteBrowserPool}
229
+ * built from the `remoteBrowser` option). Holds the same instance as `browserPool` but is the only reference
230
+ * the crawler tears down — a user-supplied `browserPool` is never owned and never destroyed by the crawler.
190
231
  */
191
- browserPool: BrowserPool<InternalBrowserPoolOptions>;
232
+ private ownedBrowserPool?;
192
233
  launchContext: BrowserLaunchContext<LaunchOptions, unknown>;
193
- protected userProvidedRequestHandler: BrowserRequestHandler<Context>;
194
- protected navigationTimeoutMillis: number;
195
- protected requestHandlerTimeoutInnerMillis: number;
196
- protected preNavigationHooks: BrowserHook<Context>[];
197
- protected postNavigationHooks: BrowserHook<Context>[];
198
- protected persistCookiesPerSession: boolean;
234
+ protected readonly ignoreShadowRoots: boolean;
235
+ protected readonly ignoreIframes: boolean;
236
+ private readonly navigationTimeoutMillis;
237
+ private readonly preNavigationHooks;
238
+ private readonly postNavigationHooks;
239
+ private readonly saveResponseCookies;
199
240
  protected static optionsShape: {
200
241
  // @ts-ignore optional peer dependency or compatibility with es2022
201
242
  navigationTimeoutSecs: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
@@ -208,19 +249,19 @@ export declare abstract class BrowserCrawler<InternalBrowserPoolOptions extends
208
249
  // @ts-ignore optional peer dependency or compatibility with es2022
209
250
  headless: import("ow").AnyPredicate<string | boolean>;
210
251
  // @ts-ignore optional peer dependency or compatibility with es2022
211
- browserPoolOptions: import("ow").ObjectPredicate<object>;
252
+ browserPool: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
212
253
  // @ts-ignore optional peer dependency or compatibility with es2022
213
- sessionPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
254
+ remoteBrowser: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
214
255
  // @ts-ignore optional peer dependency or compatibility with es2022
215
- persistCookiesPerSession: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
256
+ browserPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
216
257
  // @ts-ignore optional peer dependency or compatibility with es2022
217
- useSessionPool: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
258
+ saveResponseCookies: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
218
259
  // @ts-ignore optional peer dependency or compatibility with es2022
219
260
  proxyConfiguration: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
220
261
  // @ts-ignore optional peer dependency or compatibility with es2022
221
- ignoreShadowRoots: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
262
+ contextPipelineBuilder: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
222
263
  // @ts-ignore optional peer dependency or compatibility with es2022
223
- ignoreIframes: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
264
+ extendContext: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
224
265
  // @ts-ignore optional peer dependency or compatibility with es2022
225
266
  requestList: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
226
267
  // @ts-ignore optional peer dependency or compatibility with es2022
@@ -237,24 +278,40 @@ export declare abstract class BrowserCrawler<InternalBrowserPoolOptions extends
237
278
  maxRequestRetries: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
238
279
  // @ts-ignore optional peer dependency or compatibility with es2022
239
280
  sameDomainDelaySecs: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
240
- // @ts-ignore optional peer dependency or compatibility with es2022
241
- maxSessionRotations: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
242
281
  // @ts-ignore optional peer dependency or compatibility with es2022
243
282
  maxRequestsPerCrawl: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
283
+ // @ts-ignore optional peer dependency or compatibility with es2022
284
+ maxCrawlDepth: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
244
285
  // @ts-ignore optional peer dependency or compatibility with es2022
245
286
  autoscaledPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
287
+ // @ts-ignore optional peer dependency or compatibility with es2022
288
+ sessionPool: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
246
289
  // @ts-ignore optional peer dependency or compatibility with es2022
247
290
  statusMessageLoggingInterval: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
248
291
  // @ts-ignore optional peer dependency or compatibility with es2022
249
292
  statusMessageCallback: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
293
+ // @ts-ignore optional peer dependency or compatibility with es2022
294
+ additionalHttpErrorStatusCodes: import("ow").ArrayPredicate<number>;
295
+ // @ts-ignore optional peer dependency or compatibility with es2022
296
+ ignoreHttpErrorStatusCodes: import("ow").ArrayPredicate<number>;
297
+ // @ts-ignore optional peer dependency or compatibility with es2022
298
+ blockedStatusCodes: import("ow").ArrayPredicate<number>;
250
299
  // @ts-ignore optional peer dependency or compatibility with es2022
251
300
  retryOnBlocked: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
252
301
  // @ts-ignore optional peer dependency or compatibility with es2022
253
- respectRobotsTxtFile: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
302
+ respectRobotsTxtFile: import("ow").AnyPredicate<boolean | object>;
254
303
  // @ts-ignore optional peer dependency or compatibility with es2022
255
304
  onSkippedRequest: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
256
305
  // @ts-ignore optional peer dependency or compatibility with es2022
257
306
  httpClient: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
307
+ // @ts-ignore optional peer dependency or compatibility with es2022
308
+ configuration: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
309
+ // @ts-ignore optional peer dependency or compatibility with es2022
310
+ storageBackend: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
311
+ // @ts-ignore optional peer dependency or compatibility with es2022
312
+ eventManager: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
313
+ // @ts-ignore optional peer dependency or compatibility with es2022
314
+ logger: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
258
315
  // @ts-ignore optional peer dependency or compatibility with es2022
259
316
  minConcurrency: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
260
317
  // @ts-ignore optional peer dependency or compatibility with es2022
@@ -263,42 +320,37 @@ export declare abstract class BrowserCrawler<InternalBrowserPoolOptions extends
263
320
  maxRequestsPerMinute: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
264
321
  // @ts-ignore optional peer dependency or compatibility with es2022
265
322
  keepAlive: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
266
- // @ts-ignore optional peer dependency or compatibility with es2022
267
- log: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
268
- // @ts-ignore optional peer dependency or compatibility with es2022
269
- experiments: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
270
323
  // @ts-ignore optional peer dependency or compatibility with es2022
271
324
  statisticsOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
325
+ // @ts-ignore optional peer dependency or compatibility with es2022
326
+ id: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
272
327
  };
273
328
  /**
274
329
  * All `BrowserCrawler` parameters are passed via an options object.
275
330
  */
276
- protected constructor(options?: BrowserCrawlerOptions<Context>, config?: Configuration);
277
- protected _cleanupContext(crawlingContext: Context): Promise<void>;
331
+ protected constructor(options: BrowserCrawlerOptions<Page, Response, Context, ContextExtension, ExtendedContext> & {
332
+ contextPipelineBuilder: () => ContextPipeline<CrawlingContext, Context>;
333
+ });
334
+ protected buildContextPipeline(): ContextPipeline<CrawlingContext, BrowserCrawlingContext<Page, Response, Dictionary>>;
278
335
  private containsSelectors;
279
- protected isRequestBlocked(crawlingContext: Context): Promise<string | false>;
280
- /**
281
- * Wrapper around requestHandler that opens and closes pages etc.
282
- */
283
- protected _runRequestHandler(crawlingContext: Context): Promise<void>;
284
- protected _enhanceCrawlingContextWithPageInfo(crawlingContext: Context, page: CommonPage, createNewSession?: boolean): void;
285
- protected _handleNavigation(crawlingContext: Context): Promise<void>;
286
- protected _applyCookies({ session, request, page, browserController }: Context, preHooksCookies: string, postHooksCookies: string): Promise<void>;
336
+ private isRequestBlocked;
337
+ private preparePage;
338
+ private prepareNavigation;
339
+ private navigate;
340
+ private finalizeNavigation;
341
+ private handleBlockedRequestByContent;
342
+ private restoreRequestState;
343
+ private applyCookies;
287
344
  /**
288
- * Marks session bad in case of navigation timeout.
345
+ * Marks session bad on navigation timeout, and stops in-flight page loading on any navigation error.
289
346
  */
290
- protected _handleNavigationTimeout(crawlingContext: Context, error: Error): Promise<void>;
347
+ private handleNavigationTimeout;
291
348
  /**
292
349
  * Transforms proxy-related errors to `SessionError`.
293
350
  */
294
- protected _throwIfProxyError(error: Error): void;
295
- protected abstract _navigationHandler(crawlingContext: Context, gotoOptions: GoToOptions): Promise<Context['response'] | null | undefined>;
296
- /**
297
- * Should be overridden in case of different automation library that does not support this response API.
298
- */
299
- protected _responseHandler(crawlingContext: Context): Promise<void>;
300
- protected _extendLaunchContext(_pageId: string, launchContext: LaunchContext): Promise<void>;
301
- protected _maybeAddSessionRetiredListener(_pageId: string, browserController: Context['browserController']): void;
351
+ private throwIfProxyError;
352
+ protected abstract _navigationHandler(crawlingContext: BrowserCrawlingContext<Page, Response>, gotoOptions: GoToOptions): Promise<Context['response'] | null | undefined>;
353
+ private processResponse;
302
354
  /**
303
355
  * Function for cleaning up after all requests are processed.
304
356
  * @ignore
@@ -307,17 +359,24 @@ export declare abstract class BrowserCrawler<InternalBrowserPoolOptions extends
307
359
  }
308
360
  /** @internal */
309
361
  interface EnqueueLinksInternalOptions {
310
- options?: ReadonlyDeep<Omit<EnqueueLinksOptions, 'requestQueue'>> & Pick<EnqueueLinksOptions, 'requestQueue'>;
362
+ options?: ReadonlyDeep<Omit<EnqueueLinksOptions, 'requestManager'>> & Pick<EnqueueLinksOptions, 'requestManager'>;
311
363
  page: CommonPage;
312
- requestQueue: RequestProvider;
364
+ requestManager: IRequestManager;
313
365
  robotsTxtFile?: RobotsTxtFile;
314
366
  onSkippedRequest?: SkippedRequestCallback;
315
367
  originalRequestUrl: string;
316
368
  finalRequestUrl?: string;
317
369
  }
318
370
  /** @internal */
319
- // @ts-ignore optional peer dependency or compatibility with es2022
320
- export declare function browserCrawlerEnqueueLinks({ options, page, requestQueue, robotsTxtFile, onSkippedRequest, originalRequestUrl, finalRequestUrl, }: EnqueueLinksInternalOptions): Promise<import("@crawlee/types").BatchAddRequestsResult>;
371
+ interface BoundEnqueueLinksInternalOptions {
372
+ enqueueLinks: BasicCrawlingContext['enqueueLinks'];
373
+ options?: ReadonlyDeep<Omit<EnqueueLinksOptions, 'requestManager'>> & Pick<EnqueueLinksOptions, 'requestManager'>;
374
+ originalRequestUrl: string;
375
+ finalRequestUrl?: string;
376
+ page: CommonPage;
377
+ }
378
+ /** @internal */
379
+ export declare function browserCrawlerEnqueueLinks(options: EnqueueLinksInternalOptions | BoundEnqueueLinksInternalOptions): Promise<unknown>;
321
380
  /**
322
381
  * Extracts URLs from a given page.
323
382
  * @ignore
@@ -326,4 +385,3 @@ export declare function extractUrlsFromPage(page: {
326
385
  $$eval: Function;
327
386
  }, selector: string, baseUrl: string): Promise<string[]>;
328
387
  export {};
329
- //# sourceMappingURL=browser-crawler.d.ts.map