@xberg-io/crawlberg 0.0.1 → 1.0.0-rc.1
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/LICENSE +21 -0
- package/README.md +167 -2
- package/index.d.ts +1079 -0
- package/index.js +624 -2
- package/package.json +58 -6
package/index.d.ts
ADDED
|
@@ -0,0 +1,1079 @@
|
|
|
1
|
+
/* auto-generated by NAPI-RS */
|
|
2
|
+
/* eslint-disable */
|
|
3
|
+
/**
|
|
4
|
+
* This type implements JavaScript's async iterable protocol.
|
|
5
|
+
* It can be used with `for await...of` loops.
|
|
6
|
+
*
|
|
7
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
|
|
8
|
+
*/
|
|
9
|
+
export declare class BatchCrawlStreamIterator {
|
|
10
|
+
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* Opaque handle to a configured crawl engine.
|
|
15
|
+
*
|
|
16
|
+
* Constructed via `create_engine` with an optional `CrawlConfig`.
|
|
17
|
+
* Default implementations for all pluggable components are used internally.
|
|
18
|
+
*/
|
|
19
|
+
export declare class CrawlEngineHandle {
|
|
20
|
+
/**
|
|
21
|
+
* Stream a single-URL crawl, yielding `CrawlEvent`s as pages are processed.
|
|
22
|
+
*
|
|
23
|
+
* Returns an async stream that emits one event per crawled page, plus a
|
|
24
|
+
* terminal `Complete` event. On per-URL failure during the crawl, emits an
|
|
25
|
+
* `Error` event followed by `Complete`. The stream item type is wrapped in
|
|
26
|
+
* a `Result` to surface transport-level errors; today every emit is `Ok`.
|
|
27
|
+
*
|
|
28
|
+
* Language bindings expose this as the native streaming shape for each
|
|
29
|
+
* target. WASM does not expose native streaming wrappers.
|
|
30
|
+
*/
|
|
31
|
+
crawlStream(req: CrawlStreamRequest): Promise<CrawlStreamIterator>
|
|
32
|
+
/**
|
|
33
|
+
* Stream a multi-URL crawl, yielding `CrawlEvent`s across all seeds.
|
|
34
|
+
*
|
|
35
|
+
* Returns an async stream that emits one event per crawled page across all
|
|
36
|
+
* seeds, plus terminal `Complete` and `Error` events as appropriate. The
|
|
37
|
+
* stream item type is wrapped in a `Result` to surface transport-level
|
|
38
|
+
* errors; today every emit is `Ok`.
|
|
39
|
+
*
|
|
40
|
+
* Language bindings expose this as the native streaming shape for each
|
|
41
|
+
* target. WASM does not expose native streaming wrappers.
|
|
42
|
+
*/
|
|
43
|
+
batchCrawlStream(req: BatchCrawlStreamRequest): Promise<BatchCrawlStreamIterator>
|
|
44
|
+
}
|
|
45
|
+
export type JsCrawlEngineHandle = CrawlEngineHandle
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* This type implements JavaScript's async iterable protocol.
|
|
49
|
+
* It can be used with `for await...of` loops.
|
|
50
|
+
*
|
|
51
|
+
* @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols#the_async_iterator_and_async_iterable_protocols
|
|
52
|
+
*/
|
|
53
|
+
export declare class CrawlStreamIterator {
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
/** Result from a single page action execution. */
|
|
58
|
+
export interface ActionResult {
|
|
59
|
+
/** Zero-based index of the action in the sequence. */
|
|
60
|
+
actionIndex?: number
|
|
61
|
+
/** The type of action that was executed. */
|
|
62
|
+
actionType?: string
|
|
63
|
+
/** Whether the action completed successfully. */
|
|
64
|
+
success?: boolean
|
|
65
|
+
/** Action-specific return data (screenshot bytes, JS return value, scraped HTML). */
|
|
66
|
+
data?: any
|
|
67
|
+
/** Error message if the action failed. */
|
|
68
|
+
error?: string
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Article metadata extracted from `article:*` Open Graph tags. */
|
|
72
|
+
export interface ArticleMetadata {
|
|
73
|
+
/** The article publication time. */
|
|
74
|
+
publishedTime?: string
|
|
75
|
+
/** The article modification time. */
|
|
76
|
+
modifiedTime?: string
|
|
77
|
+
/** The article author. */
|
|
78
|
+
author?: string
|
|
79
|
+
/** The article section. */
|
|
80
|
+
section?: string
|
|
81
|
+
/** The article tags. */
|
|
82
|
+
tags?: Array<string>
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** The category of a downloaded asset. */
|
|
86
|
+
export declare const enum AssetCategory {
|
|
87
|
+
/** A document file (PDF, DOC, etc.). */
|
|
88
|
+
Document = 'document',
|
|
89
|
+
/** An image file. */
|
|
90
|
+
Image = 'image',
|
|
91
|
+
/** An audio file. */
|
|
92
|
+
Audio = 'audio',
|
|
93
|
+
/** A video file. */
|
|
94
|
+
Video = 'video',
|
|
95
|
+
/** A font file. */
|
|
96
|
+
Font = 'font',
|
|
97
|
+
/** A CSS stylesheet. */
|
|
98
|
+
Stylesheet = 'stylesheet',
|
|
99
|
+
/** A JavaScript file. */
|
|
100
|
+
Script = 'script',
|
|
101
|
+
/** An archive file (ZIP, TAR, etc.). */
|
|
102
|
+
Archive = 'archive',
|
|
103
|
+
/** A data file (JSON, XML, CSV, etc.). */
|
|
104
|
+
Data = 'data',
|
|
105
|
+
/** An unrecognized asset type. */
|
|
106
|
+
Other = 'other'
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
/** Authentication configuration. */
|
|
110
|
+
export interface AuthConfig {
|
|
111
|
+
type: string
|
|
112
|
+
username?: string
|
|
113
|
+
password?: string
|
|
114
|
+
token?: string
|
|
115
|
+
name?: string
|
|
116
|
+
value?: string
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
/** Crawl multiple seed URLs concurrently, each following links to configured depth. */
|
|
120
|
+
export declare function batchCrawl(engine: CrawlEngineHandle, urls: Array<string>): Promise<BatchCrawlResults>
|
|
121
|
+
|
|
122
|
+
/** Result from a single URL in a batch crawl operation. */
|
|
123
|
+
export interface BatchCrawlResult {
|
|
124
|
+
/** The seed URL that was crawled. */
|
|
125
|
+
url?: string
|
|
126
|
+
/** The crawl result, if successful. */
|
|
127
|
+
result?: CrawlResult
|
|
128
|
+
/** The error message, if the crawl failed. */
|
|
129
|
+
error?: string
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Aggregate result of a batch crawl, exposing per-URL results plus precomputed counts.
|
|
134
|
+
*
|
|
135
|
+
* The counts are derived once at construction so every binding language can read them
|
|
136
|
+
* as plain integer fields without re-iterating the `results` vector.
|
|
137
|
+
*/
|
|
138
|
+
export interface BatchCrawlResults {
|
|
139
|
+
/** Per-URL crawl results, in the order seed URLs were submitted. */
|
|
140
|
+
results?: Array<BatchCrawlResult>
|
|
141
|
+
/** Total number of seed URLs in the batch (equal to `results.len()`). */
|
|
142
|
+
totalCount?: number
|
|
143
|
+
/** Number of seed URLs whose crawl succeeded (`error` is `None`). */
|
|
144
|
+
completedCount?: number
|
|
145
|
+
/** Number of seed URLs whose crawl failed (`error` is `Some`). */
|
|
146
|
+
failedCount?: number
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
export declare function batchCrawlStream(engine: CrawlEngineHandle, urls: Array<string>): Promise<BatchCrawlStreamIterator>
|
|
150
|
+
|
|
151
|
+
/**
|
|
152
|
+
* Request to begin a multi-URL streaming crawl.
|
|
153
|
+
*
|
|
154
|
+
* Wraps a set of seed URLs for delivery through the streaming-adapter binding
|
|
155
|
+
* surface. Required as a struct because alef's streaming adapter requires a
|
|
156
|
+
* named request type — primitives are not supported.
|
|
157
|
+
*/
|
|
158
|
+
export interface BatchCrawlStreamRequest {
|
|
159
|
+
/**
|
|
160
|
+
* The seed URLs to crawl. Each URL is followed independently up to the
|
|
161
|
+
* engine's configured depth.
|
|
162
|
+
*/
|
|
163
|
+
urls?: Array<string>
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
/** Scrape multiple URLs concurrently. */
|
|
167
|
+
export declare function batchScrape(engine: CrawlEngineHandle, urls: Array<string>): Promise<BatchScrapeResults>
|
|
168
|
+
|
|
169
|
+
/** Result from a single URL in a batch scrape operation. */
|
|
170
|
+
export interface BatchScrapeResult {
|
|
171
|
+
/** The URL that was scraped. */
|
|
172
|
+
url?: string
|
|
173
|
+
/** The scrape result, if successful. */
|
|
174
|
+
result?: ScrapeResult
|
|
175
|
+
/** The error message, if the scrape failed. */
|
|
176
|
+
error?: string
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
/**
|
|
180
|
+
* Aggregate result of a batch scrape, exposing per-URL results plus precomputed counts.
|
|
181
|
+
*
|
|
182
|
+
* The counts are derived once at construction so every binding language can read them
|
|
183
|
+
* as plain integer fields without re-iterating the `results` vector.
|
|
184
|
+
*/
|
|
185
|
+
export interface BatchScrapeResults {
|
|
186
|
+
/** Per-URL scrape results, in the order URLs were submitted. */
|
|
187
|
+
results?: Array<BatchScrapeResult>
|
|
188
|
+
/** Total number of URLs in the batch (equal to `results.len()`). */
|
|
189
|
+
totalCount?: number
|
|
190
|
+
/** Number of URLs whose scrape succeeded (`error` is `None`). */
|
|
191
|
+
completedCount?: number
|
|
192
|
+
/** Number of URLs whose scrape failed (`error` is `Some`). */
|
|
193
|
+
failedCount?: number
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/** Browser backend used for JavaScript rendering. */
|
|
197
|
+
export declare const enum BrowserBackend {
|
|
198
|
+
/** Existing Chromium/CDP backend powered by chromiumoxide. */
|
|
199
|
+
Chromiumoxide = 'chromiumoxide',
|
|
200
|
+
/** Crawlberg-owned native browser backend derived from Obscura. */
|
|
201
|
+
Native = 'native'
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
/** Browser fallback configuration. */
|
|
205
|
+
export interface BrowserConfig {
|
|
206
|
+
/** When to use the headless browser fallback. */
|
|
207
|
+
mode?: JsBrowserMode
|
|
208
|
+
/** Browser backend used to render JavaScript-heavy pages. */
|
|
209
|
+
backend?: JsBrowserBackend
|
|
210
|
+
/** CDP WebSocket endpoint for connecting to an external browser instance. */
|
|
211
|
+
endpoint?: string
|
|
212
|
+
/** Timeout for browser page load and rendering (in milliseconds when serialized). */
|
|
213
|
+
timeout?: number
|
|
214
|
+
/** Wait strategy after browser navigation. */
|
|
215
|
+
wait?: JsBrowserWait
|
|
216
|
+
/** CSS selector to wait for when `wait` is `Selector`. */
|
|
217
|
+
waitSelector?: string
|
|
218
|
+
/** Extra time to wait after the wait condition is met. */
|
|
219
|
+
extraWait?: number
|
|
220
|
+
/**
|
|
221
|
+
* Proxy for browser fetches. Overrides `CrawlConfig.proxy` when set.
|
|
222
|
+
* Native backend supports http/https only (no SOCKS5).
|
|
223
|
+
*/
|
|
224
|
+
proxy?: ProxyConfig
|
|
225
|
+
/**
|
|
226
|
+
* URL patterns to block before the network request fires. Supports `*`
|
|
227
|
+
* wildcards. Useful for skipping ads/analytics/large images. Honored by
|
|
228
|
+
* `BrowserBackend.Native`; chromiumoxide ignores this field today.
|
|
229
|
+
*/
|
|
230
|
+
blockUrlPatterns?: Array<string>
|
|
231
|
+
/**
|
|
232
|
+
* JavaScript snippet evaluated after navigation completes.
|
|
233
|
+
*
|
|
234
|
+
* Scraping captures the native backend result in `ScrapeResult.browser.eval_result`.
|
|
235
|
+
* Interactions run this script before page actions on both browser backends but do
|
|
236
|
+
* not include the script result in `InteractionResult`.
|
|
237
|
+
*/
|
|
238
|
+
evalScript?: string
|
|
239
|
+
/**
|
|
240
|
+
* User-agent used when fetching robots.txt. Defaults to `BrowserConfig.user_agent`
|
|
241
|
+
* (or crawlberg's default) if unset. Native only.
|
|
242
|
+
*/
|
|
243
|
+
robotsUserAgent?: string
|
|
244
|
+
/**
|
|
245
|
+
* Capture the full network event stream into the result. Default false
|
|
246
|
+
* (only the document event is captured). Native only.
|
|
247
|
+
*/
|
|
248
|
+
captureNetworkEvents?: boolean
|
|
249
|
+
/**
|
|
250
|
+
* Enable session affinity: reuse chromiumoxide Pages for same-domain
|
|
251
|
+
* requests so cookies + fingerprint + solved challenges persist.
|
|
252
|
+
* Default: true. When false, each request gets a fresh Page.
|
|
253
|
+
*/
|
|
254
|
+
sessionAffinity?: boolean
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
export declare function browserConfigDefault(): BrowserConfig
|
|
258
|
+
|
|
259
|
+
/**
|
|
260
|
+
* Browser-specific extras populated when the native browser backend was used.
|
|
261
|
+
*
|
|
262
|
+
* Available on `ScrapeResult.browser` when `BrowserBackend.Native` handled the request.
|
|
263
|
+
*/
|
|
264
|
+
export interface BrowserExtras {
|
|
265
|
+
/** Return value of `BrowserConfig.eval_script`, if provided. */
|
|
266
|
+
evalResult?: any
|
|
267
|
+
/**
|
|
268
|
+
* Network events captured during page navigation (only populated when
|
|
269
|
+
* `BrowserConfig.capture_network_events` is true).
|
|
270
|
+
*/
|
|
271
|
+
networkEvents?: Array<JsResponseMeta>
|
|
272
|
+
/**
|
|
273
|
+
* All non-expired cookies present in the browser's cookie jar after
|
|
274
|
+
* navigation completes (includes both prior cookies and server Set-Cookie).
|
|
275
|
+
*/
|
|
276
|
+
cookies?: Array<JsCookieInfo>
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
/** When to use the headless browser fallback. */
|
|
280
|
+
export declare const enum BrowserMode {
|
|
281
|
+
/** Automatically detect when JS rendering is needed and fall back to browser. */
|
|
282
|
+
Auto = 'auto',
|
|
283
|
+
/** Always use the browser for every request. */
|
|
284
|
+
Always = 'always',
|
|
285
|
+
/** Never use the browser fallback. */
|
|
286
|
+
Never = 'never',
|
|
287
|
+
/**
|
|
288
|
+
* Always use the browser with all stealth surfaces enabled.
|
|
289
|
+
*
|
|
290
|
+
* Behaves like `Always` for escalation purposes
|
|
291
|
+
* (every request is routed through the browser tier), but additionally
|
|
292
|
+
* enables:
|
|
293
|
+
*
|
|
294
|
+
* - browser JavaScript stealth patches
|
|
295
|
+
* - native-backend TLS fingerprint spoofing
|
|
296
|
+
* - stealth-aware default user-agent when no explicit UA is set
|
|
297
|
+
* - 1920×1080 viewport override
|
|
298
|
+
*
|
|
299
|
+
* Use this instead of setting the now-removed `BrowserConfig.stealth`
|
|
300
|
+
* boolean field.
|
|
301
|
+
*/
|
|
302
|
+
Stealth = 'stealth'
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
/** Wait strategy for browser page rendering. */
|
|
306
|
+
export declare const enum BrowserWait {
|
|
307
|
+
/** Wait until network activity is idle. */
|
|
308
|
+
NetworkIdle = 'network_idle',
|
|
309
|
+
/** Wait for a specific CSS selector to appear in the DOM. */
|
|
310
|
+
Selector = 'selector',
|
|
311
|
+
/** Wait for a fixed duration after navigation. */
|
|
312
|
+
Fixed = 'fixed'
|
|
313
|
+
}
|
|
314
|
+
|
|
315
|
+
/**
|
|
316
|
+
* A single numbered reference in a citation list — produced by the citation
|
|
317
|
+
* extractor when content uses inline `[N]`-style markers.
|
|
318
|
+
*/
|
|
319
|
+
export interface CitationReference {
|
|
320
|
+
/** 1-based reference number as it appears in the source text. */
|
|
321
|
+
index?: number
|
|
322
|
+
/** Resolved absolute URL for this reference. */
|
|
323
|
+
url?: string
|
|
324
|
+
/** Human-readable anchor text or title for the reference. */
|
|
325
|
+
text?: string
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/** Result of citation conversion. */
|
|
329
|
+
export interface CitationResult {
|
|
330
|
+
/** Markdown with links replaced by numbered citations. */
|
|
331
|
+
content?: string
|
|
332
|
+
/** Numbered reference list: (index, url, text). */
|
|
333
|
+
references?: Array<JsCitationReference>
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* Content extraction and conversion configuration.
|
|
338
|
+
*
|
|
339
|
+
* Controls how HTML is converted to the output format. Uses
|
|
340
|
+
* html-to-markdown-rs as the conversion engine for all formats
|
|
341
|
+
* (markdown, plain text, djot).
|
|
342
|
+
*/
|
|
343
|
+
export interface ContentConfig {
|
|
344
|
+
/** Output format: `"markdown"` (default), `"plain"`, `"djot"`. */
|
|
345
|
+
outputFormat?: string
|
|
346
|
+
/**
|
|
347
|
+
* Preprocessing aggressiveness: `"minimal"`, `"standard"` (default), `"aggressive"`.
|
|
348
|
+
*
|
|
349
|
+
* - Minimal: only scripts/styles removed.
|
|
350
|
+
* - Standard: also removes nav, nav-hinted headers/footers/asides, forms.
|
|
351
|
+
* - Aggressive: removes all footers/asides unconditionally.
|
|
352
|
+
*/
|
|
353
|
+
preprocessingPreset?: string
|
|
354
|
+
/** Remove navigation elements (nav, breadcrumbs, menus). Default: `true`. */
|
|
355
|
+
removeNavigation?: boolean
|
|
356
|
+
/** Remove form elements. Default: `true`. */
|
|
357
|
+
removeForms?: boolean
|
|
358
|
+
/**
|
|
359
|
+
* HTML tag names to strip (render children only, remove the tag wrapper).
|
|
360
|
+
* Default: `["noscript"]`.
|
|
361
|
+
*/
|
|
362
|
+
stripTags?: Array<string>
|
|
363
|
+
/** HTML tag names to preserve as raw HTML in output. */
|
|
364
|
+
preserveTags?: Array<string>
|
|
365
|
+
/**
|
|
366
|
+
* CSS selectors for elements to exclude entirely (element + all content).
|
|
367
|
+
*
|
|
368
|
+
* Unlike `strip_tags` (which removes the wrapper but keeps children),
|
|
369
|
+
* excluded elements and all descendants are dropped. Supports CSS selectors:
|
|
370
|
+
* `.class`, `#id`, `[attribute]`, compound selectors.
|
|
371
|
+
*
|
|
372
|
+
* Example: `[".cookie-banner", "#ad-container", "[role='complementary']"]`
|
|
373
|
+
*/
|
|
374
|
+
excludeSelectors?: Array<string>
|
|
375
|
+
/** Skip image elements in output. Default: `false`. */
|
|
376
|
+
skipImages?: boolean
|
|
377
|
+
/** Max DOM traversal depth. Prevents stack overflow on deeply nested HTML. */
|
|
378
|
+
maxDepth?: number
|
|
379
|
+
/** Enable line wrapping. Default: `false`. */
|
|
380
|
+
wrap?: boolean
|
|
381
|
+
/** Wrap width when `wrap` is enabled. Default: `80`. */
|
|
382
|
+
wrapWidth?: number
|
|
383
|
+
/** Include document structure tree in output. Default: `true`. */
|
|
384
|
+
includeDocumentStructure?: boolean
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
export declare function contentConfigDefault(): ContentConfig
|
|
388
|
+
|
|
389
|
+
/** Information about an HTTP cookie received from a response. */
|
|
390
|
+
export interface CookieInfo {
|
|
391
|
+
/** The cookie name. */
|
|
392
|
+
name?: string
|
|
393
|
+
/** The cookie value. */
|
|
394
|
+
value?: string
|
|
395
|
+
/** The cookie domain, if specified. */
|
|
396
|
+
domain?: string
|
|
397
|
+
/** The cookie path, if specified. */
|
|
398
|
+
path?: string
|
|
399
|
+
}
|
|
400
|
+
|
|
401
|
+
/** Crawl a website starting from `url`, following links up to the configured depth. */
|
|
402
|
+
export declare function crawl(engine: CrawlEngineHandle, url: string): Promise<CrawlResult>
|
|
403
|
+
|
|
404
|
+
/** Configuration for crawl, scrape, and map operations. */
|
|
405
|
+
export interface CrawlConfig {
|
|
406
|
+
/** Maximum crawl depth (number of link hops from the start URL). */
|
|
407
|
+
maxDepth?: number
|
|
408
|
+
/** Maximum number of pages to crawl. */
|
|
409
|
+
maxPages?: number
|
|
410
|
+
/** Maximum number of concurrent requests. */
|
|
411
|
+
maxConcurrent?: number
|
|
412
|
+
/** Whether to respect robots.txt directives. */
|
|
413
|
+
respectRobotsTxt?: boolean
|
|
414
|
+
/**
|
|
415
|
+
* When true, HTTP-level error responses (404 NotFound, 403 Forbidden, WAF blocks)
|
|
416
|
+
* are surfaced as `ScrapeResult` records with the matching `status_code` rather
|
|
417
|
+
* than raised as `CrawlError`. Default `false` preserves the historical
|
|
418
|
+
* throw-on-error contract for direct fetches. Independently of this flag,
|
|
419
|
+
* 404s reached at the end of a redirect chain are *always* surfaced softly —
|
|
420
|
+
* the user opted into redirect-following, so receiving a 404 there is part of
|
|
421
|
+
* the normal flow rather than an unexpected error.
|
|
422
|
+
*/
|
|
423
|
+
softHttpErrors?: boolean
|
|
424
|
+
/** Custom user-agent string. */
|
|
425
|
+
userAgent?: string
|
|
426
|
+
/** Whether to restrict crawling to the same domain. */
|
|
427
|
+
stayOnDomain?: boolean
|
|
428
|
+
/** Whether to allow subdomains when `stay_on_domain` is true. */
|
|
429
|
+
allowSubdomains?: boolean
|
|
430
|
+
/** Regex patterns for paths to include during crawling. */
|
|
431
|
+
includePaths?: Array<string>
|
|
432
|
+
/** Regex patterns for paths to exclude during crawling. */
|
|
433
|
+
excludePaths?: Array<string>
|
|
434
|
+
/** Custom HTTP headers to send with each request. */
|
|
435
|
+
customHeaders?: Record<string, string>
|
|
436
|
+
/** Timeout for individual HTTP requests (in milliseconds when serialized). */
|
|
437
|
+
requestTimeout?: number
|
|
438
|
+
/**
|
|
439
|
+
* Per-domain rate limit in milliseconds. When set, enforces a minimum delay
|
|
440
|
+
* between requests to the same domain. Defaults to 200ms when `None`.
|
|
441
|
+
*/
|
|
442
|
+
rateLimitMs?: number
|
|
443
|
+
/** Maximum number of redirects to follow. */
|
|
444
|
+
maxRedirects?: number
|
|
445
|
+
/** Number of retry attempts for failed requests. */
|
|
446
|
+
retryCount?: number
|
|
447
|
+
/** HTTP status codes that should trigger a retry. */
|
|
448
|
+
retryCodes?: Array<number>
|
|
449
|
+
/** Whether to enable cookie handling. */
|
|
450
|
+
cookiesEnabled?: boolean
|
|
451
|
+
/** Authentication configuration. */
|
|
452
|
+
auth?: JsAuthConfig
|
|
453
|
+
/** Maximum response body size in bytes. */
|
|
454
|
+
maxBodySize?: number
|
|
455
|
+
/** CSS selectors for tags to remove from HTML before processing. */
|
|
456
|
+
removeTags?: Array<string>
|
|
457
|
+
/** Content extraction and conversion configuration. */
|
|
458
|
+
content?: ContentConfig
|
|
459
|
+
/** Maximum number of URLs to return from a map operation. */
|
|
460
|
+
mapLimit?: number
|
|
461
|
+
/** Search filter for map results (case-insensitive substring match on URLs). */
|
|
462
|
+
mapSearch?: string
|
|
463
|
+
/** Whether to download assets (CSS, JS, images, etc.) from the page. */
|
|
464
|
+
downloadAssets?: boolean
|
|
465
|
+
/** Filter for asset categories to download. */
|
|
466
|
+
assetTypes?: Array<JsAssetCategory>
|
|
467
|
+
/** Maximum size in bytes for individual asset downloads. */
|
|
468
|
+
maxAssetSize?: number
|
|
469
|
+
/** Browser configuration. */
|
|
470
|
+
browser?: BrowserConfig
|
|
471
|
+
/** Proxy configuration for HTTP requests. */
|
|
472
|
+
proxy?: ProxyConfig
|
|
473
|
+
/** List of user-agent strings for rotation. If non-empty, overrides `user_agent`. */
|
|
474
|
+
userAgents?: Array<string>
|
|
475
|
+
/** Whether to capture a screenshot when using the browser. */
|
|
476
|
+
captureScreenshot?: boolean
|
|
477
|
+
/**
|
|
478
|
+
* Re-enqueue discovered `LinkType.Document` URLs into the crawl frontier so
|
|
479
|
+
* the crawl follows links *from* document pages (PDFs, etc.) as it would
|
|
480
|
+
* from HTML pages. Default: `false` (documents terminate at materialisation).
|
|
481
|
+
*/
|
|
482
|
+
followDocumentUrls?: boolean
|
|
483
|
+
/**
|
|
484
|
+
* Maximum document-depth (from the seed URL through document links only)
|
|
485
|
+
* when `follow_document_urls` is true. `None` means inherit `max_depth`.
|
|
486
|
+
* Independent of `max_depth`: a document URL is enqueued only if BOTH the
|
|
487
|
+
* outer `max_depth` and (if set) `document_url_depth` permit it.
|
|
488
|
+
*/
|
|
489
|
+
documentUrlDepth?: number
|
|
490
|
+
/** Whether to download non-HTML documents (PDF, DOCX, images, code, etc.) instead of skipping them. */
|
|
491
|
+
downloadDocuments?: boolean
|
|
492
|
+
/** Maximum size in bytes for document downloads. Defaults to 50 MB. */
|
|
493
|
+
documentMaxSize?: number
|
|
494
|
+
/** Allowlist of MIME types to download. If empty, uses built-in defaults. */
|
|
495
|
+
documentMimeTypes?: Array<string>
|
|
496
|
+
/** Path to write WARC output. If `None`, WARC output is disabled. */
|
|
497
|
+
warcOutput?: string
|
|
498
|
+
/** Named browser profile for persistent sessions (cookies, localStorage). */
|
|
499
|
+
browserProfile?: string
|
|
500
|
+
/** Whether to save changes back to the browser profile on exit. */
|
|
501
|
+
saveBrowserProfile?: boolean
|
|
502
|
+
/**
|
|
503
|
+
* SSRF policy for outbound network requests. Default: deny private networks,
|
|
504
|
+
* allow http/https only, max 5 redirects.
|
|
505
|
+
*
|
|
506
|
+
* Phase 1: `deny_private` and `max_redirects` are exposed to all language
|
|
507
|
+
* bindings. `allowlist` is skipped (see `SsrfPolicy` fields) and will be
|
|
508
|
+
* added in a follow-up when `HostMatcher`'s tagged-enum FFI form is decided.
|
|
509
|
+
*/
|
|
510
|
+
ssrf?: JsSsrfPolicy
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
export declare function crawlConfigDefault(): CrawlConfig
|
|
514
|
+
|
|
515
|
+
/**
|
|
516
|
+
* An event emitted during a streaming crawl operation.
|
|
517
|
+
*
|
|
518
|
+
* Not available on `wasm32` targets — streaming requires native concurrency
|
|
519
|
+
* primitives (tokio channels, `JoinSet`) that are not supported on wasm32.
|
|
520
|
+
*
|
|
521
|
+
* Delivered to bindings through each target's native streaming idiom.
|
|
522
|
+
*/
|
|
523
|
+
export interface CrawlEvent {
|
|
524
|
+
type: string
|
|
525
|
+
result?: CrawlPageResult
|
|
526
|
+
url?: string
|
|
527
|
+
error?: string
|
|
528
|
+
pagesCrawled?: number
|
|
529
|
+
}
|
|
530
|
+
|
|
531
|
+
/** The result of crawling a single page during a crawl operation. */
|
|
532
|
+
export interface CrawlPageResult {
|
|
533
|
+
/** The original URL of the page. */
|
|
534
|
+
url?: string
|
|
535
|
+
/** The normalized URL of the page. */
|
|
536
|
+
normalizedUrl?: string
|
|
537
|
+
/** The HTTP status code of the response. */
|
|
538
|
+
statusCode?: number
|
|
539
|
+
/** The Content-Type header value. */
|
|
540
|
+
contentType?: string
|
|
541
|
+
/** The HTML body of the response. */
|
|
542
|
+
html?: string
|
|
543
|
+
/** The size of the response body in bytes. */
|
|
544
|
+
bodySize?: number
|
|
545
|
+
/** Extracted metadata from the page. */
|
|
546
|
+
metadata?: JsPageMetadata
|
|
547
|
+
/** Links found on the page. */
|
|
548
|
+
links?: Array<JsLinkInfo>
|
|
549
|
+
/** Images found on the page. */
|
|
550
|
+
images?: Array<JsImageInfo>
|
|
551
|
+
/** Feed links found on the page. */
|
|
552
|
+
feeds?: Array<JsFeedInfo>
|
|
553
|
+
/** JSON-LD entries found on the page. */
|
|
554
|
+
jsonLd?: Array<JsJsonLdEntry>
|
|
555
|
+
/** The depth of this page from the start URL. */
|
|
556
|
+
depth?: number
|
|
557
|
+
/** Whether this page is on the same domain as the start URL. */
|
|
558
|
+
stayedOnDomain?: boolean
|
|
559
|
+
/** Whether this page was skipped (binary or PDF content). */
|
|
560
|
+
wasSkipped?: boolean
|
|
561
|
+
/** Whether the content is a PDF. */
|
|
562
|
+
isPdf?: boolean
|
|
563
|
+
/** The detected character set encoding. */
|
|
564
|
+
detectedCharset?: string
|
|
565
|
+
/** Markdown conversion of the page content. */
|
|
566
|
+
markdown?: JsMarkdownResult
|
|
567
|
+
/** Structured data extracted by LLM. Populated when extraction is configured. */
|
|
568
|
+
extractedData?: any
|
|
569
|
+
/** Metadata about the LLM extraction pass (cost, tokens, model). */
|
|
570
|
+
extractionMeta?: ExtractionMeta
|
|
571
|
+
/** Downloaded non-HTML document (PDF, DOCX, image, code, etc.). */
|
|
572
|
+
downloadedDocument?: DownloadedDocument
|
|
573
|
+
/** Whether the browser fallback was used to fetch this page. */
|
|
574
|
+
browserUsed?: boolean
|
|
575
|
+
}
|
|
576
|
+
|
|
577
|
+
/** The result of a multi-page crawl operation. */
|
|
578
|
+
export interface CrawlResult {
|
|
579
|
+
/** The list of crawled pages. */
|
|
580
|
+
pages?: Array<CrawlPageResult>
|
|
581
|
+
/** The final URL after following redirects. */
|
|
582
|
+
finalUrl?: string
|
|
583
|
+
/** The number of redirects followed. */
|
|
584
|
+
redirectCount?: number
|
|
585
|
+
/** Whether any page was skipped during crawling. */
|
|
586
|
+
wasSkipped?: boolean
|
|
587
|
+
/** An error message, if the crawl encountered an issue. */
|
|
588
|
+
error?: string
|
|
589
|
+
/** Cookies collected during the crawl. */
|
|
590
|
+
cookies?: Array<JsCookieInfo>
|
|
591
|
+
/** Whether all crawled pages stayed on the same domain as the start URL. */
|
|
592
|
+
stayedOnDomain?: boolean
|
|
593
|
+
/** Whether the browser fallback was used for any page in this crawl. */
|
|
594
|
+
browserUsed?: boolean
|
|
595
|
+
}
|
|
596
|
+
|
|
597
|
+
export declare function crawlStream(engine: CrawlEngineHandle, url: string): Promise<CrawlStreamIterator>
|
|
598
|
+
|
|
599
|
+
/**
|
|
600
|
+
* Request to begin a single-URL streaming crawl.
|
|
601
|
+
*
|
|
602
|
+
* Wraps a single seed URL for delivery through the streaming-adapter binding
|
|
603
|
+
* surface. Required as a struct because alef's streaming adapter requires a
|
|
604
|
+
* named request type — primitives are not supported.
|
|
605
|
+
*/
|
|
606
|
+
export interface CrawlStreamRequest {
|
|
607
|
+
/** The seed URL to crawl. */
|
|
608
|
+
url?: string
|
|
609
|
+
}
|
|
610
|
+
|
|
611
|
+
/**
|
|
612
|
+
* Create a new crawl engine with the given configuration.
|
|
613
|
+
*
|
|
614
|
+
* If `config` is `None`, uses `CrawlConfig.default()`.
|
|
615
|
+
* Returns an error if the configuration is invalid.
|
|
616
|
+
*/
|
|
617
|
+
export declare function createEngine(config?: CrawlConfig | undefined | null): CrawlEngineHandle
|
|
618
|
+
|
|
619
|
+
/** A downloaded asset from a page. */
|
|
620
|
+
export interface DownloadedAsset {
|
|
621
|
+
/** The original URL of the asset. */
|
|
622
|
+
url?: string
|
|
623
|
+
/** The SHA-256 content hash of the asset. */
|
|
624
|
+
contentHash?: string
|
|
625
|
+
/** The MIME type from the Content-Type header. */
|
|
626
|
+
mimeType?: string
|
|
627
|
+
/** The size of the asset in bytes. */
|
|
628
|
+
size?: number
|
|
629
|
+
/** The category of the asset. */
|
|
630
|
+
assetCategory?: JsAssetCategory
|
|
631
|
+
/** The HTML tag that referenced this asset (e.g., "link", "script", "img"). */
|
|
632
|
+
htmlTag?: string
|
|
633
|
+
}
|
|
634
|
+
|
|
635
|
+
/**
|
|
636
|
+
* A downloaded non-HTML document (PDF, DOCX, image, code file, etc.).
|
|
637
|
+
*
|
|
638
|
+
* When the crawler encounters non-HTML content and `download_documents` is
|
|
639
|
+
* enabled, it downloads the raw bytes and populates this struct instead of
|
|
640
|
+
* skipping the resource.
|
|
641
|
+
*/
|
|
642
|
+
export interface DownloadedDocument {
|
|
643
|
+
/** The URL the document was fetched from. */
|
|
644
|
+
url?: string
|
|
645
|
+
/** The MIME type from the Content-Type header. */
|
|
646
|
+
mimeType?: string
|
|
647
|
+
/** Size of the document in bytes. */
|
|
648
|
+
size?: number
|
|
649
|
+
/** Filename extracted from Content-Disposition or URL path. */
|
|
650
|
+
filename?: string
|
|
651
|
+
/** SHA-256 hex digest of the content. */
|
|
652
|
+
contentHash?: string
|
|
653
|
+
/** Selected response headers. */
|
|
654
|
+
headers?: Record<string, string>
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
/** Metadata about an LLM extraction pass. */
|
|
658
|
+
export interface ExtractionMeta {
|
|
659
|
+
/** Estimated cost of the LLM call in USD. */
|
|
660
|
+
cost?: number
|
|
661
|
+
/** Number of prompt (input) tokens consumed. */
|
|
662
|
+
promptTokens?: number
|
|
663
|
+
/** Number of completion (output) tokens generated. */
|
|
664
|
+
completionTokens?: number
|
|
665
|
+
/** The model identifier used for extraction. */
|
|
666
|
+
model?: string
|
|
667
|
+
/** Number of content chunks sent to the LLM. */
|
|
668
|
+
chunksProcessed?: number
|
|
669
|
+
}
|
|
670
|
+
|
|
671
|
+
/** Information about a favicon or icon link. */
|
|
672
|
+
export interface FaviconInfo {
|
|
673
|
+
/** The icon URL. */
|
|
674
|
+
url?: string
|
|
675
|
+
/** The `rel` attribute (e.g., "icon", "apple-touch-icon"). */
|
|
676
|
+
rel?: string
|
|
677
|
+
/** The `sizes` attribute, if present. */
|
|
678
|
+
sizes?: string
|
|
679
|
+
/** The MIME type, if present. */
|
|
680
|
+
mimeType?: string
|
|
681
|
+
}
|
|
682
|
+
|
|
683
|
+
/** Information about a feed link found on a page. */
|
|
684
|
+
export interface FeedInfo {
|
|
685
|
+
/** The feed URL. */
|
|
686
|
+
url?: string
|
|
687
|
+
/** The feed title, if present. */
|
|
688
|
+
title?: string
|
|
689
|
+
/** The type of feed. */
|
|
690
|
+
feedType?: JsFeedType
|
|
691
|
+
}
|
|
692
|
+
|
|
693
|
+
/** The type of a feed (RSS, Atom, or JSON Feed). */
|
|
694
|
+
export declare const enum FeedType {
|
|
695
|
+
/** RSS feed. */
|
|
696
|
+
Rss = 'rss',
|
|
697
|
+
/** Atom feed. */
|
|
698
|
+
Atom = 'atom',
|
|
699
|
+
/** JSON Feed. */
|
|
700
|
+
JsonFeed = 'json_feed'
|
|
701
|
+
}
|
|
702
|
+
|
|
703
|
+
/**
|
|
704
|
+
* Convert markdown links to numbered citations.
|
|
705
|
+
*
|
|
706
|
+
* `[Example](https://example.com)` becomes `Example[1]`
|
|
707
|
+
* with `[1]: https://example.com` in the reference list.
|
|
708
|
+
* Images `` are preserved unchanged.
|
|
709
|
+
*/
|
|
710
|
+
export declare function generateCitations(markdown: string): CitationResult
|
|
711
|
+
|
|
712
|
+
/** A heading element extracted from the page. */
|
|
713
|
+
export interface HeadingInfo {
|
|
714
|
+
/** The heading level (1-6). */
|
|
715
|
+
level?: number
|
|
716
|
+
/** The heading text content. */
|
|
717
|
+
text?: string
|
|
718
|
+
}
|
|
719
|
+
|
|
720
|
+
/** An hreflang alternate link entry. */
|
|
721
|
+
export interface HreflangEntry {
|
|
722
|
+
/** The language code (e.g., "en", "fr", "x-default"). */
|
|
723
|
+
lang?: string
|
|
724
|
+
/** The URL for this language variant. */
|
|
725
|
+
url?: string
|
|
726
|
+
}
|
|
727
|
+
|
|
728
|
+
/** Information about an image found on a page. */
|
|
729
|
+
export interface ImageInfo {
|
|
730
|
+
/** The image URL. */
|
|
731
|
+
url?: string
|
|
732
|
+
/** The alt text, if present. */
|
|
733
|
+
alt?: string
|
|
734
|
+
/** The width attribute, if present and parseable. */
|
|
735
|
+
width?: number
|
|
736
|
+
/** The height attribute, if present and parseable. */
|
|
737
|
+
height?: number
|
|
738
|
+
/** The source of the image reference. */
|
|
739
|
+
source?: JsImageSource
|
|
740
|
+
}
|
|
741
|
+
|
|
742
|
+
/** The source of an image reference. */
|
|
743
|
+
export declare const enum ImageSource {
|
|
744
|
+
/** An `<img>` tag. */
|
|
745
|
+
Img = 'img',
|
|
746
|
+
/** A `<source>` tag inside `<picture>`. */
|
|
747
|
+
PictureSource = 'picture_source',
|
|
748
|
+
/** An `og:image` meta tag. */
|
|
749
|
+
OgImage = 'og:image',
|
|
750
|
+
/** A `twitter:image` meta tag. */
|
|
751
|
+
TwitterImage = 'twitter:image'
|
|
752
|
+
}
|
|
753
|
+
|
|
754
|
+
/** Execute browser actions on a single page. */
|
|
755
|
+
export declare function interact(engine: CrawlEngineHandle, url: string, actions: Array<PageAction>): Promise<InteractionResult>
|
|
756
|
+
|
|
757
|
+
/** Result of executing a sequence of page interaction actions. */
|
|
758
|
+
export interface InteractionResult {
|
|
759
|
+
/** Results from each executed action. */
|
|
760
|
+
actionResults?: Array<JsActionResult>
|
|
761
|
+
/** Final page HTML after all actions completed. */
|
|
762
|
+
finalHtml?: string
|
|
763
|
+
/** Final page URL (may have changed due to navigation). */
|
|
764
|
+
finalUrl?: string
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** A JSON-LD structured data entry found on a page. */
|
|
768
|
+
export interface JsonLdEntry {
|
|
769
|
+
/** The `@type` value from the JSON-LD object. */
|
|
770
|
+
schemaType?: string
|
|
771
|
+
/** The `name` value, if present. */
|
|
772
|
+
name?: string
|
|
773
|
+
/** The raw JSON-LD string. */
|
|
774
|
+
raw?: string
|
|
775
|
+
}
|
|
776
|
+
|
|
777
|
+
/** Information about a link found on a page. */
|
|
778
|
+
export interface LinkInfo {
|
|
779
|
+
/** The resolved URL of the link. */
|
|
780
|
+
url?: string
|
|
781
|
+
/** The visible text of the link. */
|
|
782
|
+
text?: string
|
|
783
|
+
/** The classification of the link. */
|
|
784
|
+
linkType?: JsLinkType
|
|
785
|
+
/** The `rel` attribute value, if present. */
|
|
786
|
+
rel?: string
|
|
787
|
+
/** Whether the link has `rel="nofollow"`. */
|
|
788
|
+
nofollow?: boolean
|
|
789
|
+
}
|
|
790
|
+
|
|
791
|
+
/** The classification of a link. */
|
|
792
|
+
export declare const enum LinkType {
|
|
793
|
+
/** A link to the same domain. */
|
|
794
|
+
Internal = 'internal',
|
|
795
|
+
/** A link to a different domain. */
|
|
796
|
+
External = 'external',
|
|
797
|
+
/** A fragment-only link (e.g., `#section`). */
|
|
798
|
+
Anchor = 'anchor',
|
|
799
|
+
/** A link to a downloadable document (PDF, DOC, etc.). */
|
|
800
|
+
Document = 'document'
|
|
801
|
+
}
|
|
802
|
+
|
|
803
|
+
/** The result of a map operation, containing discovered URLs. */
|
|
804
|
+
export interface MapResult {
|
|
805
|
+
/** The list of discovered URLs. */
|
|
806
|
+
urls?: Array<SitemapUrl>
|
|
807
|
+
}
|
|
808
|
+
|
|
809
|
+
/** Discover all pages on a website by following links and sitemaps. */
|
|
810
|
+
export declare function mapUrls(engine: CrawlEngineHandle, url: string): Promise<MapResult>
|
|
811
|
+
|
|
812
|
+
/** Rich markdown conversion result from HTML processing. */
|
|
813
|
+
export interface MarkdownResult {
|
|
814
|
+
/** Converted markdown text. */
|
|
815
|
+
content?: string
|
|
816
|
+
/** Structured document tree with semantic nodes. */
|
|
817
|
+
documentStructure?: any
|
|
818
|
+
/** Extracted tables with structured cell data. */
|
|
819
|
+
tables?: Array<any>
|
|
820
|
+
/** Non-fatal processing warnings. */
|
|
821
|
+
warnings?: Array<string>
|
|
822
|
+
/**
|
|
823
|
+
* Whether citation conversion was applied and produced at least one reference.
|
|
824
|
+
*
|
|
825
|
+
* `true` when the markdown contained inline links that were converted to
|
|
826
|
+
* numbered citation references. The converted content (with `[N]` markers)
|
|
827
|
+
* is available in `content`; the full reference list is accessible via
|
|
828
|
+
* `generate_citations` if needed separately.
|
|
829
|
+
*/
|
|
830
|
+
citations?: boolean
|
|
831
|
+
/** Content-filtered markdown optimized for LLM consumption. */
|
|
832
|
+
fitContent?: string
|
|
833
|
+
}
|
|
834
|
+
|
|
835
|
+
/**
|
|
836
|
+
* A single page interaction action.
|
|
837
|
+
*
|
|
838
|
+
* Actions are serialized with a `type` tag using camelCase naming,
|
|
839
|
+
* except `ExecuteJs` which is explicitly renamed to `"executeJs"`.
|
|
840
|
+
*/
|
|
841
|
+
export interface PageAction {
|
|
842
|
+
type: string
|
|
843
|
+
selector?: string
|
|
844
|
+
text?: string
|
|
845
|
+
key?: string
|
|
846
|
+
direction?: JsScrollDirection
|
|
847
|
+
amount?: number
|
|
848
|
+
milliseconds?: number
|
|
849
|
+
fullPage?: boolean
|
|
850
|
+
script?: string
|
|
851
|
+
}
|
|
852
|
+
|
|
853
|
+
/** Metadata extracted from an HTML page's `<meta>` tags and `<title>` element. */
|
|
854
|
+
export interface PageMetadata {
|
|
855
|
+
/** The page title from the `<title>` element. */
|
|
856
|
+
title?: string
|
|
857
|
+
/** The meta description. */
|
|
858
|
+
description?: string
|
|
859
|
+
/** The canonical URL from `<link rel="canonical">`. */
|
|
860
|
+
canonicalUrl?: string
|
|
861
|
+
/** Keywords from `<meta name="keywords">`. */
|
|
862
|
+
keywords?: string
|
|
863
|
+
/** Author from `<meta name="author">`. */
|
|
864
|
+
author?: string
|
|
865
|
+
/** Viewport content from `<meta name="viewport">`. */
|
|
866
|
+
viewport?: string
|
|
867
|
+
/** Theme color from `<meta name="theme-color">`. */
|
|
868
|
+
themeColor?: string
|
|
869
|
+
/** Generator from `<meta name="generator">`. */
|
|
870
|
+
generator?: string
|
|
871
|
+
/** Robots content from `<meta name="robots">`. */
|
|
872
|
+
robots?: string
|
|
873
|
+
/** The `lang` attribute from the `<html>` element. */
|
|
874
|
+
htmlLang?: string
|
|
875
|
+
/** The `dir` attribute from the `<html>` element. */
|
|
876
|
+
htmlDir?: string
|
|
877
|
+
/** Open Graph title. */
|
|
878
|
+
ogTitle?: string
|
|
879
|
+
/** Open Graph type. */
|
|
880
|
+
ogType?: string
|
|
881
|
+
/** Open Graph image URL. */
|
|
882
|
+
ogImage?: string
|
|
883
|
+
/** Open Graph description. */
|
|
884
|
+
ogDescription?: string
|
|
885
|
+
/** Open Graph URL. */
|
|
886
|
+
ogUrl?: string
|
|
887
|
+
/** Open Graph site name. */
|
|
888
|
+
ogSiteName?: string
|
|
889
|
+
/** Open Graph locale. */
|
|
890
|
+
ogLocale?: string
|
|
891
|
+
/** Open Graph video URL. */
|
|
892
|
+
ogVideo?: string
|
|
893
|
+
/** Open Graph audio URL. */
|
|
894
|
+
ogAudio?: string
|
|
895
|
+
/** Open Graph locale alternates. */
|
|
896
|
+
ogLocaleAlternates?: Array<string>
|
|
897
|
+
/** Twitter card type. */
|
|
898
|
+
twitterCard?: string
|
|
899
|
+
/** Twitter title. */
|
|
900
|
+
twitterTitle?: string
|
|
901
|
+
/** Twitter description. */
|
|
902
|
+
twitterDescription?: string
|
|
903
|
+
/** Twitter image URL. */
|
|
904
|
+
twitterImage?: string
|
|
905
|
+
/** Twitter site handle. */
|
|
906
|
+
twitterSite?: string
|
|
907
|
+
/** Twitter creator handle. */
|
|
908
|
+
twitterCreator?: string
|
|
909
|
+
/** Dublin Core title. */
|
|
910
|
+
dcTitle?: string
|
|
911
|
+
/** Dublin Core creator. */
|
|
912
|
+
dcCreator?: string
|
|
913
|
+
/** Dublin Core subject. */
|
|
914
|
+
dcSubject?: string
|
|
915
|
+
/** Dublin Core description. */
|
|
916
|
+
dcDescription?: string
|
|
917
|
+
/** Dublin Core publisher. */
|
|
918
|
+
dcPublisher?: string
|
|
919
|
+
/** Dublin Core date. */
|
|
920
|
+
dcDate?: string
|
|
921
|
+
/** Dublin Core type. */
|
|
922
|
+
dcType?: string
|
|
923
|
+
/** Dublin Core format. */
|
|
924
|
+
dcFormat?: string
|
|
925
|
+
/** Dublin Core identifier. */
|
|
926
|
+
dcIdentifier?: string
|
|
927
|
+
/** Dublin Core language. */
|
|
928
|
+
dcLanguage?: string
|
|
929
|
+
/** Dublin Core rights. */
|
|
930
|
+
dcRights?: string
|
|
931
|
+
/** Article metadata from `article:*` Open Graph tags. */
|
|
932
|
+
article?: ArticleMetadata
|
|
933
|
+
/** Hreflang alternate links. */
|
|
934
|
+
hreflangs?: Array<HreflangEntry>
|
|
935
|
+
/** Favicon and icon links. */
|
|
936
|
+
favicons?: Array<FaviconInfo>
|
|
937
|
+
/** Heading elements (h1-h6). */
|
|
938
|
+
headings?: Array<HeadingInfo>
|
|
939
|
+
/** Computed word count of the page body text. */
|
|
940
|
+
wordCount?: number
|
|
941
|
+
}
|
|
942
|
+
|
|
943
|
+
/** Proxy configuration for HTTP requests. */
|
|
944
|
+
export interface ProxyConfig {
|
|
945
|
+
/** Proxy URL (e.g. "http://proxy:8080", "socks5://proxy:1080"). */
|
|
946
|
+
url?: string
|
|
947
|
+
/** Optional username for proxy authentication. */
|
|
948
|
+
username?: string
|
|
949
|
+
/** Optional password for proxy authentication. */
|
|
950
|
+
password?: string
|
|
951
|
+
}
|
|
952
|
+
|
|
953
|
+
/** Response metadata extracted from HTTP headers. */
|
|
954
|
+
export interface ResponseMeta {
|
|
955
|
+
/** The ETag header value. */
|
|
956
|
+
etag?: string
|
|
957
|
+
/** The Last-Modified header value. */
|
|
958
|
+
lastModified?: string
|
|
959
|
+
/** The Cache-Control header value. */
|
|
960
|
+
cacheControl?: string
|
|
961
|
+
/** The Server header value. */
|
|
962
|
+
server?: string
|
|
963
|
+
/** The X-Powered-By header value. */
|
|
964
|
+
xPoweredBy?: string
|
|
965
|
+
/** The Content-Language header value. */
|
|
966
|
+
contentLanguage?: string
|
|
967
|
+
/** The Content-Encoding header value. */
|
|
968
|
+
contentEncoding?: string
|
|
969
|
+
}
|
|
970
|
+
|
|
971
|
+
/** Scrape a single URL, returning extracted page data. */
|
|
972
|
+
export declare function scrape(engine: CrawlEngineHandle, url: string): Promise<ScrapeResult>
|
|
973
|
+
|
|
974
|
+
/** The result of a single-page scrape operation. */
|
|
975
|
+
export interface ScrapeResult {
|
|
976
|
+
/** The HTTP status code of the response. */
|
|
977
|
+
statusCode?: number
|
|
978
|
+
/** The final URL after following all redirects. */
|
|
979
|
+
finalUrl?: string
|
|
980
|
+
/** The Content-Type header value. */
|
|
981
|
+
contentType?: string
|
|
982
|
+
/** The HTML body of the response. */
|
|
983
|
+
html?: string
|
|
984
|
+
/** The size of the response body in bytes. */
|
|
985
|
+
bodySize?: number
|
|
986
|
+
/** Extracted metadata from the page. */
|
|
987
|
+
metadata?: JsPageMetadata
|
|
988
|
+
/** Links found on the page. */
|
|
989
|
+
links?: Array<JsLinkInfo>
|
|
990
|
+
/** Images found on the page. */
|
|
991
|
+
images?: Array<JsImageInfo>
|
|
992
|
+
/** Feed links found on the page. */
|
|
993
|
+
feeds?: Array<JsFeedInfo>
|
|
994
|
+
/** JSON-LD entries found on the page. */
|
|
995
|
+
jsonLd?: Array<JsJsonLdEntry>
|
|
996
|
+
/** Whether the URL is allowed by robots.txt. */
|
|
997
|
+
isAllowed?: boolean
|
|
998
|
+
/** The crawl delay from robots.txt, in seconds. */
|
|
999
|
+
crawlDelay?: number
|
|
1000
|
+
/** Whether a noindex directive was detected. */
|
|
1001
|
+
noindexDetected?: boolean
|
|
1002
|
+
/** Whether a nofollow directive was detected. */
|
|
1003
|
+
nofollowDetected?: boolean
|
|
1004
|
+
/** The X-Robots-Tag header value, if present. */
|
|
1005
|
+
xRobotsTag?: string
|
|
1006
|
+
/** Whether the content is a PDF. */
|
|
1007
|
+
isPdf?: boolean
|
|
1008
|
+
/** Whether the page was skipped (binary or PDF content). */
|
|
1009
|
+
wasSkipped?: boolean
|
|
1010
|
+
/** The detected character set encoding. */
|
|
1011
|
+
detectedCharset?: string
|
|
1012
|
+
/** Whether an authentication header was sent with the request. */
|
|
1013
|
+
authHeaderSent?: boolean
|
|
1014
|
+
/** Response metadata extracted from HTTP headers. */
|
|
1015
|
+
responseMeta?: JsResponseMeta
|
|
1016
|
+
/** Downloaded assets from the page. */
|
|
1017
|
+
assets?: Array<JsDownloadedAsset>
|
|
1018
|
+
/** Whether the page content suggests JavaScript rendering is needed. */
|
|
1019
|
+
jsRenderHint?: boolean
|
|
1020
|
+
/** Whether the browser fallback was used to fetch this page. */
|
|
1021
|
+
browserUsed?: boolean
|
|
1022
|
+
/** Markdown conversion of the page content. */
|
|
1023
|
+
markdown?: JsMarkdownResult
|
|
1024
|
+
/** Structured data extracted by LLM. Populated when extraction is configured. */
|
|
1025
|
+
extractedData?: any
|
|
1026
|
+
/** Metadata about the LLM extraction pass (cost, tokens, model). */
|
|
1027
|
+
extractionMeta?: ExtractionMeta
|
|
1028
|
+
/** Downloaded non-HTML document (PDF, DOCX, image, code, etc.). */
|
|
1029
|
+
downloadedDocument?: DownloadedDocument
|
|
1030
|
+
/**
|
|
1031
|
+
* Browser-specific extras (eval result, network events, cookies). Only
|
|
1032
|
+
* populated when `BrowserBackend.Native` was used for this request.
|
|
1033
|
+
*/
|
|
1034
|
+
browser?: BrowserExtras
|
|
1035
|
+
}
|
|
1036
|
+
|
|
1037
|
+
/** Direction for a scroll action. */
|
|
1038
|
+
export declare const enum ScrollDirection {
|
|
1039
|
+
/** Scroll upward. */
|
|
1040
|
+
Up = 'up',
|
|
1041
|
+
/** Scroll downward. */
|
|
1042
|
+
Down = 'down'
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
/** A URL entry from a sitemap. */
|
|
1046
|
+
export interface SitemapUrl {
|
|
1047
|
+
/** The URL. */
|
|
1048
|
+
url?: string
|
|
1049
|
+
/** The last modification date, if present. */
|
|
1050
|
+
lastmod?: string
|
|
1051
|
+
/** The change frequency, if present. */
|
|
1052
|
+
changefreq?: string
|
|
1053
|
+
/** The priority, if present. */
|
|
1054
|
+
priority?: string
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/** SSRF policy configuration. */
|
|
1058
|
+
export interface SsrfPolicy {
|
|
1059
|
+
/** If true, reject URLs that resolve to private/metadata IP ranges. */
|
|
1060
|
+
denyPrivate?: boolean
|
|
1061
|
+
/** Maximum number of HTTP redirects to follow during validation. */
|
|
1062
|
+
maxRedirects?: number
|
|
1063
|
+
}
|
|
1064
|
+
|
|
1065
|
+
export declare function ssrfPolicyDefault(): SsrfPolicy
|
|
1066
|
+
|
|
1067
|
+
/**
|
|
1068
|
+
* Create a policy from environment variables.
|
|
1069
|
+
*
|
|
1070
|
+
* On native platforms, reads `CRAWLBERG_ALLOW_PRIVATE_NETWORK` — if set to "1" or "true"
|
|
1071
|
+
* (case-insensitive), sets `deny_private = false`. Otherwise, defaults to `deny_private = true`.
|
|
1072
|
+
*
|
|
1073
|
+
* On wasm32 targets (browser/Node.js), environment variables are not accessible to the
|
|
1074
|
+
* compiled module. Defaults to `deny_private = false` because:
|
|
1075
|
+
* - Outbound requests in a browser go through the fetch API, which enforces its own network policies.
|
|
1076
|
+
* - Rust-side SSRF checking is unenforceable and redundant in a wasm32 context.
|
|
1077
|
+
* - For testing and localhost access, the host's network sandbox is the enforcing boundary.
|
|
1078
|
+
*/
|
|
1079
|
+
export declare function ssrfPolicyFromEnv(): SsrfPolicy
|