@crawlee/playwright 4.0.0-beta.134 → 4.0.0-beta.135
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/internals/adaptive-playwright-crawler.d.ts +3 -13
- package/internals/adaptive-playwright-crawler.js +2 -2
- package/internals/enqueue-links/click-elements.js +2 -1
- package/internals/playwright-crawler.d.ts +8 -22
- package/internals/playwright-crawler.js +6 -1
- package/internals/playwright-launcher.d.ts +4 -0
- package/internals/playwright-launcher.js +6 -1
- package/internals/utils/playwright-utils.d.ts +3 -3
- package/internals/utils/playwright-utils.js +2 -1
- package/package.json +9 -9
|
@@ -3,8 +3,7 @@ import type { BasicCrawlerOptions } from '@crawlee/basic';
|
|
|
3
3
|
import { BasicCrawler } from '@crawlee/basic';
|
|
4
4
|
import type { ContextPipeline, CrawlingContext, EnqueueLinksOptions, GetUserDataFromRequest, RouterRoutes, StorageTransactionView } from '@crawlee/core';
|
|
5
5
|
import type { Dictionary, Awaitable } from '@crawlee/types';
|
|
6
|
-
import { type
|
|
7
|
-
import { type Cheerio } from 'cheerio';
|
|
6
|
+
import { type Cheerio, type CheerioAPI } from 'cheerio';
|
|
8
7
|
import type { AnyNode } from 'domhandler';
|
|
9
8
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
10
9
|
import type { Page } from 'playwright';
|
|
@@ -80,7 +79,7 @@ export interface AdaptivePlaywrightCrawlerContext<UserData extends Dictionary =
|
|
|
80
79
|
* });
|
|
81
80
|
* ```
|
|
82
81
|
*/
|
|
83
|
-
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<
|
|
82
|
+
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<CheerioAPI>;
|
|
84
83
|
enqueueLinks(options?: EnqueueLinksOptions): Promise<unknown>;
|
|
85
84
|
}
|
|
86
85
|
interface AdaptiveHookContext extends Pick<AdaptivePlaywrightCrawlerContext, 'id' | 'session' | 'proxyInfo' | 'log'> {
|
|
@@ -186,16 +185,7 @@ export declare class AdaptivePlaywrightCrawler<ContextExtension = Dictionary<nev
|
|
|
186
185
|
#private;
|
|
187
186
|
constructor(options?: AdaptivePlaywrightCrawlerOptions<ContextExtension, ExtendedContext, Routes, StatisticStateExtension>);
|
|
188
187
|
protected init(): Promise<void>;
|
|
189
|
-
protected buildContextPipeline(): ContextPipeline<CrawlingContext
|
|
190
|
-
readonly request: LoadedRequest<Request<Dictionary>>;
|
|
191
|
-
readonly response: Response;
|
|
192
|
-
readonly page: Page;
|
|
193
|
-
readonly querySelector: AdaptivePlaywrightCrawlerContext["querySelector"];
|
|
194
|
-
readonly querySelectorAll: AdaptivePlaywrightCrawlerContext["querySelectorAll"];
|
|
195
|
-
readonly waitForSelector: AdaptivePlaywrightCrawlerContext["waitForSelector"];
|
|
196
|
-
readonly parseWithCheerio: AdaptivePlaywrightCrawlerContext["parseWithCheerio"];
|
|
197
|
-
readonly enqueueLinks: AdaptivePlaywrightCrawlerContext["enqueueLinks"];
|
|
198
|
-
}>;
|
|
188
|
+
protected buildContextPipeline(): ContextPipeline<CrawlingContext, AdaptivePlaywrightCrawlerContext>;
|
|
199
189
|
private adaptCheerioContext;
|
|
200
190
|
private adaptPlaywrightContext;
|
|
201
191
|
/**
|
|
@@ -2,8 +2,8 @@ import { isDeepStrictEqual } from 'node:util';
|
|
|
2
2
|
import { BasicCrawler } from '@crawlee/basic';
|
|
3
3
|
import { extractUrlsFromPage } from '@crawlee/browser';
|
|
4
4
|
import { CheerioCrawler } from '@crawlee/cheerio';
|
|
5
|
-
import { createStorageTransaction, EnqueueStrategy, OwnedOrInjected,
|
|
6
|
-
import { extractUrlsFromCheerio } from '@crawlee/utils/internal';
|
|
5
|
+
import { createStorageTransaction, EnqueueStrategy, OwnedOrInjected, RequestHandlerError, resolveBaseUrlForEnqueueLinksFiltering, Router, Statistics, } from '@crawlee/core';
|
|
6
|
+
import { extractUrlsFromCheerio, parseArgument } from '@crawlee/utils/internal';
|
|
7
7
|
import { z } from 'zod';
|
|
8
8
|
import { addTimeoutToPromise } from '@apify/timeout';
|
|
9
9
|
import { PlaywrightCrawler } from './playwright-crawler.js';
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { URL } from 'node:url';
|
|
2
|
-
import { applyRequestTransform, constructUrlPatternObjects, createRequestOptions, filterRequestOptionsByPatterns,
|
|
2
|
+
import { applyRequestTransform, constructUrlPatternObjects, createRequestOptions, filterRequestOptionsByPatterns, urlPatternSchema, Request as CrawleeRequest, serviceLocator, } from '@crawlee/browser';
|
|
3
|
+
import { parseArgument, schemas } from '@crawlee/utils/internal';
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
const STARTING_Z_INDEX = 2147400000;
|
|
5
6
|
const getLog = () => serviceLocator.getChildLog('Playwright Click Elements');
|
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import type { BrowserCrawlerOptions, BrowserCrawlingContext, BrowserHook, GetUserDataFromRequest, RequestHandler, RouterHandler, RouterRoutes, RouteSchemas, RoutesFromSchemas } from '@crawlee/browser';
|
|
1
|
+
import type { BrowserCrawlerOptions, BrowserCrawlingContext, BrowserHook, ContextPipeline, CrawlingContext, GetUserDataFromRequest, RequestHandler, RouterHandler, RouterRoutes, RouteSchemas, RoutesFromSchemas } from '@crawlee/browser';
|
|
2
2
|
import { BrowserCrawler } from '@crawlee/browser';
|
|
3
3
|
import type { Dictionary } from '@crawlee/types';
|
|
4
4
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
5
|
-
import type {
|
|
5
|
+
import type { LaunchOptions, Page, Response } from 'playwright';
|
|
6
6
|
import { z } from 'zod';
|
|
7
|
-
import type { EnqueueLinksByClickingElementsOptions } from './enqueue-links/click-elements.js';
|
|
8
7
|
import type { PlaywrightLaunchContext } from './playwright-launcher.js';
|
|
9
|
-
import type {
|
|
8
|
+
import type { DirectNavigationOptions, HandleCloudflareChallengeOptions, PlaywrightContextUtils } from './utils/playwright-utils.js';
|
|
10
9
|
export type PlaywrightGotoOptions = NonNullable<Parameters<Page['goto']>[1]>;
|
|
11
10
|
export interface PlaywrightCrawlingContext<UserData extends Dictionary = any> extends BrowserCrawlingContext<Page, Response, UserData, PlaywrightGotoOptions>, PlaywrightContextUtils {
|
|
12
11
|
}
|
|
@@ -145,6 +144,9 @@ export interface PlaywrightCrawlerOptions<ContextExtension = Dictionary<never>,
|
|
|
145
144
|
* @category Crawlers
|
|
146
145
|
*/
|
|
147
146
|
export declare 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, LaunchOptions, PlaywrightCrawlingContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension> {
|
|
147
|
+
/**
|
|
148
|
+
* @internal
|
|
149
|
+
*/
|
|
148
150
|
protected static optionsShape: {
|
|
149
151
|
headless: z.ZodOptional<z.ZodBoolean>;
|
|
150
152
|
launcher: z.ZodOptional<z.ZodCustom<Dictionary, Dictionary>>;
|
|
@@ -204,6 +206,7 @@ export declare class PlaywrightCrawler<ContextExtension = Dictionary<never>, Ext
|
|
|
204
206
|
statistics: z.ZodOptional<z.ZodCustom<Dictionary, Dictionary>>;
|
|
205
207
|
id: z.ZodOptional<z.ZodString>;
|
|
206
208
|
};
|
|
209
|
+
/** @internal */
|
|
207
210
|
protected static optionsSchema: z.ZodObject<{
|
|
208
211
|
headless: z.ZodOptional<z.ZodBoolean>;
|
|
209
212
|
launcher: z.ZodOptional<z.ZodCustom<Dictionary, Dictionary>>;
|
|
@@ -267,24 +270,7 @@ export declare class PlaywrightCrawler<ContextExtension = Dictionary<never>, Ext
|
|
|
267
270
|
* All `PlaywrightCrawler` parameters are passed via an options object.
|
|
268
271
|
*/
|
|
269
272
|
constructor(options?: PlaywrightCrawlerOptions<ContextExtension, ExtendedContext, Routes, StatisticStateExtension>);
|
|
270
|
-
|
|
271
|
-
protected buildContextPipeline(): import("@crawlee/browser").ContextPipeline<import("@crawlee/browser").CrawlingContext<Dictionary>, BrowserCrawlingContext<Page, Response, Dictionary, Dictionary> & {
|
|
272
|
-
injectFile: (filePath: string, options?: InjectFileOptions) => Promise<unknown>;
|
|
273
|
-
injectJQuery: () => Promise<void>;
|
|
274
|
-
blockRequests: (options?: BlockRequestsOptions) => Promise<void>;
|
|
275
|
-
waitForSelector: (selector: string, timeoutMs?: number) => Promise<void>;
|
|
276
|
-
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
277
|
-
parseWithCheerio: (selector?: string, timeoutMs?: number) => Promise<import("@crawlee/browser").CheerioAPI>;
|
|
278
|
-
infiniteScroll: (options?: InfiniteScrollOptions) => Promise<void>;
|
|
279
|
-
listDownloads: () => Promise<Download[]>;
|
|
280
|
-
saveSnapshot: (options?: SaveSnapshotOptions) => Promise<void>;
|
|
281
|
-
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
282
|
-
enqueueLinksByClickingElements: (options: Omit<EnqueueLinksByClickingElementsOptions, "page" | "requestManager">) => Promise<import("@crawlee/types").BatchAddRequestsResult>;
|
|
283
|
-
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
284
|
-
compileScript: (scriptString: string, ctx?: Dictionary) => import("./utils/playwright-utils.js").CompiledScriptFunction;
|
|
285
|
-
closeCookieModals: () => Promise<void>;
|
|
286
|
-
handleCloudflareChallenge: (options?: HandleCloudflareChallengeOptions) => Promise<Response | undefined>;
|
|
287
|
-
}>;
|
|
273
|
+
protected buildContextPipeline(): ContextPipeline<CrawlingContext, PlaywrightCrawlingContext>;
|
|
288
274
|
protected navigationHandler(crawlingContext: PlaywrightCrawlingContext, gotoOptions: DirectNavigationOptions): Promise<Response | null>;
|
|
289
275
|
private enhanceContext;
|
|
290
276
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { assertBrowserPoolNotConfigured, BrowserCrawler,
|
|
1
|
+
import { assertBrowserPoolNotConfigured, BrowserCrawler, RequestState, Router, serviceLocator } from '@crawlee/browser';
|
|
2
|
+
import { parseArgument, schemas } from '@crawlee/utils/internal';
|
|
2
3
|
import { z } from 'zod';
|
|
3
4
|
import { playwrightBrowserPool, remotePlaywrightBrowserPool } from './playwright-browser-pool.js';
|
|
4
5
|
import { gotoExtended, playwrightUtils } from './utils/playwright-utils.js';
|
|
@@ -68,11 +69,15 @@ import { gotoExtended, playwrightUtils } from './utils/playwright-utils.js';
|
|
|
68
69
|
* @category Crawlers
|
|
69
70
|
*/
|
|
70
71
|
export class PlaywrightCrawler extends BrowserCrawler {
|
|
72
|
+
/**
|
|
73
|
+
* @internal
|
|
74
|
+
*/
|
|
71
75
|
static optionsShape = {
|
|
72
76
|
...BrowserCrawler.optionsShape,
|
|
73
77
|
headless: z.boolean().optional(),
|
|
74
78
|
launcher: schemas.anyObject.optional(),
|
|
75
79
|
};
|
|
80
|
+
/** @internal */
|
|
76
81
|
static optionsSchema = z.strictObject(PlaywrightCrawler.optionsShape);
|
|
77
82
|
/**
|
|
78
83
|
* All `PlaywrightCrawler` parameters are passed via an options object.
|
|
@@ -72,6 +72,9 @@ export interface PlaywrightLaunchContext extends BrowserLaunchContext<LaunchOpti
|
|
|
72
72
|
*/
|
|
73
73
|
export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin> {
|
|
74
74
|
readonly configuration: Configuration;
|
|
75
|
+
/**
|
|
76
|
+
* @internal
|
|
77
|
+
*/
|
|
75
78
|
protected static optionsShape: {
|
|
76
79
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
77
80
|
launcher: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
@@ -87,6 +90,7 @@ export declare class PlaywrightLauncher extends BrowserLauncher<PlaywrightPlugin
|
|
|
87
90
|
launchOptions: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
88
91
|
userAgent: z.ZodOptional<z.ZodString>;
|
|
89
92
|
};
|
|
93
|
+
/** @internal */
|
|
90
94
|
protected static optionsSchema: z.ZodObject<{
|
|
91
95
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
92
96
|
launcher: z.ZodOptional<z.ZodCustom<import("@crawlee/types").Dictionary, import("@crawlee/types").Dictionary>>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { BrowserLauncher, Configuration
|
|
1
|
+
import { BrowserLauncher, Configuration } from '@crawlee/browser';
|
|
2
2
|
import { PlaywrightPlugin } from '@crawlee/browser-pool';
|
|
3
|
+
import { parseArgument, schemas } from '@crawlee/utils/internal';
|
|
3
4
|
import { z } from 'zod';
|
|
4
5
|
/**
|
|
5
6
|
* `PlaywrightLauncher` is based on the `BrowserLauncher`. It launches `playwright` browser instance.
|
|
@@ -7,12 +8,16 @@ import { z } from 'zod';
|
|
|
7
8
|
*/
|
|
8
9
|
export class PlaywrightLauncher extends BrowserLauncher {
|
|
9
10
|
configuration;
|
|
11
|
+
/**
|
|
12
|
+
* @internal
|
|
13
|
+
*/
|
|
10
14
|
static optionsShape = {
|
|
11
15
|
...BrowserLauncher.optionsShape,
|
|
12
16
|
// Passthrough schemas — the launcher module object must keep its prototype through parsing.
|
|
13
17
|
launcher: schemas.anyObject.optional(),
|
|
14
18
|
launchContextOptions: schemas.anyObject.optional(),
|
|
15
19
|
};
|
|
20
|
+
/** @internal */
|
|
16
21
|
static optionsSchema = z.strictObject(PlaywrightLauncher.optionsShape);
|
|
17
22
|
/**
|
|
18
23
|
* All `PlaywrightLauncher` parameters are passed via this launchContext object.
|
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
*/
|
|
20
20
|
import { Configuration, type Request } from '@crawlee/browser';
|
|
21
21
|
import type { BatchAddRequestsResult, Dictionary } from '@crawlee/types';
|
|
22
|
-
import {
|
|
22
|
+
import type { CheerioAPI } from 'cheerio';
|
|
23
23
|
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
24
24
|
import type { Download, Page, Response } from 'playwright';
|
|
25
25
|
import type { EnqueueLinksByClickingElementsOptions } from '../enqueue-links/click-elements.js';
|
|
@@ -287,7 +287,7 @@ export declare function saveSnapshot(page: Page, options?: SaveSnapshotOptions):
|
|
|
287
287
|
* @param page Playwright [`Page`](https://playwright.dev/docs/api/class-page) object.
|
|
288
288
|
* @param ignoreShadowRoots
|
|
289
289
|
*/
|
|
290
|
-
export declare function parseWithCheerio(page: Page, ignoreShadowRoots?: boolean, ignoreIframes?: boolean): Promise<
|
|
290
|
+
export declare function parseWithCheerio(page: Page, ignoreShadowRoots?: boolean, ignoreIframes?: boolean): Promise<CheerioAPI>;
|
|
291
291
|
export declare function closeCookieModals(page: Page): Promise<void>;
|
|
292
292
|
export interface HandleCloudflareChallengeOptions {
|
|
293
293
|
/** Logging defaults to the `debug` level, use this flag to log to `info` level instead. */
|
|
@@ -434,7 +434,7 @@ export interface PlaywrightContextUtils {
|
|
|
434
434
|
* });
|
|
435
435
|
* ```
|
|
436
436
|
*/
|
|
437
|
-
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<
|
|
437
|
+
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<CheerioAPI>;
|
|
438
438
|
/**
|
|
439
439
|
* Scrolls to the bottom of a page, or until it times out.
|
|
440
440
|
* Loads dynamic content when it hits the bottom of a page, and then continues scrolling.
|
|
@@ -20,8 +20,9 @@
|
|
|
20
20
|
import { readFile } from 'node:fs/promises';
|
|
21
21
|
import { createRequire } from 'node:module';
|
|
22
22
|
import vm from 'node:vm';
|
|
23
|
-
import { Configuration, KeyValueStore,
|
|
23
|
+
import { Configuration, KeyValueStore, serviceLocator, SessionError, validators } from '@crawlee/browser';
|
|
24
24
|
import { expandShadowRoots, sleep } from '@crawlee/utils';
|
|
25
|
+
import { parseArgument, schemas } from '@crawlee/utils/internal';
|
|
25
26
|
import { z } from 'zod';
|
|
26
27
|
import { LruCache } from '@apify/datastructures';
|
|
27
28
|
import { enqueueLinksByClickingElements } from '../enqueue-links/click-elements.js';
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/playwright",
|
|
3
|
-
"version": "4.0.0-beta.
|
|
3
|
+
"version": "4.0.0-beta.135",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=22.0.0"
|
|
@@ -49,13 +49,13 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/datastructures": "^2.0.3",
|
|
51
51
|
"@apify/timeout": "^0.4.4",
|
|
52
|
-
"@crawlee/basic": "4.0.0-beta.
|
|
53
|
-
"@crawlee/browser": "4.0.0-beta.
|
|
54
|
-
"@crawlee/browser-pool": "4.0.0-beta.
|
|
55
|
-
"@crawlee/cheerio": "4.0.0-beta.
|
|
56
|
-
"@crawlee/core": "4.0.0-beta.
|
|
57
|
-
"@crawlee/types": "4.0.0-beta.
|
|
58
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
52
|
+
"@crawlee/basic": "4.0.0-beta.135",
|
|
53
|
+
"@crawlee/browser": "4.0.0-beta.135",
|
|
54
|
+
"@crawlee/browser-pool": "4.0.0-beta.135",
|
|
55
|
+
"@crawlee/cheerio": "4.0.0-beta.135",
|
|
56
|
+
"@crawlee/core": "4.0.0-beta.135",
|
|
57
|
+
"@crawlee/types": "4.0.0-beta.135",
|
|
58
|
+
"@crawlee/utils": "4.0.0-beta.135",
|
|
59
59
|
"cheerio": "^1.0.0",
|
|
60
60
|
"jquery": "^3.7.1",
|
|
61
61
|
"ml-logistic-regression": "^2.0.0",
|
|
@@ -84,5 +84,5 @@
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
},
|
|
87
|
-
"gitHead": "
|
|
87
|
+
"gitHead": "ca0325880bbcc753d97506796e9bda3b35bca201"
|
|
88
88
|
}
|