@crawlee/jsdom 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.
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { AddRequestsBatchedResult, CrawlingContext, EnqueueLinksOptions, ErrorHandler, ExtractLinksOptions, GetUserDataFromRequest, HttpCrawlerOptions, InternalHttpCrawlingContext, InternalHttpHook, RequestHandler, RouterHandler, RouterRoutes, RouteSchemas, RoutesFromSchemas } from '@crawlee/http';
|
|
1
|
+
import type { AddRequestsBatchedResult, ContextPipeline, CrawlingContext, EnqueueLinksOptions, ErrorHandler, ExtractLinksOptions, GetUserDataFromRequest, HttpCrawlerOptions, InternalHttpCrawlingContext, InternalHttpHook, RequestHandler, RouterHandler, RouterRoutes, RouteSchemas, RoutesFromSchemas } from '@crawlee/http';
|
|
2
2
|
import { HttpCrawler } from '@crawlee/http';
|
|
3
3
|
import type { Dictionary } from '@crawlee/types';
|
|
4
|
-
import {
|
|
4
|
+
import type { CheerioAPI } from 'cheerio';
|
|
5
5
|
import type { DOMWindow } from 'jsdom';
|
|
6
6
|
import { VirtualConsole } from 'jsdom';
|
|
7
7
|
import { z } from 'zod';
|
|
@@ -53,7 +53,7 @@ JSONData extends Dictionary = any> extends InternalHttpCrawlingContext<UserData,
|
|
|
53
53
|
* });
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
|
-
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<
|
|
56
|
+
parseWithCheerio(selector?: string, timeoutMs?: number): Promise<CheerioAPI>;
|
|
57
57
|
/**
|
|
58
58
|
* Extracts URLs from the parsed DOM, without adding them to the request queue.
|
|
59
59
|
*/
|
|
@@ -67,6 +67,9 @@ export type JSDOMRequestHandler<UserData extends Dictionary = any, // with defau
|
|
|
67
67
|
JSONData extends Dictionary = any> = RequestHandler<JSDOMCrawlingContext<UserData, JSONData>>;
|
|
68
68
|
export declare class JSDOMCrawler<ContextExtension = Dictionary<never>, ExtendedContext extends JSDOMCrawlingContext = JSDOMCrawlingContext & ContextExtension, Routes extends Record<keyof Routes, Dictionary> = Record<string, GetUserDataFromRequest<JSDOMCrawlingContext['request']>>, StatisticStateExtension extends object = {}> extends HttpCrawler<JSDOMCrawlingContext, ContextExtension, ExtendedContext, Routes, StatisticStateExtension> {
|
|
69
69
|
#private;
|
|
70
|
+
/**
|
|
71
|
+
* @internal
|
|
72
|
+
*/
|
|
70
73
|
protected static optionsShape: {
|
|
71
74
|
runScripts: z.ZodOptional<z.ZodBoolean>;
|
|
72
75
|
hideInternalConsole: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -124,6 +127,7 @@ export declare class JSDOMCrawler<ContextExtension = Dictionary<never>, Extended
|
|
|
124
127
|
statistics: z.ZodOptional<z.ZodCustom<Dictionary, Dictionary>>;
|
|
125
128
|
id: z.ZodOptional<z.ZodString>;
|
|
126
129
|
};
|
|
130
|
+
/** @internal */
|
|
127
131
|
protected static optionsSchema: z.ZodObject<{
|
|
128
132
|
runScripts: z.ZodOptional<z.ZodBoolean>;
|
|
129
133
|
hideInternalConsole: z.ZodOptional<z.ZodBoolean>;
|
|
@@ -182,18 +186,7 @@ export declare class JSDOMCrawler<ContextExtension = Dictionary<never>, Extended
|
|
|
182
186
|
id: z.ZodOptional<z.ZodString>;
|
|
183
187
|
}, z.core.$strict>;
|
|
184
188
|
constructor(options?: JSDOMCrawlerOptions<ContextExtension, ExtendedContext, any, any, Routes, StatisticStateExtension>);
|
|
185
|
-
|
|
186
|
-
protected buildContextPipeline(): import("@crawlee/http").ContextPipeline<CrawlingContext<Dictionary>, InternalHttpCrawlingContext<any, any> & {
|
|
187
|
-
readonly window: DOMWindow;
|
|
188
|
-
readonly body: string;
|
|
189
|
-
readonly document: Document;
|
|
190
|
-
} & {
|
|
191
|
-
extractLinks: (options?: ExtractLinksOptions) => Promise<string[]>;
|
|
192
|
-
enqueueLinks: (options?: EnqueueLinksOptions) => Promise<AddRequestsBatchedResult>;
|
|
193
|
-
waitForSelector(selector: string, timeoutMs?: number): Promise<void>;
|
|
194
|
-
// @ts-ignore optional peer dependency or compatibility with es2022
|
|
195
|
-
parseWithCheerio(selector?: string, _timeoutMs?: number): Promise<import("cheerio").CheerioAPI>;
|
|
196
|
-
}>;
|
|
189
|
+
protected buildContextPipeline(): ContextPipeline<CrawlingContext, JSDOMCrawlingContext>;
|
|
197
190
|
/**
|
|
198
191
|
* Returns the currently used `VirtualConsole` instance. Can be used to listen for the JSDOM's internal console messages.
|
|
199
192
|
*
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import { EnqueueStrategy, HttpCrawler, NavigationSkippedError,
|
|
1
|
+
import { EnqueueStrategy, HttpCrawler, NavigationSkippedError, resolveBaseUrlForEnqueueLinksFiltering, Router, } from '@crawlee/http';
|
|
2
2
|
import { sleep } from '@crawlee/utils';
|
|
3
|
+
import { parseArgument, tryAbsoluteURL } from '@crawlee/utils/internal';
|
|
3
4
|
import { JSDOM, ResourceLoader, VirtualConsole } from 'jsdom';
|
|
4
5
|
import { z } from 'zod';
|
|
5
6
|
import { addTimeoutToPromise } from '@apify/timeout';
|
|
@@ -84,11 +85,15 @@ const resources = new ResourceLoader({
|
|
|
84
85
|
userAgent: 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/107.0.0.0 Safari/537.36',
|
|
85
86
|
});
|
|
86
87
|
export class JSDOMCrawler extends HttpCrawler {
|
|
88
|
+
/**
|
|
89
|
+
* @internal
|
|
90
|
+
*/
|
|
87
91
|
static optionsShape = {
|
|
88
92
|
...HttpCrawler.optionsShape,
|
|
89
93
|
runScripts: z.boolean().optional(),
|
|
90
94
|
hideInternalConsole: z.boolean().optional(),
|
|
91
95
|
};
|
|
96
|
+
/** @internal */
|
|
92
97
|
static optionsSchema = z.strictObject(JSDOMCrawler.optionsShape);
|
|
93
98
|
#runScripts;
|
|
94
99
|
#hideInternalConsole;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/jsdom",
|
|
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,9 +49,9 @@
|
|
|
49
49
|
"dependencies": {
|
|
50
50
|
"@apify/timeout": "^0.4.4",
|
|
51
51
|
"@apify/utilities": "^2.7.10",
|
|
52
|
-
"@crawlee/http": "4.0.0-beta.
|
|
53
|
-
"@crawlee/types": "4.0.0-beta.
|
|
54
|
-
"@crawlee/utils": "4.0.0-beta.
|
|
52
|
+
"@crawlee/http": "4.0.0-beta.135",
|
|
53
|
+
"@crawlee/types": "4.0.0-beta.135",
|
|
54
|
+
"@crawlee/utils": "4.0.0-beta.135",
|
|
55
55
|
"@types/jsdom": "^21.1.7",
|
|
56
56
|
"cheerio": "^1.0.0",
|
|
57
57
|
"jsdom": "^26.1.0",
|
|
@@ -65,5 +65,5 @@
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
},
|
|
68
|
-
"gitHead": "
|
|
68
|
+
"gitHead": "ca0325880bbcc753d97506796e9bda3b35bca201"
|
|
69
69
|
}
|