@crawlbrulee/sdk 1.5.0 → 1.7.0
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 +83 -21
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +289 -58
- package/dist/index.d.ts +289 -58
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -74,8 +74,12 @@ declare class HttpClient {
|
|
|
74
74
|
*
|
|
75
75
|
* - `basic` — basic proxy, lowest cost.
|
|
76
76
|
* - `advanced` — enhanced proxy tier with a higher success rate.
|
|
77
|
-
* - `auto` — start
|
|
78
|
-
*
|
|
77
|
+
* - `auto` — we start with the lightest way to get the page and step up our
|
|
78
|
+
* effort on our own when a site needs more: a stronger proxy, a real browser,
|
|
79
|
+
* or both (a map steps up the proxy only). Billed at the delivered tier. This
|
|
80
|
+
* is the default when `proxy` is omitted.
|
|
81
|
+
*
|
|
82
|
+
* See https://crawlbrulee.com/docs/proxies#how-auto-works.
|
|
79
83
|
*/
|
|
80
84
|
type ProxyTier = 'basic' | 'advanced' | 'auto';
|
|
81
85
|
/**
|
|
@@ -162,24 +166,143 @@ type ScreenshotDeviceMode = 'desktop' | 'mobile';
|
|
|
162
166
|
* {@link ScreenshotRequest.color_scheme}.
|
|
163
167
|
*/
|
|
164
168
|
type ScreenshotColorScheme = 'light' | 'dark';
|
|
165
|
-
/**
|
|
166
|
-
interface
|
|
169
|
+
/** Fields every action takes. */
|
|
170
|
+
interface ScrapeActionBase {
|
|
171
|
+
/**
|
|
172
|
+
* When `true`, a failure of this action does not stop the list: it is
|
|
173
|
+
* reported as `skipped` and the next action runs. A page that moves on to
|
|
174
|
+
* another page during the action still stops the list. Defaults to `false`.
|
|
175
|
+
*/
|
|
176
|
+
optional?: boolean;
|
|
177
|
+
}
|
|
178
|
+
/** Wait for a set time. */
|
|
179
|
+
interface ScrapeWaitAction extends ScrapeActionBase {
|
|
167
180
|
type: 'wait';
|
|
168
|
-
/** Milliseconds to wait
|
|
181
|
+
/** Milliseconds to wait, from 0 to 60 000. */
|
|
169
182
|
ms: number;
|
|
170
183
|
}
|
|
171
|
-
/**
|
|
172
|
-
interface
|
|
184
|
+
/** Scroll by a number of pixels. */
|
|
185
|
+
interface ScrapeScrollByAction extends ScrapeActionBase {
|
|
173
186
|
type: 'scroll';
|
|
174
|
-
/** Pixels to scroll
|
|
187
|
+
/** Pixels to scroll down. Negative scrolls up. */
|
|
175
188
|
pixels: number;
|
|
189
|
+
to?: never;
|
|
190
|
+
/**
|
|
191
|
+
* How long the scroll takes, in milliseconds, up to 60 000. A slow scroll
|
|
192
|
+
* gives images further down the page time to load on the way; 0 jumps at
|
|
193
|
+
* once. Without it, the page scrolls at a steady pace, taking up to 5 s.
|
|
194
|
+
*/
|
|
195
|
+
duration_ms?: number;
|
|
196
|
+
}
|
|
197
|
+
/** Scroll to an edge of the page or to an element. */
|
|
198
|
+
interface ScrapeScrollToAction extends ScrapeActionBase {
|
|
199
|
+
type: 'scroll';
|
|
200
|
+
/**
|
|
201
|
+
* `top`, `bottom`, `left` or `right` of the page, or a CSS selector, which
|
|
202
|
+
* brings the first match to the middle of the window. It waits up to 5 s for
|
|
203
|
+
* the element.
|
|
204
|
+
*/
|
|
205
|
+
to: 'top' | 'bottom' | 'left' | 'right' | (string & {});
|
|
206
|
+
pixels?: never;
|
|
207
|
+
/** How long the scroll takes, in milliseconds. See {@link ScrapeScrollByAction.duration_ms}. */
|
|
208
|
+
duration_ms?: number;
|
|
209
|
+
}
|
|
210
|
+
/** Scroll the page: by `pixels`, or `to` a place. Use one of the two, not both. */
|
|
211
|
+
type ScrapeScrollAction = ScrapeScrollByAction | ScrapeScrollToAction;
|
|
212
|
+
/** Wait for an element to appear. */
|
|
213
|
+
interface ScrapeWaitForAction extends ScrapeActionBase {
|
|
214
|
+
type: 'wait_for';
|
|
215
|
+
/**
|
|
216
|
+
* CSS selector. The action waits until the first match is on the page and
|
|
217
|
+
* visible, for up to 10 s; after that it fails.
|
|
218
|
+
*/
|
|
219
|
+
selector: string;
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Move the mouse over an element, or to a point in the window. Desktop only:
|
|
223
|
+
* on a mobile device it is always `skipped`.
|
|
224
|
+
*/
|
|
225
|
+
type ScrapeHoverAction = ScrapeActionBase & {
|
|
226
|
+
type: 'hover';
|
|
227
|
+
} & ({
|
|
228
|
+
/** CSS selector: the mouse goes to the first match, brought into view first. */
|
|
229
|
+
selector: string;
|
|
230
|
+
x?: never;
|
|
231
|
+
y?: never;
|
|
232
|
+
} | {
|
|
233
|
+
selector?: never;
|
|
234
|
+
/** Pixels from the left edge of the window, 0 to 10 000. */
|
|
235
|
+
x: number;
|
|
236
|
+
/** Pixels from the top edge of the window, 0 to 10 000. */
|
|
237
|
+
y: number;
|
|
238
|
+
});
|
|
239
|
+
/** Click an element (a tap on a mobile device). */
|
|
240
|
+
interface ScrapeClickAction extends ScrapeActionBase {
|
|
241
|
+
type: 'click';
|
|
242
|
+
/**
|
|
243
|
+
* CSS selector: the first match on the page itself (not inside a frame or a
|
|
244
|
+
* shadow root), brought into view first.
|
|
245
|
+
*/
|
|
246
|
+
selector: string;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Type text into a field, such as a search box. To send the form, `click` its
|
|
250
|
+
* button next.
|
|
251
|
+
*/
|
|
252
|
+
interface ScrapeTypeAction extends ScrapeActionBase {
|
|
253
|
+
type: 'type';
|
|
254
|
+
/**
|
|
255
|
+
* CSS selector of a field you can type into: the first match on the page
|
|
256
|
+
* itself (not inside a frame or a shadow root).
|
|
257
|
+
*/
|
|
258
|
+
selector: string;
|
|
259
|
+
/**
|
|
260
|
+
* The text, 1 to 200 characters, with no line breaks or tabs. Typing takes
|
|
261
|
+
* up to 90 ms a character, and that time counts toward the list's 60 s.
|
|
262
|
+
*/
|
|
263
|
+
text: string;
|
|
264
|
+
/** When `true`, the field is emptied first. Defaults to `false`. */
|
|
265
|
+
clear?: boolean;
|
|
176
266
|
}
|
|
177
267
|
/**
|
|
178
|
-
*
|
|
179
|
-
*
|
|
180
|
-
|
|
268
|
+
* Pick an option in a `<select>` dropdown, by `value` or by `label`. A dropdown
|
|
269
|
+
* the page builds from other elements takes two `click`s instead.
|
|
270
|
+
*/
|
|
271
|
+
type ScrapeSelectAction = ScrapeActionBase & {
|
|
272
|
+
type: 'select';
|
|
273
|
+
/**
|
|
274
|
+
* CSS selector of the `<select>`: the first match on the page itself (not
|
|
275
|
+
* inside a frame or a shadow root).
|
|
276
|
+
*/
|
|
277
|
+
selector: string;
|
|
278
|
+
} & ({
|
|
279
|
+
/** The option's value. */
|
|
280
|
+
value: string;
|
|
281
|
+
label?: never;
|
|
282
|
+
} | {
|
|
283
|
+
value?: never;
|
|
284
|
+
/** The option's text as the page shows it (spaces at either end do not count). */
|
|
285
|
+
label: string;
|
|
286
|
+
});
|
|
287
|
+
/**
|
|
288
|
+
* One thing to do on the page before it is read. The list runs in order, up
|
|
289
|
+
* to 12 actions and 60 s in total. See https://crawlbrulee.com/docs/scrape/actions.
|
|
181
290
|
*/
|
|
182
|
-
type
|
|
291
|
+
type ScrapeAction = ScrapeWaitAction | ScrapeScrollAction | ScrapeWaitForAction | ScrapeHoverAction | ScrapeClickAction | ScrapeTypeAction | ScrapeSelectAction;
|
|
292
|
+
/** The `type` of a {@link ScrapeAction}. */
|
|
293
|
+
type ScrapeActionType = ScrapeAction['type'];
|
|
294
|
+
/** @deprecated Use {@link ScrapeWaitAction}. */
|
|
295
|
+
type ScreenshotWaitAction = ScrapeWaitAction;
|
|
296
|
+
/**
|
|
297
|
+
* @deprecated Use {@link ScrapeScrollAction}. Kept at its old shape: a scroll
|
|
298
|
+
* by `pixels`.
|
|
299
|
+
*/
|
|
300
|
+
type ScreenshotScrollAction = ScrapeScrollByAction;
|
|
301
|
+
/**
|
|
302
|
+
* @deprecated Use {@link ScrapeAction}. Kept at its old shape: a `wait` or a
|
|
303
|
+
* scroll by `pixels`. `actions_before` itself takes every {@link ScrapeAction}.
|
|
304
|
+
*/
|
|
305
|
+
type ScreenshotBeforeAction = ScrapeWaitAction | ScrapeScrollByAction;
|
|
183
306
|
/**
|
|
184
307
|
* Action performed after the screenshot is taken. Currently only `slice` is
|
|
185
308
|
* supported — it cuts the screenshot into horizontal tiles of `height` px.
|
|
@@ -218,8 +341,12 @@ interface ScreenshotRequest {
|
|
|
218
341
|
* dark theme too. No extra credits.
|
|
219
342
|
*/
|
|
220
343
|
color_scheme?: ScreenshotColorScheme;
|
|
221
|
-
/**
|
|
222
|
-
|
|
344
|
+
/**
|
|
345
|
+
* @deprecated Use the top-level {@link ScrapeRequest.actions}, which takes
|
|
346
|
+
* the same list and runs it at the same time. Sending a non-empty list in
|
|
347
|
+
* both is a `400`. This field will be removed on 2027-02-01.
|
|
348
|
+
*/
|
|
349
|
+
actions_before?: ScrapeAction[];
|
|
223
350
|
/** Post-capture actions (e.g. slice into tiles). Maximum 1 entry. */
|
|
224
351
|
actions_after?: ScreenshotAfterAction[];
|
|
225
352
|
}
|
|
@@ -386,9 +513,14 @@ interface ScrapeExtract {
|
|
|
386
513
|
/** Extract the page as clean Markdown. Default `true`. */
|
|
387
514
|
markdown?: boolean;
|
|
388
515
|
/**
|
|
389
|
-
* Return the
|
|
390
|
-
*
|
|
391
|
-
*
|
|
516
|
+
* Return the page HTML with its classes and attributes, after `cleanup` and
|
|
517
|
+
* after any `actions`. Default `false`. Scripts and styles are removed,
|
|
518
|
+
* except the JSON-LD blocks (`<script type="application/ld+json">`), which
|
|
519
|
+
* are kept up to 100 KB per page. Capped at 10 000 000 characters per page;
|
|
520
|
+
* past that the HTML is truncated at a tag boundary and a
|
|
521
|
+
* `raw_html_truncated` warning is returned. For the page without cleanup,
|
|
522
|
+
* set `cleanup.ads_and_popups` to `false` and send no
|
|
523
|
+
* `cleanup.exclude_selectors` (see {@link ScrapeCleanup}).
|
|
392
524
|
*/
|
|
393
525
|
raw_html?: boolean;
|
|
394
526
|
/**
|
|
@@ -488,22 +620,29 @@ interface PdfRequest {
|
|
|
488
620
|
media?: PdfMedia;
|
|
489
621
|
}
|
|
490
622
|
/**
|
|
491
|
-
* What is removed from the page before any output
|
|
623
|
+
* What is removed from the page, once, when it has loaded: before any output
|
|
624
|
+
* is built and before the `actions` run. A page a click loads is cleaned when
|
|
625
|
+
* it loads. Something the page adds later, such as a popup that opens after a
|
|
626
|
+
* delay, is not removed.
|
|
492
627
|
*
|
|
493
|
-
* Applies to `markdown`, `cleaned_html`,
|
|
494
|
-
*
|
|
495
|
-
* page
|
|
628
|
+
* Applies to every output on every engine: `markdown`, `cleaned_html`,
|
|
629
|
+
* `raw_html`, `metadata`, `links`, `images`, `elements`, the screenshot and
|
|
630
|
+
* the PDF. To get the page without cleanup, set `ads_and_popups` to `false`
|
|
631
|
+
* and send no `exclude_selectors`.
|
|
496
632
|
*/
|
|
497
633
|
interface ScrapeCleanup {
|
|
498
634
|
/**
|
|
499
635
|
* Remove ads, cookie banners, consent dialogs and chat widgets. Defaults to
|
|
500
|
-
* `true` server-side. Set it to `false` to
|
|
636
|
+
* `true` server-side. Set it to `false` to get the page as-is, or to get
|
|
501
637
|
* past a site that refuses to serve content to an ad-blocking client.
|
|
502
638
|
*/
|
|
503
639
|
ads_and_popups?: boolean;
|
|
504
640
|
/**
|
|
505
641
|
* CSS selectors whose elements are removed before anything is captured. Use
|
|
506
|
-
* it for a banner or widget `ads_and_popups` does not recognise.
|
|
642
|
+
* it for a banner or widget `ads_and_popups` does not recognise. Standard
|
|
643
|
+
* CSS only: a selector browsers do not support, such as `:contains()`,
|
|
644
|
+
* removes nothing. An element removed here can't be used by an action
|
|
645
|
+
* later: a `click` on it fails.
|
|
507
646
|
*
|
|
508
647
|
* At most 100 selectors, each at most 500 characters. A cached result is
|
|
509
648
|
* only reused for a request that removes the same selectors.
|
|
@@ -515,9 +654,10 @@ interface ScrapeCleanup {
|
|
|
515
654
|
* A cached result has to match the url, the screenshot setup (type, viewport,
|
|
516
655
|
* device mode, color scheme), the PDF settings, `cleanup.ads_and_popups`,
|
|
517
656
|
* `cleanup.exclude_selectors` and `location.locale`, and `require_js: true`
|
|
518
|
-
* only matches browser-rendered results. A
|
|
519
|
-
*
|
|
520
|
-
* `
|
|
657
|
+
* only matches browser-rendered results. A request with `actions` (or the
|
|
658
|
+
* deprecated `extract.screenshot.actions_before`) that do something, or with
|
|
659
|
+
* `headers` or `cookies`, never reads from or writes to the cache. An empty
|
|
660
|
+
* list, a `wait` of 0 or a `scroll` of 0 pixels does not count.
|
|
521
661
|
*/
|
|
522
662
|
interface ScrapeCache {
|
|
523
663
|
/**
|
|
@@ -562,21 +702,52 @@ interface ScrapeRequest {
|
|
|
562
702
|
/** Cache settings for this request. */
|
|
563
703
|
cache?: ScrapeCache;
|
|
564
704
|
/**
|
|
565
|
-
*
|
|
566
|
-
*
|
|
705
|
+
* Go straight to a headless browser to render JavaScript before scraping.
|
|
706
|
+
* Without it, we still move to a browser on our own when a page needs one;
|
|
707
|
+
* set it when you already know the page needs JavaScript, to save time.
|
|
708
|
+
* Default `false`.
|
|
567
709
|
*/
|
|
568
710
|
require_js?: boolean;
|
|
569
711
|
/**
|
|
570
|
-
* What is removed from the page before any output is
|
|
571
|
-
*
|
|
572
|
-
*
|
|
573
|
-
* Never applies to `raw_html`, which is always the page before anything was
|
|
574
|
-
* removed.
|
|
712
|
+
* What is removed from the page when it has loaded, before any output is
|
|
713
|
+
* built and before the `actions` run. Shapes every output, `raw_html`,
|
|
714
|
+
* `metadata`, the screenshot and the PDF included. See {@link ScrapeCleanup}.
|
|
575
715
|
*/
|
|
576
716
|
cleanup?: ScrapeCleanup;
|
|
577
717
|
/**
|
|
578
|
-
*
|
|
579
|
-
*
|
|
718
|
+
* Things to do on the page, in order, before it is read: `wait`, `scroll`,
|
|
719
|
+
* `wait_for` (an element), `hover`, `click`, `type` (text into a field) and
|
|
720
|
+
* `select` (an option of a dropdown). To fill in and send a form, such as a
|
|
721
|
+
* search box, `type` into the field, then `click` its button. Every output,
|
|
722
|
+
* the screenshot and the PDF included, shows the page as the actions left it.
|
|
723
|
+
*
|
|
724
|
+
* - Up to 12 actions, and 60 s for the whole list, waits, scroll durations
|
|
725
|
+
* and typing included.
|
|
726
|
+
* - A list with an action that does something runs in a browser, so it is
|
|
727
|
+
* billed as a browser scrape, and never reads from or writes to the cache.
|
|
728
|
+
* The actions themselves cost no extra credits.
|
|
729
|
+
* - The actions run after `cleanup`. A popup that opens later can still be in
|
|
730
|
+
* the way of a click, so click its close button first.
|
|
731
|
+
* - An action that fails stops the list: the page still comes back as it is
|
|
732
|
+
* then, billed as usual, with the `actions_incomplete` warning. Mark an
|
|
733
|
+
* action `optional` to go on past it. The response reports each action in
|
|
734
|
+
* {@link ScrapeResponse.actions}.
|
|
735
|
+
* - A click (or a `type` or `select` whose page sends the form) that loads a
|
|
736
|
+
* new page is followed: the response is that page, and the rest of the list
|
|
737
|
+
* runs there. A click that opens a new tab is ignored.
|
|
738
|
+
* - If a try fails and we try again, the actions run again from the start,
|
|
739
|
+
* so don't use them for anything that must happen only once, such as an
|
|
740
|
+
* order.
|
|
741
|
+
* - A request that `type`s has a lower rate limit of its own.
|
|
742
|
+
*
|
|
743
|
+
* See https://crawlbrulee.com/docs/scrape/actions.
|
|
744
|
+
*/
|
|
745
|
+
actions?: ScrapeAction[];
|
|
746
|
+
/**
|
|
747
|
+
* Proxy tier. Defaults to `auto`: we start with the lightest way to get the
|
|
748
|
+
* page and step up our effort on our own when a site needs more (a stronger
|
|
749
|
+
* proxy, a real browser, or both), billed at the delivered tier. `basic` or
|
|
750
|
+
* `advanced` pins the tier.
|
|
580
751
|
*/
|
|
581
752
|
proxy?: ProxyTier;
|
|
582
753
|
/** Optional locale + country emulation. */
|
|
@@ -798,6 +969,9 @@ interface ScrapeMetadata {
|
|
|
798
969
|
*
|
|
799
970
|
* - `custom_user_agent`: the request set its own `User-Agent` header; this
|
|
800
971
|
* can lower the success rate.
|
|
972
|
+
* - `actions_incomplete`: at least one action in `actions` failed or never
|
|
973
|
+
* ran. {@link ScrapeResponse.actions} says which, and the page is the one
|
|
974
|
+
* the actions left.
|
|
801
975
|
*
|
|
802
976
|
* The page body has no such code: if it can't be extracted the scrape fails
|
|
803
977
|
* outright rather than returning a hollow `200`, and isn't billed.
|
|
@@ -806,7 +980,25 @@ interface ScrapeMetadata {
|
|
|
806
980
|
* its own, so new scrapes never send it. It stays in the union because results
|
|
807
981
|
* stored before that change can still carry it. Don't rely on it in new code.
|
|
808
982
|
*/
|
|
809
|
-
type ScrapeWarningCode = 'screenshot_truncated' | 'links_truncated' | 'inline_images_truncated' | 'raw_html_truncated' | 'metadata_truncated' | 'elements_truncated' | 'pdf_single_page_overflow' | 'links_unavailable' | 'inline_images_unavailable' | 'metadata_unavailable' | 'screenshot_unavailable' | 'pdf_unavailable' | 'custom_user_agent';
|
|
983
|
+
type ScrapeWarningCode = 'screenshot_truncated' | 'links_truncated' | 'inline_images_truncated' | 'raw_html_truncated' | 'metadata_truncated' | 'elements_truncated' | 'pdf_single_page_overflow' | 'links_unavailable' | 'inline_images_unavailable' | 'metadata_unavailable' | 'screenshot_unavailable' | 'pdf_unavailable' | 'custom_user_agent' | 'actions_incomplete';
|
|
984
|
+
/**
|
|
985
|
+
* What happened to one action:
|
|
986
|
+
*
|
|
987
|
+
* - `ok`: it was done.
|
|
988
|
+
* - `failed`: it could not be done, for example its element was not found or
|
|
989
|
+
* was covered by something else, or the page a click loaded failed to load.
|
|
990
|
+
* - `skipped`: it could not be done, but it was `optional`, so the list went
|
|
991
|
+
* on. A `hover` is always skipped on a mobile device, which has no mouse.
|
|
992
|
+
* - `not_run`: the list never got to it.
|
|
993
|
+
*/
|
|
994
|
+
type ScrapeActionStatus = 'ok' | 'failed' | 'skipped' | 'not_run';
|
|
995
|
+
/** One entry of {@link ScrapeResponse.actions}. */
|
|
996
|
+
interface ScrapeActionResult {
|
|
997
|
+
/** The action type, as sent. */
|
|
998
|
+
type: ScrapeActionType;
|
|
999
|
+
/** What happened to it. */
|
|
1000
|
+
status: ScrapeActionStatus;
|
|
1001
|
+
}
|
|
810
1002
|
/**
|
|
811
1003
|
* Successful response from `POST /api/scrape` and `GET /api/scrape/result/:jobId`.
|
|
812
1004
|
*
|
|
@@ -835,7 +1027,7 @@ interface ScrapeResponse {
|
|
|
835
1027
|
* you, for example `if (page.page_status_code === 404)`.
|
|
836
1028
|
*
|
|
837
1029
|
* Billing follows this status: 2xx and 4xx pages are billed, except 403,
|
|
838
|
-
* 407, 408, 429 and 451; 5xx pages are never billed.
|
|
1030
|
+
* 407, 408, 429, 444 and 451; 5xx pages are never billed.
|
|
839
1031
|
*
|
|
840
1032
|
* Optional only because older api versions do not send it.
|
|
841
1033
|
*/
|
|
@@ -852,8 +1044,11 @@ interface ScrapeResponse {
|
|
|
852
1044
|
/** Cleaned HTML of the main page content (when `extract.cleaned_html`). */
|
|
853
1045
|
cleaned_html?: string;
|
|
854
1046
|
/**
|
|
855
|
-
*
|
|
856
|
-
*
|
|
1047
|
+
* The page HTML with its classes and attributes, after `cleanup` and after
|
|
1048
|
+
* any `actions` (when `extract.raw_html`). Scripts and styles are removed,
|
|
1049
|
+
* except the JSON-LD blocks (`<script type="application/ld+json">`), kept
|
|
1050
|
+
* up to 100 KB per page. Truncated at a tag boundary past 10 000 000
|
|
1051
|
+
* characters, with a `raw_html_truncated` warning.
|
|
857
1052
|
*/
|
|
858
1053
|
raw_html?: string;
|
|
859
1054
|
/** Inline images discovered on the page (when `extract.images`). */
|
|
@@ -903,9 +1098,18 @@ interface ScrapeResponse {
|
|
|
903
1098
|
pdf?: PdfResult;
|
|
904
1099
|
/** Extracted page metadata (when `extract.metadata`, on by default). */
|
|
905
1100
|
metadata?: ScrapeMetadata;
|
|
1101
|
+
/**
|
|
1102
|
+
* What happened to each action the request sent, in the same order. Present
|
|
1103
|
+
* only when the request sent actions. When any action is `failed` or
|
|
1104
|
+
* `not_run`, `warnings` has `actions_incomplete`. When the page could not be
|
|
1105
|
+
* loaded in a browser and was fetched without one, every action that acts on
|
|
1106
|
+
* the page is `not_run`.
|
|
1107
|
+
*/
|
|
1108
|
+
actions?: ScrapeActionResult[];
|
|
906
1109
|
/**
|
|
907
1110
|
* Non-error notices about the scrape: an output was capped (`*_truncated`,
|
|
908
|
-
* `pdf_single_page_overflow`)
|
|
1111
|
+
* `pdf_single_page_overflow`), could not be extracted (`*_unavailable`), or
|
|
1112
|
+
* not every action ran (`actions_incomplete`);
|
|
909
1113
|
* see {@link ScrapeWarningCode}
|
|
910
1114
|
* for what each one means. The codes are stable and safe to switch on, but
|
|
911
1115
|
* the array stays widened to `string` so a newly introduced code doesn't
|
|
@@ -957,7 +1161,8 @@ interface MapLocation {
|
|
|
957
1161
|
}
|
|
958
1162
|
/**
|
|
959
1163
|
* What a map returns, sent as {@link MapRequest.entries}: `pages` (page
|
|
960
|
-
* addresses, the default), `sitemaps` (sitemap files
|
|
1164
|
+
* addresses, the default), `sitemaps` (sitemap files, of type `sitemap` or
|
|
1165
|
+
* `sitemap_index`) or `all` (both).
|
|
961
1166
|
*/
|
|
962
1167
|
type MapEntries = 'pages' | 'sitemaps' | 'all';
|
|
963
1168
|
/** Request body for `POST /api/map`. */
|
|
@@ -968,8 +1173,9 @@ interface MapRequest {
|
|
|
968
1173
|
*/
|
|
969
1174
|
url: string;
|
|
970
1175
|
/**
|
|
971
|
-
* Proxy tier
|
|
972
|
-
*
|
|
1176
|
+
* Proxy tier. Defaults to `auto`: we start on basic and move to a stronger
|
|
1177
|
+
* proxy on our own when a site needs it, billed at the delivered tier.
|
|
1178
|
+
* `basic` or `advanced` pins the tier.
|
|
973
1179
|
*/
|
|
974
1180
|
proxy?: ProxyTier;
|
|
975
1181
|
/**
|
|
@@ -1002,12 +1208,20 @@ interface MapRequest {
|
|
|
1002
1208
|
*
|
|
1003
1209
|
* With `sitemap_url`, level 0 is that file, and it is read. Without it,
|
|
1004
1210
|
* level 0 is the list of the site's top sitemap files, which `depth: 0`
|
|
1005
|
-
* returns without reading
|
|
1006
|
-
*
|
|
1211
|
+
* returns without reading their entries. A top file found at one of the
|
|
1212
|
+
* usual addresses can still show as `sitemap_index`, because finding it
|
|
1213
|
+
* shows its kind.
|
|
1007
1214
|
*
|
|
1008
1215
|
* A sitemap index holds only sitemap files, so reading one at a low depth
|
|
1009
1216
|
* with `entries: 'pages'` returns no pages. Ask with `entries: 'sitemaps'`
|
|
1010
1217
|
* or a higher depth.
|
|
1218
|
+
*
|
|
1219
|
+
* `{ depth: 1, entries: 'sitemaps' }` lists the site's top sitemap files and
|
|
1220
|
+
* every file they list, in one call. A listed file shows as `sitemap` until
|
|
1221
|
+
* a map opens it, even when it is a sitemap index itself. To go deeper, read
|
|
1222
|
+
* a listed file with `sitemap_url`, or ask with a higher depth. A large site
|
|
1223
|
+
* can reach `max_results` or a discovery limit first;
|
|
1224
|
+
* {@link MapTruncation.discovery_cap_reason} then says which.
|
|
1011
1225
|
*/
|
|
1012
1226
|
depth?: number;
|
|
1013
1227
|
/**
|
|
@@ -1019,9 +1233,13 @@ interface MapRequest {
|
|
|
1019
1233
|
* An ISO 8601 date and time with a zone, such as `2026-11-01T00:00:00Z`.
|
|
1020
1234
|
* Only entries whose `lastmod` is at or after it come back. An entry with no
|
|
1021
1235
|
* `lastmod` is left out, so every entry returned matches; links found on the
|
|
1022
|
-
* home page have no `lastmod`, so none of them is returned.
|
|
1023
|
-
*
|
|
1024
|
-
*
|
|
1236
|
+
* home page have no `lastmod`, so none of them is returned.
|
|
1237
|
+
*
|
|
1238
|
+
* Every sitemap file is read whatever its own `lastmod`, and each entry
|
|
1239
|
+
* returned, a page or a sitemap file, is judged by its own `lastmod`. With
|
|
1240
|
+
* `entries: 'sitemaps'`, a sitemap file is returned when its own `lastmod`
|
|
1241
|
+
* matches, not when a page in it does: to find the pages that changed, ask
|
|
1242
|
+
* with `entries: 'pages'`.
|
|
1025
1243
|
*
|
|
1026
1244
|
* A request with this field is always mapped fresh: it never reads from or
|
|
1027
1245
|
* adds to the cache, and each call is priced as a fresh map.
|
|
@@ -1060,12 +1278,22 @@ interface MapRequest {
|
|
|
1060
1278
|
zero_data_retention?: boolean;
|
|
1061
1279
|
}
|
|
1062
1280
|
/**
|
|
1063
|
-
* What a link in a map result is:
|
|
1064
|
-
*
|
|
1065
|
-
*
|
|
1066
|
-
*
|
|
1281
|
+
* What a link in a map result is:
|
|
1282
|
+
*
|
|
1283
|
+
* - `page`: a page address.
|
|
1284
|
+
* - `sitemap_index`: a sitemap file that this map found to be a sitemap index
|
|
1285
|
+
* (a file that lists other sitemap files), whether it read all of the file,
|
|
1286
|
+
* part of it, or only its start. Such a file can also be in
|
|
1287
|
+
* {@link MapTruncation.unread_sitemaps} when this map did not read all of
|
|
1288
|
+
* it.
|
|
1289
|
+
* - `sitemap`: any other sitemap file: one that lists pages, or one whose kind
|
|
1290
|
+
* this map did not learn (past `depth`, or it could not be read).
|
|
1291
|
+
*
|
|
1292
|
+
* Read a `sitemap` or `sitemap_index` file with `sitemap_url` in another call.
|
|
1293
|
+
* A file on another site is read that way only when the site's robots.txt
|
|
1294
|
+
* names its host.
|
|
1067
1295
|
*/
|
|
1068
|
-
type MapLinkType = 'page' | 'sitemap';
|
|
1296
|
+
type MapLinkType = 'page' | 'sitemap' | 'sitemap_index';
|
|
1069
1297
|
/** Single discovered URL in a map result. */
|
|
1070
1298
|
interface MapLinkItem {
|
|
1071
1299
|
/**
|
|
@@ -1074,8 +1302,9 @@ interface MapLinkItem {
|
|
|
1074
1302
|
*/
|
|
1075
1303
|
url: string;
|
|
1076
1304
|
/**
|
|
1077
|
-
* `page` for a page address
|
|
1078
|
-
* `sitemap_url` in another call
|
|
1305
|
+
* `page` for a page address; `sitemap` or `sitemap_index` for a sitemap file
|
|
1306
|
+
* you can read with `sitemap_url` in another call (see {@link MapLinkType}).
|
|
1307
|
+
* A link found on the home page is a `page`.
|
|
1079
1308
|
*/
|
|
1080
1309
|
type: MapLinkType;
|
|
1081
1310
|
/**
|
|
@@ -1105,8 +1334,10 @@ interface MapPagination {
|
|
|
1105
1334
|
* again with a higher one to get more.
|
|
1106
1335
|
* - `depth`: there are sitemap files past the `depth` you asked for. That is
|
|
1107
1336
|
* the answer to the depth you chose, not a fault: with `depth: 0` it is how
|
|
1108
|
-
* a site's top sitemap files are listed
|
|
1109
|
-
*
|
|
1337
|
+
* a site's top sitemap files are listed, and with `depth: 1` and
|
|
1338
|
+
* `entries: 'sitemaps'` how the top files and every file they list are
|
|
1339
|
+
* listed. The files past it are in {@link MapTruncation.unread_sitemaps};
|
|
1340
|
+
* read each one with `sitemap_url`, or ask with a higher depth.
|
|
1110
1341
|
* - `time`: discovery ran out of its time budget.
|
|
1111
1342
|
* - `file_budget`: the site has more sitemap files than one request reads.
|
|
1112
1343
|
* - `file_size`: a sitemap file was too large. A file that says up front
|
|
@@ -1858,5 +2089,5 @@ interface VerifyWebhookSignatureOptions {
|
|
|
1858
2089
|
*/
|
|
1859
2090
|
declare function verifyWebhookSignature(options: VerifyWebhookSignatureOptions): Promise<WebhookVerificationResult>;
|
|
1860
2091
|
//#endregion
|
|
1861
|
-
export { AntibotBlockedError, ApiErrorDetails, ApiErrorName, ApiErrorResponse, AsyncJobStatus, AsyncJobStatusResponse, AsyncScrapeRequest, AsyncScrapeResponse, AsyncScrapeWebhook, AuthenticationError, BillingEngine, Crawlbrulee, CrawlbruleeError, type CrawlbruleeOptions, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, type HttpMethod, MapBillingEngine, MapCache, MapDiscoveryCapReason, MapEntries, MapLinkItem, MapLinkType, MapLocation, MapPagination, MapRequest, MapResponse, MapResponseMeta, MapTruncation, MapTypes, MapUsage, NotFoundError, PageInlineImage, PageLink, PageTooLargeError, PdfLayout, PdfMedia, PdfPaper, PdfRequest, PdfResult, ProxyTier, RateLimitError, RateLimitErrorDetails, type RequestOptions, ResolvedProxyTier, ResponseMeta, ScrapeCache, ScrapeCleanup, ScrapeCompleteWebhook, ScrapeCompleteWebhookData, ScrapeCookie, ScrapeElementFieldSpec, ScrapeElementLeafSpec, ScrapeElementNestedFieldSpec, ScrapeElementObject, ScrapeElementOutput, ScrapeElementSpec, ScrapeElementValue, ScrapeElements, ScrapeExtract, ScrapeLocation, ScrapeMetadata, ScrapeRequest, ScrapeResponse, ScrapeWarningCode, ScrapeWebhookStatus, ScreenshotAfterAction, ScreenshotBeforeAction, ScreenshotColorScheme, ScreenshotDeviceMode, ScreenshotProperties, ScreenshotRequest, ScreenshotResult, ScreenshotScrollAction, ScreenshotSlice, ScreenshotSliceAction, ScreenshotType, ScreenshotViewport, ScreenshotViewportInfo, ScreenshotWaitAction, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, Usage, UsageAllocationError, UsageAllocationErrorDetails, UsageAllocationReason, UsageLimitDetails, UsageResponse, ValidationError, type VerifyWebhookSignatureOptions, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, type WaitForScrapeOptions, type WebhookSignatureSource, type WebhookVerificationFailureReason, type WebhookVerificationResult, WhoamiResponse, ZeroDataRetentionNotEnabledError, isCrawlbruleeError, verifyWebhookSignature };
|
|
2092
|
+
export { AntibotBlockedError, ApiErrorDetails, ApiErrorName, ApiErrorResponse, AsyncJobStatus, AsyncJobStatusResponse, AsyncScrapeRequest, AsyncScrapeResponse, AsyncScrapeWebhook, AuthenticationError, BillingEngine, Crawlbrulee, CrawlbruleeError, type CrawlbruleeOptions, DEFAULT_BASE_URL, DEFAULT_REQUEST_TIMEOUT_MS, DEFAULT_WEBHOOK_TOLERANCE_SECONDS, ENV_API_KEY, type HttpMethod, MapBillingEngine, MapCache, MapDiscoveryCapReason, MapEntries, MapLinkItem, MapLinkType, MapLocation, MapPagination, MapRequest, MapResponse, MapResponseMeta, MapTruncation, MapTypes, MapUsage, NotFoundError, PageInlineImage, PageLink, PageTooLargeError, PdfLayout, PdfMedia, PdfPaper, PdfRequest, PdfResult, ProxyTier, RateLimitError, RateLimitErrorDetails, type RequestOptions, ResolvedProxyTier, ResponseMeta, ScrapeAction, ScrapeActionResult, ScrapeActionStatus, ScrapeActionType, ScrapeCache, ScrapeCleanup, ScrapeClickAction, ScrapeCompleteWebhook, ScrapeCompleteWebhookData, ScrapeCookie, ScrapeElementFieldSpec, ScrapeElementLeafSpec, ScrapeElementNestedFieldSpec, ScrapeElementObject, ScrapeElementOutput, ScrapeElementSpec, ScrapeElementValue, ScrapeElements, ScrapeExtract, ScrapeHoverAction, ScrapeLocation, ScrapeMetadata, ScrapeRequest, ScrapeResponse, ScrapeScrollAction, ScrapeScrollByAction, ScrapeScrollToAction, ScrapeSelectAction, ScrapeTypeAction, ScrapeWaitAction, ScrapeWaitForAction, ScrapeWarningCode, ScrapeWebhookStatus, ScreenshotAfterAction, ScreenshotBeforeAction, ScreenshotColorScheme, ScreenshotDeviceMode, ScreenshotProperties, ScreenshotRequest, ScreenshotResult, ScreenshotScrollAction, ScreenshotSlice, ScreenshotSliceAction, ScreenshotType, ScreenshotViewport, ScreenshotViewportInfo, ScreenshotWaitAction, ServiceUnavailableError, TargetUnreachableError, TooManyRedirectsError, TransportError, Usage, UsageAllocationError, UsageAllocationErrorDetails, UsageAllocationReason, UsageLimitDetails, UsageResponse, ValidationError, type VerifyWebhookSignatureOptions, WEBHOOK_EVENT_ID_HEADER, WEBHOOK_SIGNATURE_HEADER, WEBHOOK_SIGNATURE_ROTATED_HEADER, type WaitForScrapeOptions, type WebhookSignatureSource, type WebhookVerificationFailureReason, type WebhookVerificationResult, WhoamiResponse, ZeroDataRetentionNotEnabledError, isCrawlbruleeError, verifyWebhookSignature };
|
|
1862
2093
|
//# sourceMappingURL=index.d.cts.map
|