@crawlee/playwright 4.0.0-beta.327 → 4.0.0-beta.328
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.
|
@@ -214,7 +214,7 @@ export class AdaptivePlaywrightCrawler extends BasicCrawler {
|
|
|
214
214
|
this.#individualRequestHandlerTimeoutMillis = requestHandlerTimeoutSecs * 1000;
|
|
215
215
|
// `renderingTypeDetectionRatio` only configures the default predictor - an injected one brings its own
|
|
216
216
|
// detection ratio (and its own state), so the option is ignored in that case.
|
|
217
|
-
this.#renderingTypePredictor = OwnedOrInjected.resolve(renderingTypePredictor, () => new RenderingTypePredictor({ detectionRatio: renderingTypeDetectionRatio }));
|
|
217
|
+
this.#renderingTypePredictor = OwnedOrInjected.resolve(renderingTypePredictor, () => new RenderingTypePredictor({ detectionRatio: renderingTypeDetectionRatio, id: options.id }));
|
|
218
218
|
this.#attemptWritePolicy = {
|
|
219
219
|
requestQueue: 'deferred',
|
|
220
220
|
...(typeof transactionalStorage === 'object' ? transactionalStorage : {}),
|
|
@@ -4,6 +4,12 @@ export type RenderingType = 'clientOnly' | 'static';
|
|
|
4
4
|
export interface RenderingTypePredictorOptions {
|
|
5
5
|
/** A number between 0 and 1 that determines the desired ratio of rendering type detections */
|
|
6
6
|
detectionRatio: number;
|
|
7
|
+
/**
|
|
8
|
+
* Unique identifier for this predictor instance. Used to generate a unique persistence key when
|
|
9
|
+
* `persistenceOptions.persistStateKey` is not provided. If not provided, an auto-incrementing ID is used.
|
|
10
|
+
* Explicit IDs share one namespace with the generated ones, so avoid explicit IDs like `'0'` or `'1'`.
|
|
11
|
+
*/
|
|
12
|
+
id?: string | number;
|
|
7
13
|
persistenceOptions?: Partial<RecoverableStatePersistenceOptions>;
|
|
8
14
|
}
|
|
9
15
|
/**
|
|
@@ -36,7 +42,9 @@ export interface IRenderingTypePredictor {
|
|
|
36
42
|
*/
|
|
37
43
|
export declare class RenderingTypePredictor implements IRenderingTypePredictor {
|
|
38
44
|
#private;
|
|
39
|
-
|
|
45
|
+
/** The identifier used in the default persistence key. */
|
|
46
|
+
readonly id: string;
|
|
47
|
+
constructor({ detectionRatio, id, persistenceOptions }: RenderingTypePredictorOptions);
|
|
40
48
|
/**
|
|
41
49
|
* Initialize the predictor by restoring persisted state.
|
|
42
50
|
*/
|
|
@@ -64,16 +64,20 @@ const stateCodec = z.codec(persistedState, predictorState, {
|
|
|
64
64
|
* Stores rendering type information for previously crawled URLs and predicts the rendering type for URLs that have yet to be crawled and recommends when rendering type detection should be performed.
|
|
65
65
|
*/
|
|
66
66
|
export class RenderingTypePredictor {
|
|
67
|
+
static #nextId = 0;
|
|
68
|
+
/** The identifier used in the default persistence key. */
|
|
69
|
+
id;
|
|
67
70
|
#detectionRatio;
|
|
68
71
|
#state;
|
|
69
|
-
constructor({ detectionRatio, persistenceOptions }) {
|
|
72
|
+
constructor({ detectionRatio, id, persistenceOptions }) {
|
|
73
|
+
this.id = id != null ? String(id) : String(RenderingTypePredictor.#nextId++);
|
|
70
74
|
this.#detectionRatio = detectionRatio;
|
|
71
75
|
this.#state = new RecoverableState({
|
|
72
76
|
defaultState: () => stateCodec.decode({}),
|
|
73
77
|
// The codec validates in the decode direction, so it is a Standard Schema as-is; encoding needs a call.
|
|
74
78
|
deserialize: stateCodec,
|
|
75
79
|
serialize: (state) => stateCodec.encode(state),
|
|
76
|
-
persistStateKey:
|
|
80
|
+
persistStateKey: `CRAWLEE_RENDERING_TYPE_PREDICTOR_STATE_${this.id}`,
|
|
77
81
|
persistenceEnabled: true,
|
|
78
82
|
...persistenceOptions,
|
|
79
83
|
});
|
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.328",
|
|
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.13.0"
|
|
@@ -49,14 +49,14 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/datastructures": "^3.0.1",
|
|
51
51
|
"@apify/timeout": "^1.1.0",
|
|
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/http-client": "4.0.0-beta.
|
|
58
|
-
"@crawlee/types": "4.0.0-beta.
|
|
59
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
52
|
+
"@crawlee/basic": "4.0.0-beta.328",
|
|
53
|
+
"@crawlee/browser": "4.0.0-beta.328",
|
|
54
|
+
"@crawlee/browser-pool": "4.0.0-beta.328",
|
|
55
|
+
"@crawlee/cheerio": "4.0.0-beta.328",
|
|
56
|
+
"@crawlee/core": "4.0.0-beta.328",
|
|
57
|
+
"@crawlee/http-client": "4.0.0-beta.328",
|
|
58
|
+
"@crawlee/types": "4.0.0-beta.328",
|
|
59
|
+
"@crawlee/utils": "4.0.0-beta.328",
|
|
60
60
|
"cheerio": "^1.2.0",
|
|
61
61
|
"domhandler": "^6.0.1",
|
|
62
62
|
"jquery": "^3.8.0",
|
|
@@ -81,5 +81,5 @@
|
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
},
|
|
84
|
-
"gitHead": "
|
|
84
|
+
"gitHead": "dfb2fb79cfb0e188e9118a0ec2be614a64732f0a"
|
|
85
85
|
}
|