@crawlee/puppeteer 4.0.0-beta.21 → 4.0.0-beta.210
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 +14 -14
- package/index.d.ts +2 -4
- package/index.js +1 -3
- package/internals/enqueue-links/click-elements.d.ts +45 -72
- package/internals/enqueue-links/click-elements.js +65 -66
- package/internals/puppeteer-browser-pool.d.ts +55 -0
- package/internals/puppeteer-browser-pool.js +48 -0
- package/internals/puppeteer-crawler.d.ts +163 -118
- package/internals/puppeteer-crawler.js +55 -70
- package/internals/puppeteer-launcher.d.ts +31 -19
- package/internals/puppeteer-launcher.js +18 -14
- package/internals/utils/puppeteer_request_interception.d.ts +0 -1
- package/internals/utils/puppeteer_request_interception.js +8 -8
- package/internals/utils/puppeteer_utils.d.ts +17 -77
- package/internals/utils/puppeteer_utils.js +82 -181
- package/package.json +11 -16
- package/index.d.ts.map +0 -1
- package/index.js.map +0 -1
- package/internals/enqueue-links/click-elements.d.ts.map +0 -1
- package/internals/enqueue-links/click-elements.js.map +0 -1
- package/internals/puppeteer-crawler.d.ts.map +0 -1
- package/internals/puppeteer-crawler.js.map +0 -1
- package/internals/puppeteer-launcher.d.ts.map +0 -1
- package/internals/puppeteer-launcher.js.map +0 -1
- package/internals/utils/puppeteer_request_interception.d.ts.map +0 -1
- package/internals/utils/puppeteer_request_interception.js.map +0 -1
- package/internals/utils/puppeteer_utils.d.ts.map +0 -1
- package/internals/utils/puppeteer_utils.js.map +0 -1
|
@@ -3,6 +3,7 @@ import { BrowserLauncher, Configuration } from '@crawlee/browser';
|
|
|
3
3
|
import { PuppeteerPlugin } from '@crawlee/browser-pool';
|
|
4
4
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
5
5
|
import type { Browser } from 'puppeteer';
|
|
6
|
+
import { z } from 'zod';
|
|
6
7
|
/**
|
|
7
8
|
* Apify extends the launch options of Puppeteer.
|
|
8
9
|
* You can use any of the Puppeteer compatible
|
|
@@ -66,30 +67,42 @@ export interface PuppeteerLaunchContext extends BrowserLaunchContext<PuppeteerPl
|
|
|
66
67
|
* @ignore
|
|
67
68
|
*/
|
|
68
69
|
export declare class PuppeteerLauncher extends BrowserLauncher<PuppeteerPlugin, unknown> {
|
|
69
|
-
readonly
|
|
70
|
+
readonly configuration: Configuration;
|
|
71
|
+
/**
|
|
72
|
+
* @internal
|
|
73
|
+
*/
|
|
70
74
|
protected static optionsShape: {
|
|
75
|
+
proxyUrl: z.ZodOptional<z.ZodURL>;
|
|
76
|
+
useChrome: z.ZodOptional<z.ZodBoolean>;
|
|
77
|
+
useIncognitoPages: z.ZodOptional<z.ZodBoolean>;
|
|
78
|
+
browserPerProxy: z.ZodOptional<z.ZodBoolean>;
|
|
79
|
+
ignoreProxyCertificate: z.ZodOptional<z.ZodBoolean>;
|
|
80
|
+
userDataDir: z.ZodOptional<z.ZodString>;
|
|
71
81
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
proxyUrl: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
75
|
-
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
76
|
-
useChrome: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
82
|
+
launchOptions: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
83
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
77
84
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
85
|
+
launcher: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
86
|
+
};
|
|
87
|
+
/** @internal */
|
|
88
|
+
protected static optionsSchema: z.ZodObject<{
|
|
89
|
+
proxyUrl: z.ZodOptional<z.ZodURL>;
|
|
90
|
+
useChrome: z.ZodOptional<z.ZodBoolean>;
|
|
91
|
+
useIncognitoPages: z.ZodOptional<z.ZodBoolean>;
|
|
92
|
+
browserPerProxy: z.ZodOptional<z.ZodBoolean>;
|
|
93
|
+
ignoreProxyCertificate: z.ZodOptional<z.ZodBoolean>;
|
|
94
|
+
userDataDir: z.ZodOptional<z.ZodString>;
|
|
83
95
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
84
|
-
launchOptions: import("
|
|
96
|
+
launchOptions: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
97
|
+
userAgent: z.ZodOptional<z.ZodString>;
|
|
85
98
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
86
|
-
|
|
87
|
-
}
|
|
99
|
+
launcher: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
100
|
+
}, z.core.$strict>;
|
|
88
101
|
/**
|
|
89
102
|
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
90
103
|
*/
|
|
91
|
-
constructor(launchContext?: PuppeteerLaunchContext,
|
|
92
|
-
protected
|
|
104
|
+
constructor(launchContext?: PuppeteerLaunchContext, configuration?: Configuration);
|
|
105
|
+
protected getDefaultHeadlessOption(): boolean;
|
|
93
106
|
}
|
|
94
107
|
/**
|
|
95
108
|
* Launches headless Chrome using Puppeteer pre-configured to work within the Apify platform.
|
|
@@ -119,9 +132,8 @@ export declare class PuppeteerLauncher extends BrowserLauncher<PuppeteerPlugin,
|
|
|
119
132
|
* @param [launchContext]
|
|
120
133
|
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
121
134
|
* If you want to pass custom `puppeteer.launch(options)` options you can use the `PuppeteerLaunchContext.launchOptions` property.
|
|
122
|
-
* @param [
|
|
135
|
+
* @param [configuration]
|
|
123
136
|
* @returns
|
|
124
137
|
* Promise that resolves to Puppeteer's `Browser` instance.
|
|
125
138
|
*/
|
|
126
|
-
export declare function launchPuppeteer(launchContext?: PuppeteerLaunchContext,
|
|
127
|
-
//# sourceMappingURL=puppeteer-launcher.d.ts.map
|
|
139
|
+
export declare function launchPuppeteer(launchContext?: PuppeteerLaunchContext, configuration?: Configuration): Promise<Browser>;
|
|
@@ -1,31 +1,36 @@
|
|
|
1
1
|
import { BrowserLauncher, Configuration } from '@crawlee/browser';
|
|
2
2
|
import { PuppeteerPlugin } from '@crawlee/browser-pool';
|
|
3
|
-
import
|
|
3
|
+
import { parseArgument, schemas } from '@crawlee/utils/internal';
|
|
4
|
+
import { z } from 'zod';
|
|
4
5
|
/**
|
|
5
6
|
* `PuppeteerLauncher` is based on the `BrowserLauncher`. It launches `puppeteer` browser instance.
|
|
6
7
|
* @ignore
|
|
7
8
|
*/
|
|
8
9
|
export class PuppeteerLauncher extends BrowserLauncher {
|
|
9
|
-
|
|
10
|
+
configuration;
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
10
14
|
static optionsShape = {
|
|
11
15
|
...BrowserLauncher.optionsShape,
|
|
12
|
-
launcher:
|
|
16
|
+
launcher: schemas.anyObject.optional(),
|
|
13
17
|
};
|
|
18
|
+
/** @internal */
|
|
19
|
+
static optionsSchema = z.strictObject(PuppeteerLauncher.optionsShape);
|
|
14
20
|
/**
|
|
15
21
|
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
16
22
|
*/
|
|
17
|
-
constructor(launchContext = {},
|
|
18
|
-
|
|
19
|
-
const { launcher = BrowserLauncher.requireLauncherOrThrow('puppeteer', 'apify/actor-node-puppeteer-chrome'), ...browserLauncherOptions } = launchContext;
|
|
23
|
+
constructor(launchContext = {}, configuration = Configuration.getGlobalConfiguration()) {
|
|
24
|
+
const { launcher = BrowserLauncher.requireLauncherOrThrow('puppeteer', 'apify/actor-node-puppeteer-chrome'), ...browserLauncherOptions } = parseArgument(launchContext, PuppeteerLauncher.optionsSchema, 'PuppeteerLaunchContext');
|
|
20
25
|
super({
|
|
21
26
|
...browserLauncherOptions,
|
|
22
27
|
launcher,
|
|
23
|
-
},
|
|
24
|
-
this.
|
|
28
|
+
}, configuration);
|
|
29
|
+
this.configuration = configuration;
|
|
25
30
|
this.Plugin = PuppeteerPlugin;
|
|
26
31
|
}
|
|
27
|
-
|
|
28
|
-
const headless = super.
|
|
32
|
+
getDefaultHeadlessOption() {
|
|
33
|
+
const headless = super.getDefaultHeadlessOption();
|
|
29
34
|
return headless ? 'new' : headless;
|
|
30
35
|
}
|
|
31
36
|
}
|
|
@@ -57,12 +62,11 @@ export class PuppeteerLauncher extends BrowserLauncher {
|
|
|
57
62
|
* @param [launchContext]
|
|
58
63
|
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
59
64
|
* If you want to pass custom `puppeteer.launch(options)` options you can use the `PuppeteerLaunchContext.launchOptions` property.
|
|
60
|
-
* @param [
|
|
65
|
+
* @param [configuration]
|
|
61
66
|
* @returns
|
|
62
67
|
* Promise that resolves to Puppeteer's `Browser` instance.
|
|
63
68
|
*/
|
|
64
|
-
export async function launchPuppeteer(launchContext,
|
|
65
|
-
const puppeteerLauncher = new PuppeteerLauncher(launchContext,
|
|
69
|
+
export async function launchPuppeteer(launchContext, configuration = Configuration.getGlobalConfiguration()) {
|
|
70
|
+
const puppeteerLauncher = new PuppeteerLauncher(launchContext, configuration);
|
|
66
71
|
return puppeteerLauncher.launch();
|
|
67
72
|
}
|
|
68
|
-
//# sourceMappingURL=puppeteer-launcher.js.map
|
|
@@ -58,4 +58,3 @@ export declare function addInterceptRequestHandler(page: Page, handler: Intercep
|
|
|
58
58
|
* @param handler Request interception handler.
|
|
59
59
|
*/
|
|
60
60
|
export declare function removeInterceptRequestHandler(page: Page, handler: InterceptHandler): Promise<void>;
|
|
61
|
-
//# sourceMappingURL=puppeteer_request_interception.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from 'node:events';
|
|
2
|
-
import
|
|
3
|
-
import
|
|
2
|
+
import { serviceLocator } from '@crawlee/browser';
|
|
3
|
+
import { parseArgument, schemas } from '@crawlee/utils/internal';
|
|
4
|
+
const pageSchema = schemas.objectWithKeys(['goto', 'evaluate']);
|
|
4
5
|
// We use weak maps here so that the content gets discarded after page gets closed.
|
|
5
6
|
const pageInterceptRequestHandlersMap = new WeakMap(); // Maps page to an array of request interception handlers.
|
|
6
7
|
const pageInterceptRequestMasterHandlerMap = new WeakMap(); // Maps page to master request interception handler.
|
|
@@ -137,8 +138,8 @@ async function handleRequest(request, interceptRequestHandlers) {
|
|
|
137
138
|
* @param handler Request interception handler.
|
|
138
139
|
*/
|
|
139
140
|
export async function addInterceptRequestHandler(page, handler) {
|
|
140
|
-
|
|
141
|
-
|
|
141
|
+
parseArgument(page, pageSchema);
|
|
142
|
+
parseArgument(handler, schemas.anyFunction);
|
|
142
143
|
if (!pageInterceptRequestHandlersMap.has(page)) {
|
|
143
144
|
pageInterceptRequestHandlersMap.set(page, []);
|
|
144
145
|
}
|
|
@@ -174,8 +175,8 @@ export async function addInterceptRequestHandler(page, handler) {
|
|
|
174
175
|
* @param handler Request interception handler.
|
|
175
176
|
*/
|
|
176
177
|
export async function removeInterceptRequestHandler(page, handler) {
|
|
177
|
-
|
|
178
|
-
|
|
178
|
+
parseArgument(page, pageSchema);
|
|
179
|
+
parseArgument(handler, schemas.anyFunction);
|
|
179
180
|
const handlersArray = pageInterceptRequestHandlersMap.get(page).filter((item) => item !== handler);
|
|
180
181
|
pageInterceptRequestHandlersMap.set(page, handlersArray);
|
|
181
182
|
if (handlersArray.length === 0) {
|
|
@@ -194,7 +195,7 @@ export async function removeInterceptRequestHandler(page, handler) {
|
|
|
194
195
|
interceptedRequestsInProgress.removeListener('delete', onDelete);
|
|
195
196
|
}
|
|
196
197
|
catch (error) {
|
|
197
|
-
|
|
198
|
+
serviceLocator.getLogger().debug('Error while disabling request interception', { error });
|
|
198
199
|
}
|
|
199
200
|
}
|
|
200
201
|
};
|
|
@@ -207,4 +208,3 @@ async function disableRequestInterception(page) {
|
|
|
207
208
|
const requestHandler = pageInterceptRequestMasterHandlerMap.get(page);
|
|
208
209
|
page.off('request', requestHandler);
|
|
209
210
|
}
|
|
210
|
-
//# sourceMappingURL=puppeteer_request_interception.js.map
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* **Example usage:**
|
|
6
6
|
*
|
|
7
7
|
* ```javascript
|
|
8
|
-
* import { launchPuppeteer,
|
|
8
|
+
* import { launchPuppeteer, puppeteerUtils } from 'crawlee';
|
|
9
9
|
*
|
|
10
10
|
* // Open https://www.example.com in Puppeteer
|
|
11
11
|
* const browser = await launchPuppeteer();
|
|
@@ -13,17 +13,16 @@
|
|
|
13
13
|
* await page.goto('https://www.example.com');
|
|
14
14
|
*
|
|
15
15
|
* // Inject jQuery into a page
|
|
16
|
-
* await
|
|
16
|
+
* await puppeteerUtils.injectJQuery(page);
|
|
17
17
|
* ```
|
|
18
18
|
* @module puppeteerUtils
|
|
19
19
|
*/
|
|
20
20
|
import type { Request } from '@crawlee/browser';
|
|
21
21
|
import { Configuration } from '@crawlee/browser';
|
|
22
22
|
import type { BatchAddRequestsResult, Dictionary } from '@crawlee/types';
|
|
23
|
-
import {
|
|
24
|
-
import type { ProtocolMapping } from 'devtools-protocol/types/protocol-mapping.js';
|
|
23
|
+
import type { CheerioAPI } from 'cheerio';
|
|
25
24
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
26
|
-
import type { HTTPResponse, Page
|
|
25
|
+
import type { HTTPResponse, Page } from 'puppeteer';
|
|
27
26
|
import type { EnqueueLinksByClickingElementsOptions } from '../enqueue-links/click-elements.js';
|
|
28
27
|
import { enqueueLinksByClickingElements } from '../enqueue-links/click-elements.js';
|
|
29
28
|
import type { InterceptHandler } from './puppeteer_request_interception.js';
|
|
@@ -101,7 +100,7 @@ export declare function injectFile(page: Page, filePath: string, options?: Injec
|
|
|
101
100
|
*
|
|
102
101
|
* **Example usage:**
|
|
103
102
|
* ```javascript
|
|
104
|
-
* await
|
|
103
|
+
* await puppeteerUtils.injectJQuery(page);
|
|
105
104
|
* const title = await page.evaluate(() => {
|
|
106
105
|
* return $('head title').text();
|
|
107
106
|
* });
|
|
@@ -122,14 +121,14 @@ export declare function injectJQuery(page: Page, options?: {
|
|
|
122
121
|
*
|
|
123
122
|
* **Example usage:**
|
|
124
123
|
* ```javascript
|
|
125
|
-
* const $ = await
|
|
124
|
+
* const $ = await puppeteerUtils.parseWithCheerio(page);
|
|
126
125
|
* const title = $('title').text();
|
|
127
126
|
* ```
|
|
128
127
|
*
|
|
129
128
|
* @param page Puppeteer [`Page`](https://pptr.dev/api/puppeteer.page) object.
|
|
130
129
|
* @param ignoreShadowRoots
|
|
131
130
|
*/
|
|
132
|
-
export declare function parseWithCheerio(page: Page, ignoreShadowRoots?: boolean, ignoreIframes?: boolean): Promise<
|
|
131
|
+
export declare function parseWithCheerio(page: Page, ignoreShadowRoots?: boolean, ignoreIframes?: boolean): Promise<CheerioAPI>;
|
|
133
132
|
/**
|
|
134
133
|
* Forces the Puppeteer browser tab to block loading URLs that match a provided pattern.
|
|
135
134
|
* This is useful to speed up crawling of websites, since it reduces the amount
|
|
@@ -156,13 +155,13 @@ export declare function parseWithCheerio(page: Page, ignoreShadowRoots?: boolean
|
|
|
156
155
|
*
|
|
157
156
|
* **Example usage**
|
|
158
157
|
* ```javascript
|
|
159
|
-
* import { launchPuppeteer,
|
|
158
|
+
* import { launchPuppeteer, puppeteerUtils } from 'crawlee';
|
|
160
159
|
*
|
|
161
160
|
* const browser = await launchPuppeteer();
|
|
162
161
|
* const page = await browser.newPage();
|
|
163
162
|
*
|
|
164
163
|
* // Block all requests to URLs that include `adsbygoogle.js` and also all defaults.
|
|
165
|
-
* await
|
|
164
|
+
* await puppeteerUtils.blockRequests(page, {
|
|
166
165
|
* extraUrlPatterns: ['adsbygoogle.js'],
|
|
167
166
|
* });
|
|
168
167
|
*
|
|
@@ -173,33 +172,6 @@ export declare function parseWithCheerio(page: Page, ignoreShadowRoots?: boolean
|
|
|
173
172
|
* @param [options]
|
|
174
173
|
*/
|
|
175
174
|
export declare function blockRequests(page: Page, options?: BlockRequestsOptions): Promise<void>;
|
|
176
|
-
/**
|
|
177
|
-
* @internal
|
|
178
|
-
*/
|
|
179
|
-
export declare function sendCDPCommand<T extends keyof ProtocolMapping.Commands>(page: Page, command: T, ...args: ProtocolMapping.Commands[T]['paramsType']): Promise<ProtocolMapping.Commands[T]['returnType']>;
|
|
180
|
-
/**
|
|
181
|
-
* `blockResources()` has a high impact on performance in recent versions of Puppeteer.
|
|
182
|
-
* Until this resolves, please use `utils.puppeteer.blockRequests()`.
|
|
183
|
-
* @deprecated
|
|
184
|
-
*/
|
|
185
|
-
export declare const blockResources: (page: Page, resourceTypes?: string[]) => Promise<void>;
|
|
186
|
-
/**
|
|
187
|
-
* *NOTE:* In recent versions of Puppeteer using this function entirely disables browser cache which resolves in sub-optimal
|
|
188
|
-
* performance. Until this resolves, we suggest just relying on the in-browser cache unless absolutely necessary.
|
|
189
|
-
*
|
|
190
|
-
* Enables caching of intercepted responses into a provided object. Automatically enables request interception in Puppeteer.
|
|
191
|
-
* *IMPORTANT*: Caching responses stores them to memory, so too loose rules could cause memory leaks for longer running crawlers.
|
|
192
|
-
* This issue should be resolved or atleast mitigated in future iterations of this feature.
|
|
193
|
-
* @param page
|
|
194
|
-
* Puppeteer [`Page`](https://pptr.dev/api/puppeteer.page) object.
|
|
195
|
-
* @param cache
|
|
196
|
-
* Object in which responses are stored
|
|
197
|
-
* @param responseUrlRules
|
|
198
|
-
* List of rules that are used to check if the response should be cached.
|
|
199
|
-
* String rules are compared as page.url().includes(rule) while RegExp rules are evaluated as rule.test(page.url()).
|
|
200
|
-
* @deprecated
|
|
201
|
-
*/
|
|
202
|
-
export declare function cacheResponses(page: Page, cache: Dictionary<Partial<ResponseForRequest>>, responseUrlRules: (string | RegExp)[]): Promise<void>;
|
|
203
175
|
/**
|
|
204
176
|
* Compiles a Puppeteer script into an async function that may be executed at any time
|
|
205
177
|
* by providing it with the following object:
|
|
@@ -305,9 +277,9 @@ export interface SaveSnapshotOptions {
|
|
|
305
277
|
keyValueStoreName?: string | null;
|
|
306
278
|
/**
|
|
307
279
|
* Configuration of the crawler that will be used to save the snapshot.
|
|
308
|
-
* @default Configuration.
|
|
280
|
+
* @default Configuration.getGlobalConfiguration()
|
|
309
281
|
*/
|
|
310
|
-
|
|
282
|
+
configuration?: Configuration;
|
|
311
283
|
}
|
|
312
284
|
/**
|
|
313
285
|
* Saves a full screenshot and HTML of the current page into a Key-Value store.
|
|
@@ -315,8 +287,6 @@ export interface SaveSnapshotOptions {
|
|
|
315
287
|
* @param [options]
|
|
316
288
|
*/
|
|
317
289
|
export declare function saveSnapshot(page: Page, options?: SaveSnapshotOptions): Promise<void>;
|
|
318
|
-
export declare function closeCookieModals(page: Page): Promise<void>;
|
|
319
|
-
/** @internal */
|
|
320
290
|
export interface PuppeteerContextUtils {
|
|
321
291
|
/**
|
|
322
292
|
* Injects a JavaScript file into current `page`.
|
|
@@ -378,7 +348,7 @@ export interface PuppeteerContextUtils {
|
|
|
378
348
|
* });
|
|
379
349
|
* ```
|
|
380
350
|
*/
|
|
381
|
-
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<
|
|
351
|
+
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<CheerioAPI>;
|
|
382
352
|
/**
|
|
383
353
|
* The function finds elements matching a specific CSS selector in a Puppeteer page,
|
|
384
354
|
* clicks all those elements using a mouse move and a left mouse button click and intercepts
|
|
@@ -388,8 +358,7 @@ export interface PuppeteerContextUtils {
|
|
|
388
358
|
* in `href` elements, but rather navigations are triggered in click handlers.
|
|
389
359
|
* If you're looking to find URLs in `href` attributes of the page, see {@link enqueueLinks}.
|
|
390
360
|
*
|
|
391
|
-
* Optionally, the function allows you to filter the target links' URLs using an array of
|
|
392
|
-
* and override settings of the enqueued {@link Request} objects.
|
|
361
|
+
* Optionally, the function allows you to filter the target links' URLs using an array of glob or regexp patterns.
|
|
393
362
|
*
|
|
394
363
|
* **IMPORTANT**: To be able to do this, this function uses various mutations on the page,
|
|
395
364
|
* such as changing the Z-index of elements being clicked and their visibility. Therefore,
|
|
@@ -410,9 +379,9 @@ export interface PuppeteerContextUtils {
|
|
|
410
379
|
* async requestHandler({ enqueueLinksByClickingElements }) {
|
|
411
380
|
* await enqueueLinksByClickingElements({
|
|
412
381
|
* selector: 'a.product-detail',
|
|
413
|
-
*
|
|
414
|
-
* 'https://www.example.com/handbags/**'
|
|
415
|
-
* 'https://www.example.com/purses/**'
|
|
382
|
+
* include: [
|
|
383
|
+
* 'https://www.example.com/handbags/**',
|
|
384
|
+
* 'https://www.example.com/purses/**',
|
|
416
385
|
* ],
|
|
417
386
|
* });
|
|
418
387
|
* });
|
|
@@ -420,7 +389,7 @@ export interface PuppeteerContextUtils {
|
|
|
420
389
|
*
|
|
421
390
|
* @returns Promise that resolves to {@link BatchAddRequestsResult} object.
|
|
422
391
|
*/
|
|
423
|
-
enqueueLinksByClickingElements(options: Omit<EnqueueLinksByClickingElementsOptions, 'page' | '
|
|
392
|
+
enqueueLinksByClickingElements(options: Omit<EnqueueLinksByClickingElementsOptions, 'page' | 'requestManager'>): Promise<BatchAddRequestsResult>;
|
|
424
393
|
/**
|
|
425
394
|
* Forces the Puppeteer browser tab to block loading URLs that match a provided pattern.
|
|
426
395
|
* This is useful to speed up crawling of websites, since it reduces the amount
|
|
@@ -550,34 +519,5 @@ export interface PuppeteerContextUtils {
|
|
|
550
519
|
* Saves a full screenshot and HTML of the current page into a Key-Value store.
|
|
551
520
|
*/
|
|
552
521
|
saveSnapshot(options?: SaveSnapshotOptions): Promise<void>;
|
|
553
|
-
/**
|
|
554
|
-
* Tries to close cookie consent modals on the page. Based on the I Don't Care About Cookies browser extension.
|
|
555
|
-
*
|
|
556
|
-
* Note that this method requires the idcac-playwright package to be installed.
|
|
557
|
-
* Crawlee does not include it by default due to licensing issues.
|
|
558
|
-
*
|
|
559
|
-
* To use this method, please install the package manually by running:
|
|
560
|
-
*
|
|
561
|
-
* ```bash
|
|
562
|
-
* npm install idcac-playwright
|
|
563
|
-
* ```
|
|
564
|
-
*/
|
|
565
|
-
closeCookieModals(): Promise<void>;
|
|
566
522
|
}
|
|
567
523
|
export { enqueueLinksByClickingElements, addInterceptRequestHandler, removeInterceptRequestHandler };
|
|
568
|
-
/** @internal */
|
|
569
|
-
export declare const puppeteerUtils: {
|
|
570
|
-
injectFile: typeof injectFile;
|
|
571
|
-
injectJQuery: typeof injectJQuery;
|
|
572
|
-
enqueueLinksByClickingElements: typeof enqueueLinksByClickingElements;
|
|
573
|
-
blockRequests: typeof blockRequests;
|
|
574
|
-
compileScript: typeof compileScript;
|
|
575
|
-
gotoExtended: typeof gotoExtended;
|
|
576
|
-
addInterceptRequestHandler: typeof addInterceptRequestHandler;
|
|
577
|
-
removeInterceptRequestHandler: typeof removeInterceptRequestHandler;
|
|
578
|
-
infiniteScroll: typeof infiniteScroll;
|
|
579
|
-
saveSnapshot: typeof saveSnapshot;
|
|
580
|
-
parseWithCheerio: typeof parseWithCheerio;
|
|
581
|
-
closeCookieModals: typeof closeCookieModals;
|
|
582
|
-
};
|
|
583
|
-
//# sourceMappingURL=puppeteer_utils.d.ts.map
|