@scrapa/sdk 0.3.0 → 0.4.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 +30 -0
- package/dist/generated/contract.d.ts +47 -4
- package/dist/generated/contract.d.ts.map +1 -1
- package/dist/generated/contract.js +11 -4
- package/dist/generated/contract.js.map +1 -1
- package/dist/generated/operations.d.ts +34 -4
- package/dist/generated/operations.d.ts.map +1 -1
- package/dist/generated/operations.js +46 -2
- package/dist/generated/operations.js.map +1 -1
- package/dist/generated/params.d.ts +128 -16
- package/dist/generated/params.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/generated/contract.ts +57 -4
- package/src/generated/operations.ts +66 -2
- package/src/generated/params.ts +130 -16
package/README.md
CHANGED
|
@@ -39,6 +39,17 @@ page.links; // every absolute link, in document order
|
|
|
39
39
|
page.metadata.title;
|
|
40
40
|
```
|
|
41
41
|
|
|
42
|
+
`markdown` and `text` hold the page's main content, without the menus, the share buttons or
|
|
43
|
+
the related posts. Send `onlyMainContent: false` for the whole page, or pick the parts
|
|
44
|
+
yourself with CSS selectors:
|
|
45
|
+
|
|
46
|
+
```ts
|
|
47
|
+
const post = await scrapa.scrape({ url: "https://example.com/blog/hello", includeTags: ["article"] });
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
A link to a PDF or a Word file comes back as text too, and `metadata.pages` says how many
|
|
51
|
+
pages the PDF has.
|
|
52
|
+
|
|
42
53
|
Ask for a screenshot or a PDF and the browser is used whatever `engine` says. Both come back
|
|
43
54
|
base64-encoded, and asking for both costs no more than asking for one.
|
|
44
55
|
|
|
@@ -98,6 +109,25 @@ read any result, hand its URL straight to `scrape()`.
|
|
|
98
109
|
A search every front refused costs nothing. A search that ran and found nothing is charged.
|
|
99
110
|
The index answered, and "nothing published that" is an answer.
|
|
100
111
|
|
|
112
|
+
## Listing a site's pages
|
|
113
|
+
|
|
114
|
+
`map()` hands back every URL a site lists, without reading the pages. The list comes from the
|
|
115
|
+
site's robots.txt, its sitemaps (gzipped ones and indexes too) and the links on the page you
|
|
116
|
+
name.
|
|
117
|
+
|
|
118
|
+
```ts
|
|
119
|
+
const { urls } = await scrapa.map({ url: "https://example.com" });
|
|
120
|
+
|
|
121
|
+
urls[0]; // { url: "https://example.com", lastmod: "2026-10-01" }
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
Each URL comes back once, without `utm_` parameters, a `#` part or a trailing slash. Only the
|
|
125
|
+
host you named is kept unless you pass `includeSubdomains: true`, and `search: "blog"` keeps
|
|
126
|
+
the URLs that contain the word. `truncated: true` means the site may list more than you got.
|
|
127
|
+
|
|
128
|
+
The price does not change with what a map finds. Only managed-pool bandwidth past the first
|
|
129
|
+
megabyte is added. Price one first with `quoteMap()`.
|
|
130
|
+
|
|
101
131
|
## Driving a real browser
|
|
102
132
|
|
|
103
133
|
A session is one Chromium held for you, with a CDP URL your own tools connect to. We hand
|
|
@@ -4,12 +4,13 @@
|
|
|
4
4
|
* locale catalogs, exhaustiveness checks).
|
|
5
5
|
*
|
|
6
6
|
* THE WHOSE-FAULT VOCABULARY (DESIGN.md) is the organising principle: a caller's next move
|
|
7
|
-
* depends entirely on who said no, so the code says. `UPSTREAM_BLOCKED`
|
|
8
|
-
*
|
|
7
|
+
* depends entirely on who said no, so the code says. `UPSTREAM_BLOCKED` is "the site said no"
|
|
8
|
+
* (retry differently — another engine, pool or country), and `NAV_TIMEOUT` shares its hue under
|
|
9
|
+
* its own word, "time ran out" (give it more time; see `OWN_WORD`); `SSRF_DENIED` /
|
|
9
10
|
* `AUP_DENIED` are "our policy said no" (retrying cannot help, change the URL); a 5xx is
|
|
10
11
|
* "we broke it" (retry as-is, already refunded).
|
|
11
12
|
*/
|
|
12
|
-
export declare const ERROR_CODES: readonly ["VALIDATION_ERROR", "INVALID_URL", "SSRF_DENIED", "UNAUTHORIZED", "INVALID_TOKEN", "PLAN_GATE", "FORBIDDEN", "AUP_DENIED", "NOT_FOUND", "SESSION_NOT_FOUND", "CONFLICT", "PAYLOAD_TOO_LARGE", "UPSTREAM_BLOCKED", "NAV_TIMEOUT", "PROXY_REFUSED", "FILE_TOO_LARGE", "RATE_LIMIT_EXCEEDED", "QUOTA_EXCEEDED", "INTERNAL_ERROR", "SERVICE_UNAVAILABLE", "BILLING_UNAVAILABLE"];
|
|
13
|
+
export declare const ERROR_CODES: readonly ["VALIDATION_ERROR", "INVALID_URL", "SSRF_DENIED", "UNAUTHORIZED", "INVALID_TOKEN", "PLAN_GATE", "FORBIDDEN", "AUP_DENIED", "NOT_FOUND", "SESSION_NOT_FOUND", "CONFLICT", "PAYLOAD_TOO_LARGE", "UPSTREAM_BLOCKED", "NAV_TIMEOUT", "PROXY_REFUSED", "FILE_TOO_LARGE", "DOCUMENT_TIMEOUT", "RATE_LIMIT_EXCEEDED", "QUOTA_EXCEEDED", "INTERNAL_ERROR", "SERVICE_UNAVAILABLE", "BILLING_UNAVAILABLE"];
|
|
13
14
|
export type ErrorCode = (typeof ERROR_CODES)[number];
|
|
14
15
|
/** The status each code answers with. The server's error factory, the SDK's fallback and
|
|
15
16
|
* the docs' errors table all read this one map — three copies could drift, one cannot. */
|
|
@@ -30,6 +31,7 @@ export declare const ERROR_STATUS: {
|
|
|
30
31
|
readonly NAV_TIMEOUT: 422;
|
|
31
32
|
readonly PROXY_REFUSED: 422;
|
|
32
33
|
readonly FILE_TOO_LARGE: 422;
|
|
34
|
+
readonly DOCUMENT_TIMEOUT: 422;
|
|
33
35
|
readonly RATE_LIMIT_EXCEEDED: 429;
|
|
34
36
|
readonly QUOTA_EXCEEDED: 429;
|
|
35
37
|
readonly INTERNAL_ERROR: 500;
|
|
@@ -41,7 +43,7 @@ export declare const ERROR_STATUS: {
|
|
|
41
43
|
* — this is the map the console reads to pick the hue and the word, and the SDK reads to
|
|
42
44
|
* tell a caller what to do next. A code absent from here gets no colour: the caller's own
|
|
43
45
|
* mistake (a bad body, a missing key), or a free refusal whose fix is in the request rather
|
|
44
|
-
* than the site (PROXY_REFUSED, FILE_TOO_LARGE).
|
|
46
|
+
* than the site (PROXY_REFUSED, FILE_TOO_LARGE, DOCUMENT_TIMEOUT).
|
|
45
47
|
*
|
|
46
48
|
* blocked → the site said no → try another engine, pool or country
|
|
47
49
|
* denied → our policy said no → change the URL; retrying cannot help
|
|
@@ -136,6 +138,8 @@ export type SearchTopic = (typeof SEARCH_TOPICS)[number];
|
|
|
136
138
|
* one it was, because a result set's flavour follows its index. */
|
|
137
139
|
export declare const SEARCH_ENGINES: readonly ["bing", "brave", "duckduckgo"];
|
|
138
140
|
export type SearchEngine = (typeof SEARCH_ENGINES)[number];
|
|
141
|
+
/** Where a map's URLs came from. With none found, the sources that were read. */
|
|
142
|
+
export type MapSource = "sitemap" | "links" | "both";
|
|
139
143
|
/** A batch's life. `queued` is accepted but not yet picked up; `running` has at least one
|
|
140
144
|
* item in flight. The three end states answer the same question the session statuses do —
|
|
141
145
|
* who ended it: `completed` ran every item to a verdict (some of which may be failures,
|
|
@@ -186,6 +190,12 @@ export interface ScrapeMetadataDto {
|
|
|
186
190
|
* it so a caller can retry with `engine: "browser"` instead of trusting an empty page.
|
|
187
191
|
* Always false from the browser engine, which ran the scripts. */
|
|
188
192
|
needsJs: boolean;
|
|
193
|
+
/** How many pages the PDF has, when a PDF was read into text. Absent for anything else,
|
|
194
|
+
* and when only "raw" was asked for. */
|
|
195
|
+
pages?: number;
|
|
196
|
+
/** True when the PDF has more pages than we read: the first 200 are in the answer and the
|
|
197
|
+
* rest are not. Absent otherwise. */
|
|
198
|
+
truncated?: boolean;
|
|
189
199
|
}
|
|
190
200
|
/** A file, exactly as the site sent it. */
|
|
191
201
|
export interface ScrapeRawDto {
|
|
@@ -365,6 +375,39 @@ export interface CreatedBatchDto extends BatchDto {
|
|
|
365
375
|
* delivery somebody copied can be sent to you again. */
|
|
366
376
|
webhookSecret?: string;
|
|
367
377
|
}
|
|
378
|
+
/** One URL a site lists, normalised: no fragment, no `utm_*` parameters, the query sorted,
|
|
379
|
+
* no trailing slash. */
|
|
380
|
+
export interface MapUrlDto {
|
|
381
|
+
url: string;
|
|
382
|
+
/** When the sitemap says the page last changed, as the sitemap wrote it (a W3C date, often
|
|
383
|
+
* just the day). Absent when it did not say, or when the URL came from the page's links. */
|
|
384
|
+
lastmod?: string;
|
|
385
|
+
}
|
|
386
|
+
/** `POST /v1/map`'s answer. */
|
|
387
|
+
export interface MapResultDto {
|
|
388
|
+
/** Every URL found, once each, sitemap URLs first in the order the site listed them. */
|
|
389
|
+
urls: MapUrlDto[];
|
|
390
|
+
/** Where they came from. With none found, the sources that were read. */
|
|
391
|
+
source: MapSource;
|
|
392
|
+
/** True when the site may list more than this answer holds: `limit` cut the list, or the
|
|
393
|
+
* robots.txt or a sitemap was not read to its end (the site refused it, its size, the
|
|
394
|
+
* 25-document cap, or the time limit). */
|
|
395
|
+
truncated: boolean;
|
|
396
|
+
pool: ProxyPool;
|
|
397
|
+
/** What the managed pool carried for every document the map read, decompressed. The
|
|
398
|
+
* first megabyte is free; past it, bandwidth is metered like any request's. */
|
|
399
|
+
bytes: number;
|
|
400
|
+
}
|
|
401
|
+
/** What a map would cost, without making it. */
|
|
402
|
+
export interface MapQuoteDto {
|
|
403
|
+
pool: ProxyPool;
|
|
404
|
+
/** Credits a map charges, whatever it finds. */
|
|
405
|
+
cost: number;
|
|
406
|
+
/** Managed-pool megabytes included before `perMb` applies. 0 on BYO. */
|
|
407
|
+
freeMb: number;
|
|
408
|
+
/** Credits per additional megabyte through the managed pool. 0 on BYO. */
|
|
409
|
+
perMb: number;
|
|
410
|
+
}
|
|
368
411
|
/** One hit, as the index ranked it. The array's ORDER is the ranking — there is no score,
|
|
369
412
|
* because no engine we read publishes one and a rank-derived float would be a made-up
|
|
370
413
|
* number in a public contract. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.d.ts","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAOA
|
|
1
|
+
{"version":3,"file":"contract.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D;;kCAEkC;AAClC,MAAM,WAAW,WAAW;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,OAAO,CAAC;IACjB,2DAA2D;IAC3D,OAAO,EAAE,MAAM,CAAC;IAChB;mEAC+D;IAC/D,KAAK,EAAE,MAAM,CAAC;CACjB;AAED,sFAAsF;AACtF,MAAM,WAAW,QAAQ;IACrB,IAAI,EAAE,MAAM,CAAC;IACb,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,uDAAuD;IACvD,WAAW,EAAE,MAAM,CAAC;IACpB,gCAAgC;IAChC,eAAe,EAAE,MAAM,CAAC;IACxB;+FAC2F;IAC3F,aAAa,EAAE,MAAM,CAAC;IACtB,gFAAgF;IAChF,WAAW,EAAE,MAAM,CAAC;IACpB,eAAe,EAAE,MAAM,CAAC;IACxB,uFAAuF;IACvF,OAAO,EAAE,MAAM,CAAC;IAChB,IAAI,EAAE,WAAW,EAAE,CAAC;CACvB"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// GENERATED FILE — do not edit. Run `bun run sdk:gen`.
|
|
2
|
-
// Source: packages/shared/src/http/index.ts, packages/shared/src/locale/index.ts, packages/shared/src/enums/index.ts, packages/shared/src/billing/catalog.ts, packages/shared/src/dto/account.ts, packages/shared/src/dto/scrape.ts, packages/shared/src/dto/batch.ts, packages/shared/src/dto/search.ts, packages/shared/src/dto/sessions.ts, packages/shared/src/dto/usage.ts
|
|
2
|
+
// Source: packages/shared/src/http/index.ts, packages/shared/src/locale/index.ts, packages/shared/src/enums/index.ts, packages/shared/src/billing/catalog.ts, packages/shared/src/dto/account.ts, packages/shared/src/dto/scrape.ts, packages/shared/src/dto/batch.ts, packages/shared/src/dto/map.ts, packages/shared/src/dto/search.ts, packages/shared/src/dto/sessions.ts, packages/shared/src/dto/usage.ts
|
|
3
3
|
//
|
|
4
4
|
// The shapes the API speaks, lifted from the server's own contract.
|
|
5
5
|
// ── from packages/shared/src/http/index.ts ───────────────────────────
|
|
@@ -9,8 +9,9 @@
|
|
|
9
9
|
* locale catalogs, exhaustiveness checks).
|
|
10
10
|
*
|
|
11
11
|
* THE WHOSE-FAULT VOCABULARY (DESIGN.md) is the organising principle: a caller's next move
|
|
12
|
-
* depends entirely on who said no, so the code says. `UPSTREAM_BLOCKED`
|
|
13
|
-
*
|
|
12
|
+
* depends entirely on who said no, so the code says. `UPSTREAM_BLOCKED` is "the site said no"
|
|
13
|
+
* (retry differently — another engine, pool or country), and `NAV_TIMEOUT` shares its hue under
|
|
14
|
+
* its own word, "time ran out" (give it more time; see `OWN_WORD`); `SSRF_DENIED` /
|
|
14
15
|
* `AUP_DENIED` are "our policy said no" (retrying cannot help, change the URL); a 5xx is
|
|
15
16
|
* "we broke it" (retry as-is, already refunded).
|
|
16
17
|
*/
|
|
@@ -46,6 +47,11 @@ export const ERROR_CODES = [
|
|
|
46
47
|
// client its OWN request was too big. Free, and no colour, for PROXY_REFUSED's reason:
|
|
47
48
|
// the fix is in the request (another format, or download it yourself), not another road.
|
|
48
49
|
"FILE_TOO_LARGE", // 422 — details {limit}, in bytes
|
|
50
|
+
// A PDF or a Word file arrived whole, and reading it into text took longer than the time
|
|
51
|
+
// the call had left. Free, and no colour: the site answered in full, so another engine,
|
|
52
|
+
// pool or country reads the same file just as slowly. The fix is more `timeoutMs`, or
|
|
53
|
+
// "raw" and reading it yourself.
|
|
54
|
+
"DOCUMENT_TIMEOUT", // 422: details {budgetMs}, the call's timeout
|
|
49
55
|
"RATE_LIMIT_EXCEEDED", // 429 — the per-minute burst bucket; Retry-After + details {limit}
|
|
50
56
|
"QUOTA_EXCEEDED", // 429 — a durable bound that WAITING clears; details {scope, limit, resetAt}
|
|
51
57
|
"INTERNAL_ERROR", // 500 — we broke it; the body is always generic, the cause stays server-side
|
|
@@ -71,6 +77,7 @@ export const ERROR_STATUS = {
|
|
|
71
77
|
NAV_TIMEOUT: 422,
|
|
72
78
|
PROXY_REFUSED: 422,
|
|
73
79
|
FILE_TOO_LARGE: 422,
|
|
80
|
+
DOCUMENT_TIMEOUT: 422,
|
|
74
81
|
RATE_LIMIT_EXCEEDED: 429,
|
|
75
82
|
QUOTA_EXCEEDED: 429,
|
|
76
83
|
INTERNAL_ERROR: 500,
|
|
@@ -82,7 +89,7 @@ export const ERROR_STATUS = {
|
|
|
82
89
|
* — this is the map the console reads to pick the hue and the word, and the SDK reads to
|
|
83
90
|
* tell a caller what to do next. A code absent from here gets no colour: the caller's own
|
|
84
91
|
* mistake (a bad body, a missing key), or a free refusal whose fix is in the request rather
|
|
85
|
-
* than the site (PROXY_REFUSED, FILE_TOO_LARGE).
|
|
92
|
+
* than the site (PROXY_REFUSED, FILE_TOO_LARGE, DOCUMENT_TIMEOUT).
|
|
86
93
|
*
|
|
87
94
|
* blocked → the site said no → try another engine, pool or country
|
|
88
95
|
* denied → our policy said no → change the URL; retrying cannot help
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,
|
|
1
|
+
{"version":3,"file":"contract.js","sourceRoot":"","sources":["../../src/generated/contract.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,gZAAgZ;AAChZ,EAAE;AACF,oEAAoE;AAEpE,wEAAwE;AAExE;;;;;;;;;;;GAWG;AACH,MAAM,CAAC,MAAM,WAAW,GAAG;IACvB,kBAAkB,EAAE,iFAAiF;IACrG,aAAa,EAAE,+DAA+D;IAC9E,aAAa,EAAE,sFAAsF;IACrG,cAAc,EAAE,gCAAgC;IAChD,eAAe,EAAE,6EAA6E;IAC9F,oFAAoF;IACpF,mFAAmF;IACnF,qFAAqF;IACrF,uFAAuF;IACvF,qFAAqF;IACrF,WAAW,EAAE,2EAA2E;IACxF,WAAW,EAAE,uCAAuC;IACpD,YAAY,EAAE,yEAAyE;IACvF,WAAW,EAAE,u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EAImE;AACnE,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,UAAU,EAAE,QAAQ,CAAU,CAAC;AAIhG;;;;;eAKe;AACf,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,SAAS,CAAU,CAAC;AAI/F;;;;;;8BAM8B;AAC9B,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,iBAAiB,EAAE,sBAAsB,CAAU,CAAC;AAInF;;;kBAGkB;AAClB,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAU,CAAC"}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { RequestOptions, RequestSpec } from "../client.js";
|
|
2
|
-
import type { BatchDto, BatchQuoteDto, CreatedBatchDto, LiveSessionDto, ScrapeQuoteDto, ScrapeResultDto, SearchResultDto, SessionDto, SessionQuoteDto, UsageDto } from "./contract.js";
|
|
3
|
-
import type { CancelBatchParams, CloseSessionParams, CreateBatchParams, CreateSessionParams, GetBatchParams, GetSessionParams, ListBatchesParams, ListSessionsParams, QuoteBatchParams, QuoteScrapeParams, QuoteSessionParams, ScrapeParams, SearchParams } from "./params.js";
|
|
2
|
+
import type { BatchDto, BatchQuoteDto, CreatedBatchDto, LiveSessionDto, MapQuoteDto, MapResultDto, ScrapeQuoteDto, ScrapeResultDto, SearchResultDto, SessionDto, SessionQuoteDto, UsageDto } from "./contract.js";
|
|
3
|
+
import type { CancelBatchParams, CloseSessionParams, CreateBatchParams, CreateSessionParams, GetBatchParams, GetSessionParams, ListBatchesParams, ListSessionsParams, MapSiteParams, QuoteBatchParams, QuoteMapParams, QuoteScrapeParams, QuoteSessionParams, ScrapeParams, SearchParams } from "./params.js";
|
|
4
4
|
/** The version this client reports in `x-scrapa-client`. */
|
|
5
|
-
export declare const SDK_VERSION = "0.
|
|
5
|
+
export declare const SDK_VERSION = "0.4.0";
|
|
6
6
|
/** The hosted API. */
|
|
7
7
|
export declare const DEFAULT_BASE_URL = "https://api.scrapa.app/v1";
|
|
8
8
|
export declare abstract class GeneratedOperations {
|
|
@@ -15,7 +15,8 @@ export declare abstract class GeneratedOperations {
|
|
|
15
15
|
* makes a plain HTTP request first and re-reads the page in a real Chromium when the body
|
|
16
16
|
* turns out to be a JavaScript shell, so you pay for a browser only when the page needed one.
|
|
17
17
|
* To send a search form or a JSON query, use `method: "POST"` with a `body`; to download a
|
|
18
|
-
* file exactly as the site sent it, ask for `formats: ["raw"]`.
|
|
18
|
+
* file exactly as the site sent it, ask for `formats: ["raw"]`. A link to a PDF or a Word file
|
|
19
|
+
* is read into text too, headings and paragraphs included. Every request leaves through a
|
|
19
20
|
* residential proxy, or through your own with `proxy: { pool: "custom", server }`. The answer
|
|
20
21
|
* says which engine replied, where the page finally was and what it cost.
|
|
21
22
|
*
|
|
@@ -40,6 +41,35 @@ export declare abstract class GeneratedOperations {
|
|
|
40
41
|
* `POST /v1/scrape/quote`
|
|
41
42
|
*/
|
|
42
43
|
quote(params: QuoteScrapeParams, opts?: Omit<RequestOptions, "idempotencyKey">): Promise<ScrapeQuoteDto>;
|
|
44
|
+
/**
|
|
45
|
+
* List a site's URLs
|
|
46
|
+
*
|
|
47
|
+
* Hand back every URL a site lists, without reading the pages: what its robots.txt and
|
|
48
|
+
* sitemaps name (gzipped ones too, and indexes of sitemaps), plus the links on the page you
|
|
49
|
+
* named. Each URL comes back once, without tracking parameters or a trailing slash, with
|
|
50
|
+
* `lastmod` when the sitemap gives one. Only the host you named is kept unless you set
|
|
51
|
+
* `includeSubdomains`, and `search` keeps the URLs that contain a word. To read a page, pass
|
|
52
|
+
* its URL to `scrape`.
|
|
53
|
+
*
|
|
54
|
+
* Credits: 2 credits, plus managed-proxy bandwidth past the first megabyte, every file the map
|
|
55
|
+
* read counted together. A site that lists nothing is charged, because it answered. A site
|
|
56
|
+
* that refused every file, and anything we broke, cost nothing.
|
|
57
|
+
*
|
|
58
|
+
* `POST /v1/map`
|
|
59
|
+
*/
|
|
60
|
+
map(params: MapSiteParams, opts?: Omit<RequestOptions, "idempotencyKey">): Promise<MapResultDto>;
|
|
61
|
+
/**
|
|
62
|
+
* Price a map
|
|
63
|
+
*
|
|
64
|
+
* What the same map would cost, without making it. Free, and refused by the same guards a real
|
|
65
|
+
* call meets. Bandwidth is priced per megabyte because nobody knows a site's sitemap size
|
|
66
|
+
* before reading it.
|
|
67
|
+
*
|
|
68
|
+
* Credits: 0 credits. Pricing a call is free.
|
|
69
|
+
*
|
|
70
|
+
* `POST /v1/map/quote`
|
|
71
|
+
*/
|
|
72
|
+
quoteMap(params: QuoteMapParams, opts?: Omit<RequestOptions, "idempotencyKey">): Promise<MapQuoteDto>;
|
|
43
73
|
/**
|
|
44
74
|
* Search the web
|
|
45
75
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/generated/operations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EACR,QAAQ,EACR,aAAa,EACb,eAAe,EACf,cAAc,EACd,cAAc,EACd,eAAe,EACf,eAAe,EACf,UAAU,EACV,eAAe,EACf,QAAQ,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACR,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACf,MAAM,aAAa,CAAC;AAErB,4DAA4D;AAC5D,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,sBAAsB;AACtB,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAE5D,8BAAsB,mBAAmB;IACrC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EACxB,IAAI,EAAE,WAAW,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,CAAC,CAAC;IAEb
|
|
1
|
+
{"version":3,"file":"operations.d.ts","sourceRoot":"","sources":["../../src/generated/operations.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,KAAK,EACR,QAAQ,EACR,aAAa,EACb,eAAe,EACf,cAAc,EACd,WAAW,EACX,YAAY,EACZ,cAAc,EACd,eAAe,EACf,eAAe,EACf,UAAU,EACV,eAAe,EACf,QAAQ,EACX,MAAM,eAAe,CAAC;AACvB,OAAO,KAAK,EACR,iBAAiB,EACjB,kBAAkB,EAClB,iBAAiB,EACjB,mBAAmB,EACnB,cAAc,EACd,gBAAgB,EAChB,iBAAiB,EACjB,kBAAkB,EAClB,aAAa,EACb,gBAAgB,EAChB,cAAc,EACd,iBAAiB,EACjB,kBAAkB,EAClB,YAAY,EACZ,YAAY,EACf,MAAM,aAAa,CAAC;AAErB,4DAA4D;AAC5D,eAAO,MAAM,WAAW,UAAU,CAAC;AAEnC,sBAAsB;AACtB,eAAO,MAAM,gBAAgB,8BAA8B,CAAC;AAE5D,8BAAsB,mBAAmB;IACrC,SAAS,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EACxB,IAAI,EAAE,WAAW,EACjB,MAAM,CAAC,EAAE,MAAM,EACf,IAAI,CAAC,EAAE,cAAc,GACtB,OAAO,CAAC,CAAC,CAAC;IAEb;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CACF,MAAM,EAAE,YAAY,EACpB,IAAI,CAAC,EAAE,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,GAC9C,OAAO,CAAC,eAAe,CAAC;IAa3B;;;;;;;;;;;OAWG;IACH,KAAK,CACD,MAAM,EAAE,iBA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;;;;;;;;WAgBG;0BAEU,mBAAmB,SACrB,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAC9C,OAAO,CAAC,cAAc,CAAC;QAW1B;;;;;;;;;;WAUG;yBAEU,kBAAkB,SACpB,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAC9C,OAAO,CAAC,eAAe,CAAC;QAW3B;;;;;;;;;WASG;wBAEU,kBAAkB,SACpB,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAC9C,OAAO,CAAC,UAAU,EAAE,CAAC;QAExB;;;;;;;;;;WAUG;sBAES,gBAAgB,SACjB,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAC9C,OAAO,CAAC,UAAU,CAAC;QAEtB;;;;;;;;;;;WAWG;wBAES,kBAAkB,SACnB,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAC9C,OAAO,CAAC,UAAU,CAAC;MAMxB;IAEF,QAAQ,CAAC,KAAK;QACV;;;;;;;;;;WAUG;qBACU,IAAI,CAAC,cAAc,EAAE,gBAAgB,CAAC,KAAG,OAAO,CAAC,QAAQ,CAAC;MAEzE;CACL"}
|
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
// One method per capability, grouped the way the docs group them, returning the
|
|
5
5
|
// DTO the operation declares. `Scrapa` in ../client.ts supplies request().
|
|
6
6
|
/** The version this client reports in `x-scrapa-client`. */
|
|
7
|
-
export const SDK_VERSION = "0.
|
|
7
|
+
export const SDK_VERSION = "0.4.0";
|
|
8
8
|
/** The hosted API. */
|
|
9
9
|
export const DEFAULT_BASE_URL = "https://api.scrapa.app/v1";
|
|
10
10
|
export class GeneratedOperations {
|
|
@@ -16,7 +16,8 @@ export class GeneratedOperations {
|
|
|
16
16
|
* makes a plain HTTP request first and re-reads the page in a real Chromium when the body
|
|
17
17
|
* turns out to be a JavaScript shell, so you pay for a browser only when the page needed one.
|
|
18
18
|
* To send a search form or a JSON query, use `method: "POST"` with a `body`; to download a
|
|
19
|
-
* file exactly as the site sent it, ask for `formats: ["raw"]`.
|
|
19
|
+
* file exactly as the site sent it, ask for `formats: ["raw"]`. A link to a PDF or a Word file
|
|
20
|
+
* is read into text too, headings and paragraphs included. Every request leaves through a
|
|
20
21
|
* residential proxy, or through your own with `proxy: { pool: "custom", server }`. The answer
|
|
21
22
|
* says which engine replied, where the page finally was and what it cost.
|
|
22
23
|
*
|
|
@@ -55,6 +56,49 @@ export class GeneratedOperations {
|
|
|
55
56
|
proxy: ["pool", "server", "country", "state", "city"],
|
|
56
57
|
}, params, opts);
|
|
57
58
|
}
|
|
59
|
+
/**
|
|
60
|
+
* List a site's URLs
|
|
61
|
+
*
|
|
62
|
+
* Hand back every URL a site lists, without reading the pages: what its robots.txt and
|
|
63
|
+
* sitemaps name (gzipped ones too, and indexes of sitemaps), plus the links on the page you
|
|
64
|
+
* named. Each URL comes back once, without tracking parameters or a trailing slash, with
|
|
65
|
+
* `lastmod` when the sitemap gives one. Only the host you named is kept unless you set
|
|
66
|
+
* `includeSubdomains`, and `search` keeps the URLs that contain a word. To read a page, pass
|
|
67
|
+
* its URL to `scrape`.
|
|
68
|
+
*
|
|
69
|
+
* Credits: 2 credits, plus managed-proxy bandwidth past the first megabyte, every file the map
|
|
70
|
+
* read counted together. A site that lists nothing is charged, because it answered. A site
|
|
71
|
+
* that refused every file, and anything we broke, cost nothing.
|
|
72
|
+
*
|
|
73
|
+
* `POST /v1/map`
|
|
74
|
+
*/
|
|
75
|
+
map(params, opts) {
|
|
76
|
+
return this.request({
|
|
77
|
+
method: "POST",
|
|
78
|
+
path: "/map",
|
|
79
|
+
repeatable: false,
|
|
80
|
+
proxy: ["pool", "server", "country"],
|
|
81
|
+
}, params, opts);
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Price a map
|
|
85
|
+
*
|
|
86
|
+
* What the same map would cost, without making it. Free, and refused by the same guards a real
|
|
87
|
+
* call meets. Bandwidth is priced per megabyte because nobody knows a site's sitemap size
|
|
88
|
+
* before reading it.
|
|
89
|
+
*
|
|
90
|
+
* Credits: 0 credits. Pricing a call is free.
|
|
91
|
+
*
|
|
92
|
+
* `POST /v1/map/quote`
|
|
93
|
+
*/
|
|
94
|
+
quoteMap(params, opts) {
|
|
95
|
+
return this.request({
|
|
96
|
+
method: "POST",
|
|
97
|
+
path: "/map/quote",
|
|
98
|
+
repeatable: true,
|
|
99
|
+
proxy: ["pool", "server", "country"],
|
|
100
|
+
}, params, opts);
|
|
101
|
+
}
|
|
58
102
|
/**
|
|
59
103
|
* Search the web
|
|
60
104
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/generated/operations.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,0DAA0D;AAC1D,EAAE;AACF,gFAAgF;AAChF,2EAA2E;
|
|
1
|
+
{"version":3,"file":"operations.js","sourceRoot":"","sources":["../../src/generated/operations.ts"],"names":[],"mappings":"AAAA,uDAAuD;AACvD,0DAA0D;AAC1D,EAAE;AACF,gFAAgF;AAChF,2EAA2E;AAmC3E,4DAA4D;AAC5D,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AAEnC,sBAAsB;AACtB,MAAM,CAAC,MAAM,gBAAgB,GAAG,2BAA2B,CAAC;AAE5D,MAAM,OAAgB,mBAAmB;IAOrC;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CACF,MAAoB,EACpB,IAA6C;QAE7C,OAAO,IAAI,CAAC,OAAO,CACf;YACI,MAAM,EAAE,MAAM;YACd,IAAI,EAAE,SAAS;YACf,UAAU,EAAE,KAAK;YACjB,KAAK,EAAE,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,CAAC;SACxD,EACD,MAAM,EACN,IAAI,CACP,CAAC;IACN,CAAC;IAED;;;;;;;;;;;OAWG;IACH,KAAK,CACD,MAAyB,EACzB,IAA6C;QAE7C,OAAO,IAAI,CAAC,OAAO,C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AAE,IAAI,CAAC;KACvE,CAAC;CACL"}
|
|
@@ -29,11 +29,24 @@ export interface ScrapeParams {
|
|
|
29
29
|
retry?: number;
|
|
30
30
|
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
31
31
|
* asking for both costs no more than one. "extract" is the page read into fields by a model,
|
|
32
|
-
* and needs an `extract` block saying which ones.
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
32
|
+
* and needs an `extract` block saying which ones. A link to a PDF or a Word (.docx) file is
|
|
33
|
+
* read into text, so the text formats work on it too. We read files up to 25 MB and the first
|
|
34
|
+
* 200 pages, at the fetch price. "raw" is the file exactly as the site sent it, as base64 with
|
|
35
|
+
* its content type: a PDF report, an image, a spreadsheet. It uses the fetch engine and holds
|
|
36
|
+
* up to 5 MB; a larger file answers FILE_TOO_LARGE at no charge, never cut short. */
|
|
36
37
|
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf" | "extract" | "raw")[];
|
|
38
|
+
/** Read only the page's main content into `markdown`, `text` and `extract`: the article or the
|
|
39
|
+
* product, without the menus, ads and related links around it. On by default. Set `false` for
|
|
40
|
+
* the whole page. When the main content is under 50 words, you get the whole page instead.
|
|
41
|
+
* `html` and `links` always hold the whole page. */
|
|
42
|
+
onlyMainContent?: boolean;
|
|
43
|
+
/** CSS selectors for the parts of the page to keep, such as `["h1", ".price"]`. `markdown`,
|
|
44
|
+
* `text` and `extract` then hold only what they match, in page order, and `onlyMainContent` no
|
|
45
|
+
* longer applies. Hidden parts are never kept. Up to 20 selectors, 256 characters each. */
|
|
46
|
+
includeTags?: string[];
|
|
47
|
+
/** CSS selectors for the parts of the page to leave out of `markdown`, `text` and `extract`,
|
|
48
|
+
* such as `[".comments", "#newsletter"]`. Up to 20 selectors, 256 characters each. */
|
|
49
|
+
excludeTags?: string[];
|
|
37
50
|
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
38
51
|
* that comes back (a maintenance notice, a "checking your browser" page, a login form) is then
|
|
39
52
|
* not your answer. It costs nothing, and we try again from another address instead of handing
|
|
@@ -138,11 +151,24 @@ export interface QuoteScrapeParams {
|
|
|
138
151
|
retry?: number;
|
|
139
152
|
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
140
153
|
* asking for both costs no more than one. "extract" is the page read into fields by a model,
|
|
141
|
-
* and needs an `extract` block saying which ones.
|
|
142
|
-
*
|
|
143
|
-
*
|
|
144
|
-
*
|
|
154
|
+
* and needs an `extract` block saying which ones. A link to a PDF or a Word (.docx) file is
|
|
155
|
+
* read into text, so the text formats work on it too. We read files up to 25 MB and the first
|
|
156
|
+
* 200 pages, at the fetch price. "raw" is the file exactly as the site sent it, as base64 with
|
|
157
|
+
* its content type: a PDF report, an image, a spreadsheet. It uses the fetch engine and holds
|
|
158
|
+
* up to 5 MB; a larger file answers FILE_TOO_LARGE at no charge, never cut short. */
|
|
145
159
|
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf" | "extract" | "raw")[];
|
|
160
|
+
/** Read only the page's main content into `markdown`, `text` and `extract`: the article or the
|
|
161
|
+
* product, without the menus, ads and related links around it. On by default. Set `false` for
|
|
162
|
+
* the whole page. When the main content is under 50 words, you get the whole page instead.
|
|
163
|
+
* `html` and `links` always hold the whole page. */
|
|
164
|
+
onlyMainContent?: boolean;
|
|
165
|
+
/** CSS selectors for the parts of the page to keep, such as `["h1", ".price"]`. `markdown`,
|
|
166
|
+
* `text` and `extract` then hold only what they match, in page order, and `onlyMainContent` no
|
|
167
|
+
* longer applies. Hidden parts are never kept. Up to 20 selectors, 256 characters each. */
|
|
168
|
+
includeTags?: string[];
|
|
169
|
+
/** CSS selectors for the parts of the page to leave out of `markdown`, `text` and `extract`,
|
|
170
|
+
* such as `[".comments", "#newsletter"]`. Up to 20 selectors, 256 characters each. */
|
|
171
|
+
excludeTags?: string[];
|
|
146
172
|
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
147
173
|
* that comes back (a maintenance notice, a "checking your browser" page, a login form) is then
|
|
148
174
|
* not your answer. It costs nothing, and we try again from another address instead of handing
|
|
@@ -216,6 +242,66 @@ export interface QuoteScrapeParams {
|
|
|
216
242
|
* free outcome. */
|
|
217
243
|
timeoutMs?: number;
|
|
218
244
|
}
|
|
245
|
+
/** Arguments for `map()`. */
|
|
246
|
+
export interface MapSiteParams {
|
|
247
|
+
/** The site to map, as any http(s) URL on it. Private and loopback hosts are refused. */
|
|
248
|
+
url: string;
|
|
249
|
+
/** How many URLs to hand back at most, 1 to 30,000. The price is the same whatever you ask for. */
|
|
250
|
+
limit?: number;
|
|
251
|
+
/** Only URLs that contain this text, upper or lower case alike: `blog` keeps `/blog/` and
|
|
252
|
+
* `/Blog-post`. */
|
|
253
|
+
search?: string;
|
|
254
|
+
/** Also keep URLs on other hosts of the same domain, like `blog.example.com` for `example.com`.
|
|
255
|
+
* Off by default: only the host you named, with or without `www.`. */
|
|
256
|
+
includeSubdomains?: boolean;
|
|
257
|
+
/** Where to look. "include" reads the site's sitemaps and the links on the page you named;
|
|
258
|
+
* "only" reads the sitemaps alone; "skip" reads the page's links alone. */
|
|
259
|
+
sitemap?: "include" | "only" | "skip";
|
|
260
|
+
/** Where the map's requests leave from. Every file it reads goes through the same exit. */
|
|
261
|
+
proxy?: {
|
|
262
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
263
|
+
* "custom" is your own proxy, free on every plan, bytes never billed. */
|
|
264
|
+
pool?: "residential" | "custom";
|
|
265
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
266
|
+
* for the managed one. */
|
|
267
|
+
server?: string;
|
|
268
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`). Name one
|
|
269
|
+
* and the managed pool leaves from that country. Leave it out and the page sees a US
|
|
270
|
+
* browser, from an address we pick. The browser's clock and languages follow the country
|
|
271
|
+
* on every pool. */
|
|
272
|
+
country?: string;
|
|
273
|
+
};
|
|
274
|
+
}
|
|
275
|
+
/** Arguments for `quoteMap()`. */
|
|
276
|
+
export interface QuoteMapParams {
|
|
277
|
+
/** The site to map, as any http(s) URL on it. Private and loopback hosts are refused. */
|
|
278
|
+
url: string;
|
|
279
|
+
/** How many URLs to hand back at most, 1 to 30,000. The price is the same whatever you ask for. */
|
|
280
|
+
limit?: number;
|
|
281
|
+
/** Only URLs that contain this text, upper or lower case alike: `blog` keeps `/blog/` and
|
|
282
|
+
* `/Blog-post`. */
|
|
283
|
+
search?: string;
|
|
284
|
+
/** Also keep URLs on other hosts of the same domain, like `blog.example.com` for `example.com`.
|
|
285
|
+
* Off by default: only the host you named, with or without `www.`. */
|
|
286
|
+
includeSubdomains?: boolean;
|
|
287
|
+
/** Where to look. "include" reads the site's sitemaps and the links on the page you named;
|
|
288
|
+
* "only" reads the sitemaps alone; "skip" reads the page's links alone. */
|
|
289
|
+
sitemap?: "include" | "only" | "skip";
|
|
290
|
+
/** Where the map's requests leave from. Every file it reads goes through the same exit. */
|
|
291
|
+
proxy?: {
|
|
292
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
293
|
+
* "custom" is your own proxy, free on every plan, bytes never billed. */
|
|
294
|
+
pool?: "residential" | "custom";
|
|
295
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
296
|
+
* for the managed one. */
|
|
297
|
+
server?: string;
|
|
298
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`). Name one
|
|
299
|
+
* and the managed pool leaves from that country. Leave it out and the page sees a US
|
|
300
|
+
* browser, from an address we pick. The browser's clock and languages follow the country
|
|
301
|
+
* on every pool. */
|
|
302
|
+
country?: string;
|
|
303
|
+
};
|
|
304
|
+
}
|
|
219
305
|
/** Arguments for `search()`. */
|
|
220
306
|
export interface SearchParams {
|
|
221
307
|
/** What to search for, in plain words: the same thing you would type. */
|
|
@@ -271,11 +357,24 @@ export interface CreateBatchParams {
|
|
|
271
357
|
retry?: number;
|
|
272
358
|
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
273
359
|
* asking for both costs no more than one. "extract" is the page read into fields by a model,
|
|
274
|
-
* and needs an `extract` block saying which ones.
|
|
275
|
-
*
|
|
276
|
-
*
|
|
277
|
-
*
|
|
360
|
+
* and needs an `extract` block saying which ones. A link to a PDF or a Word (.docx) file is
|
|
361
|
+
* read into text, so the text formats work on it too. We read files up to 25 MB and the first
|
|
362
|
+
* 200 pages, at the fetch price. "raw" is the file exactly as the site sent it, as base64 with
|
|
363
|
+
* its content type: a PDF report, an image, a spreadsheet. It uses the fetch engine and holds
|
|
364
|
+
* up to 5 MB; a larger file answers FILE_TOO_LARGE at no charge, never cut short. */
|
|
278
365
|
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf" | "extract" | "raw")[];
|
|
366
|
+
/** Read only the page's main content into `markdown`, `text` and `extract`: the article or the
|
|
367
|
+
* product, without the menus, ads and related links around it. On by default. Set `false` for
|
|
368
|
+
* the whole page. When the main content is under 50 words, you get the whole page instead.
|
|
369
|
+
* `html` and `links` always hold the whole page. */
|
|
370
|
+
onlyMainContent?: boolean;
|
|
371
|
+
/** CSS selectors for the parts of the page to keep, such as `["h1", ".price"]`. `markdown`,
|
|
372
|
+
* `text` and `extract` then hold only what they match, in page order, and `onlyMainContent` no
|
|
373
|
+
* longer applies. Hidden parts are never kept. Up to 20 selectors, 256 characters each. */
|
|
374
|
+
includeTags?: string[];
|
|
375
|
+
/** CSS selectors for the parts of the page to leave out of `markdown`, `text` and `extract`,
|
|
376
|
+
* such as `[".comments", "#newsletter"]`. Up to 20 selectors, 256 characters each. */
|
|
377
|
+
excludeTags?: string[];
|
|
279
378
|
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
280
379
|
* that comes back (a maintenance notice, a "checking your browser" page, a login form) is then
|
|
281
380
|
* not your answer. It costs nothing, and we try again from another address instead of handing
|
|
@@ -384,11 +483,24 @@ export interface QuoteBatchParams {
|
|
|
384
483
|
retry?: number;
|
|
385
484
|
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
386
485
|
* asking for both costs no more than one. "extract" is the page read into fields by a model,
|
|
387
|
-
* and needs an `extract` block saying which ones.
|
|
388
|
-
*
|
|
389
|
-
*
|
|
390
|
-
*
|
|
486
|
+
* and needs an `extract` block saying which ones. A link to a PDF or a Word (.docx) file is
|
|
487
|
+
* read into text, so the text formats work on it too. We read files up to 25 MB and the first
|
|
488
|
+
* 200 pages, at the fetch price. "raw" is the file exactly as the site sent it, as base64 with
|
|
489
|
+
* its content type: a PDF report, an image, a spreadsheet. It uses the fetch engine and holds
|
|
490
|
+
* up to 5 MB; a larger file answers FILE_TOO_LARGE at no charge, never cut short. */
|
|
391
491
|
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf" | "extract" | "raw")[];
|
|
492
|
+
/** Read only the page's main content into `markdown`, `text` and `extract`: the article or the
|
|
493
|
+
* product, without the menus, ads and related links around it. On by default. Set `false` for
|
|
494
|
+
* the whole page. When the main content is under 50 words, you get the whole page instead.
|
|
495
|
+
* `html` and `links` always hold the whole page. */
|
|
496
|
+
onlyMainContent?: boolean;
|
|
497
|
+
/** CSS selectors for the parts of the page to keep, such as `["h1", ".price"]`. `markdown`,
|
|
498
|
+
* `text` and `extract` then hold only what they match, in page order, and `onlyMainContent` no
|
|
499
|
+
* longer applies. Hidden parts are never kept. Up to 20 selectors, 256 characters each. */
|
|
500
|
+
includeTags?: string[];
|
|
501
|
+
/** CSS selectors for the parts of the page to leave out of `markdown`, `text` and `extract`,
|
|
502
|
+
* such as `[".comments", "#newsletter"]`. Up to 20 selectors, 256 characters each. */
|
|
503
|
+
excludeTags?: string[];
|
|
392
504
|
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
393
505
|
* that comes back (a maintenance notice, a "checking your browser" page, a login form) is then
|
|
394
506
|
* not your answer. It costs nothing, and we try again from another address instead of handing
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/generated/params.ts"],"names":[],"mappings":"AAMA,gCAAgC;AAChC,MAAM,WAAW,YAAY;IACzB,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAC;IACZ;;;wDAGoD;IACpD,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACtC;;;uEAGmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;8BAE0B;IAC1B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB;;;;qCAIiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;sCAGkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf
|
|
1
|
+
{"version":3,"file":"params.d.ts","sourceRoot":"","sources":["../../src/generated/params.ts"],"names":[],"mappings":"AAMA,gCAAgC;AAChC,MAAM,WAAW,YAAY;IACzB,gFAAgF;IAChF,GAAG,EAAE,MAAM,CAAC;IACZ;;;wDAGoD;IACpD,MAAM,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,SAAS,CAAC;IACtC;;;uEAGmE;IACnE,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB;;8BAE0B;IAC1B,MAAM,CAAC,EAAE,KAAK,GAAG,MAAM,CAAC;IACxB;;;;qCAIiC;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd;;;sCAGkC;IAClC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;;;0FAMsF;IACtF,OAAO,CAAC,EAAE,CAAC,UAAU,GAAG,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,YAAY,GAAG,KAAK,GAAG,SAAS,GAAG,KAAK,CAAC,EAAE,CAAC;IAChG;;;yDAGqD;IACrD,eAAe,CAAC,EAAE,OAAO,CAAC;IAC1B;;gGAE4F;IAC5F,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB;2FACuF;IACvF,WA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1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@scrapa/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "Official TypeScript client for scrapa.app. Scrape any web page as markdown, HTML, text, links, a screenshot or a PDF, search the web, and drive a real browser over CDP.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"homepage": "https://scrapa.app",
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// GENERATED FILE — do not edit. Run `bun run sdk:gen`.
|
|
2
|
-
// Source: packages/shared/src/http/index.ts, packages/shared/src/locale/index.ts, packages/shared/src/enums/index.ts, packages/shared/src/billing/catalog.ts, packages/shared/src/dto/account.ts, packages/shared/src/dto/scrape.ts, packages/shared/src/dto/batch.ts, packages/shared/src/dto/search.ts, packages/shared/src/dto/sessions.ts, packages/shared/src/dto/usage.ts
|
|
2
|
+
// Source: packages/shared/src/http/index.ts, packages/shared/src/locale/index.ts, packages/shared/src/enums/index.ts, packages/shared/src/billing/catalog.ts, packages/shared/src/dto/account.ts, packages/shared/src/dto/scrape.ts, packages/shared/src/dto/batch.ts, packages/shared/src/dto/map.ts, packages/shared/src/dto/search.ts, packages/shared/src/dto/sessions.ts, packages/shared/src/dto/usage.ts
|
|
3
3
|
//
|
|
4
4
|
// The shapes the API speaks, lifted from the server's own contract.
|
|
5
5
|
|
|
@@ -11,8 +11,9 @@
|
|
|
11
11
|
* locale catalogs, exhaustiveness checks).
|
|
12
12
|
*
|
|
13
13
|
* THE WHOSE-FAULT VOCABULARY (DESIGN.md) is the organising principle: a caller's next move
|
|
14
|
-
* depends entirely on who said no, so the code says. `UPSTREAM_BLOCKED`
|
|
15
|
-
*
|
|
14
|
+
* depends entirely on who said no, so the code says. `UPSTREAM_BLOCKED` is "the site said no"
|
|
15
|
+
* (retry differently — another engine, pool or country), and `NAV_TIMEOUT` shares its hue under
|
|
16
|
+
* its own word, "time ran out" (give it more time; see `OWN_WORD`); `SSRF_DENIED` /
|
|
16
17
|
* `AUP_DENIED` are "our policy said no" (retrying cannot help, change the URL); a 5xx is
|
|
17
18
|
* "we broke it" (retry as-is, already refunded).
|
|
18
19
|
*/
|
|
@@ -48,6 +49,11 @@ export const ERROR_CODES = [
|
|
|
48
49
|
// client its OWN request was too big. Free, and no colour, for PROXY_REFUSED's reason:
|
|
49
50
|
// the fix is in the request (another format, or download it yourself), not another road.
|
|
50
51
|
"FILE_TOO_LARGE", // 422 — details {limit}, in bytes
|
|
52
|
+
// A PDF or a Word file arrived whole, and reading it into text took longer than the time
|
|
53
|
+
// the call had left. Free, and no colour: the site answered in full, so another engine,
|
|
54
|
+
// pool or country reads the same file just as slowly. The fix is more `timeoutMs`, or
|
|
55
|
+
// "raw" and reading it yourself.
|
|
56
|
+
"DOCUMENT_TIMEOUT", // 422: details {budgetMs}, the call's timeout
|
|
51
57
|
"RATE_LIMIT_EXCEEDED", // 429 — the per-minute burst bucket; Retry-After + details {limit}
|
|
52
58
|
"QUOTA_EXCEEDED", // 429 — a durable bound that WAITING clears; details {scope, limit, resetAt}
|
|
53
59
|
"INTERNAL_ERROR", // 500 — we broke it; the body is always generic, the cause stays server-side
|
|
@@ -76,6 +82,7 @@ export const ERROR_STATUS = {
|
|
|
76
82
|
NAV_TIMEOUT: 422,
|
|
77
83
|
PROXY_REFUSED: 422,
|
|
78
84
|
FILE_TOO_LARGE: 422,
|
|
85
|
+
DOCUMENT_TIMEOUT: 422,
|
|
79
86
|
RATE_LIMIT_EXCEEDED: 429,
|
|
80
87
|
QUOTA_EXCEEDED: 429,
|
|
81
88
|
INTERNAL_ERROR: 500,
|
|
@@ -88,7 +95,7 @@ export const ERROR_STATUS = {
|
|
|
88
95
|
* — this is the map the console reads to pick the hue and the word, and the SDK reads to
|
|
89
96
|
* tell a caller what to do next. A code absent from here gets no colour: the caller's own
|
|
90
97
|
* mistake (a bad body, a missing key), or a free refusal whose fix is in the request rather
|
|
91
|
-
* than the site (PROXY_REFUSED, FILE_TOO_LARGE).
|
|
98
|
+
* than the site (PROXY_REFUSED, FILE_TOO_LARGE, DOCUMENT_TIMEOUT).
|
|
92
99
|
*
|
|
93
100
|
* blocked → the site said no → try another engine, pool or country
|
|
94
101
|
* denied → our policy said no → change the URL; retrying cannot help
|
|
@@ -222,6 +229,9 @@ export const SEARCH_ENGINES = ["bing", "brave", "duckduckgo"] as const;
|
|
|
222
229
|
|
|
223
230
|
export type SearchEngine = (typeof SEARCH_ENGINES)[number];
|
|
224
231
|
|
|
232
|
+
/** Where a map's URLs came from. With none found, the sources that were read. */
|
|
233
|
+
export type MapSource = "sitemap" | "links" | "both";
|
|
234
|
+
|
|
225
235
|
/** A batch's life. `queued` is accepted but not yet picked up; `running` has at least one
|
|
226
236
|
* item in flight. The three end states answer the same question the session statuses do —
|
|
227
237
|
* who ended it: `completed` ran every item to a verdict (some of which may be failures,
|
|
@@ -283,6 +293,12 @@ export interface ScrapeMetadataDto {
|
|
|
283
293
|
* it so a caller can retry with `engine: "browser"` instead of trusting an empty page.
|
|
284
294
|
* Always false from the browser engine, which ran the scripts. */
|
|
285
295
|
needsJs: boolean;
|
|
296
|
+
/** How many pages the PDF has, when a PDF was read into text. Absent for anything else,
|
|
297
|
+
* and when only "raw" was asked for. */
|
|
298
|
+
pages?: number;
|
|
299
|
+
/** True when the PDF has more pages than we read: the first 200 are in the answer and the
|
|
300
|
+
* rest are not. Absent otherwise. */
|
|
301
|
+
truncated?: boolean;
|
|
286
302
|
}
|
|
287
303
|
|
|
288
304
|
/** A file, exactly as the site sent it. */
|
|
@@ -468,6 +484,43 @@ export interface CreatedBatchDto extends BatchDto {
|
|
|
468
484
|
* delivery somebody copied can be sent to you again. */
|
|
469
485
|
webhookSecret?: string;
|
|
470
486
|
}
|
|
487
|
+
// ── from packages/shared/src/dto/map.ts ──────────────────────────────
|
|
488
|
+
|
|
489
|
+
/** One URL a site lists, normalised: no fragment, no `utm_*` parameters, the query sorted,
|
|
490
|
+
* no trailing slash. */
|
|
491
|
+
export interface MapUrlDto {
|
|
492
|
+
url: string;
|
|
493
|
+
/** When the sitemap says the page last changed, as the sitemap wrote it (a W3C date, often
|
|
494
|
+
* just the day). Absent when it did not say, or when the URL came from the page's links. */
|
|
495
|
+
lastmod?: string;
|
|
496
|
+
}
|
|
497
|
+
|
|
498
|
+
/** `POST /v1/map`'s answer. */
|
|
499
|
+
export interface MapResultDto {
|
|
500
|
+
/** Every URL found, once each, sitemap URLs first in the order the site listed them. */
|
|
501
|
+
urls: MapUrlDto[];
|
|
502
|
+
/** Where they came from. With none found, the sources that were read. */
|
|
503
|
+
source: MapSource;
|
|
504
|
+
/** True when the site may list more than this answer holds: `limit` cut the list, or the
|
|
505
|
+
* robots.txt or a sitemap was not read to its end (the site refused it, its size, the
|
|
506
|
+
* 25-document cap, or the time limit). */
|
|
507
|
+
truncated: boolean;
|
|
508
|
+
pool: ProxyPool;
|
|
509
|
+
/** What the managed pool carried for every document the map read, decompressed. The
|
|
510
|
+
* first megabyte is free; past it, bandwidth is metered like any request's. */
|
|
511
|
+
bytes: number;
|
|
512
|
+
}
|
|
513
|
+
|
|
514
|
+
/** What a map would cost, without making it. */
|
|
515
|
+
export interface MapQuoteDto {
|
|
516
|
+
pool: ProxyPool;
|
|
517
|
+
/** Credits a map charges, whatever it finds. */
|
|
518
|
+
cost: number;
|
|
519
|
+
/** Managed-pool megabytes included before `perMb` applies. 0 on BYO. */
|
|
520
|
+
freeMb: number;
|
|
521
|
+
/** Credits per additional megabyte through the managed pool. 0 on BYO. */
|
|
522
|
+
perMb: number;
|
|
523
|
+
}
|
|
471
524
|
// ── from packages/shared/src/dto/search.ts ───────────────────────────
|
|
472
525
|
|
|
473
526
|
/** One hit, as the index ranked it. The array's ORDER is the ranking — there is no score,
|
|
@@ -10,6 +10,8 @@ import type {
|
|
|
10
10
|
BatchQuoteDto,
|
|
11
11
|
CreatedBatchDto,
|
|
12
12
|
LiveSessionDto,
|
|
13
|
+
MapQuoteDto,
|
|
14
|
+
MapResultDto,
|
|
13
15
|
ScrapeQuoteDto,
|
|
14
16
|
ScrapeResultDto,
|
|
15
17
|
SearchResultDto,
|
|
@@ -26,7 +28,9 @@ import type {
|
|
|
26
28
|
GetSessionParams,
|
|
27
29
|
ListBatchesParams,
|
|
28
30
|
ListSessionsParams,
|
|
31
|
+
MapSiteParams,
|
|
29
32
|
QuoteBatchParams,
|
|
33
|
+
QuoteMapParams,
|
|
30
34
|
QuoteScrapeParams,
|
|
31
35
|
QuoteSessionParams,
|
|
32
36
|
ScrapeParams,
|
|
@@ -34,7 +38,7 @@ import type {
|
|
|
34
38
|
} from "./params.ts";
|
|
35
39
|
|
|
36
40
|
/** The version this client reports in `x-scrapa-client`. */
|
|
37
|
-
export const SDK_VERSION = "0.
|
|
41
|
+
export const SDK_VERSION = "0.4.0";
|
|
38
42
|
|
|
39
43
|
/** The hosted API. */
|
|
40
44
|
export const DEFAULT_BASE_URL = "https://api.scrapa.app/v1";
|
|
@@ -54,7 +58,8 @@ export abstract class GeneratedOperations {
|
|
|
54
58
|
* makes a plain HTTP request first and re-reads the page in a real Chromium when the body
|
|
55
59
|
* turns out to be a JavaScript shell, so you pay for a browser only when the page needed one.
|
|
56
60
|
* To send a search form or a JSON query, use `method: "POST"` with a `body`; to download a
|
|
57
|
-
* file exactly as the site sent it, ask for `formats: ["raw"]`.
|
|
61
|
+
* file exactly as the site sent it, ask for `formats: ["raw"]`. A link to a PDF or a Word file
|
|
62
|
+
* is read into text too, headings and paragraphs included. Every request leaves through a
|
|
58
63
|
* residential proxy, or through your own with `proxy: { pool: "custom", server }`. The answer
|
|
59
64
|
* says which engine replied, where the page finally was and what it cost.
|
|
60
65
|
*
|
|
@@ -109,6 +114,65 @@ export abstract class GeneratedOperations {
|
|
|
109
114
|
);
|
|
110
115
|
}
|
|
111
116
|
|
|
117
|
+
/**
|
|
118
|
+
* List a site's URLs
|
|
119
|
+
*
|
|
120
|
+
* Hand back every URL a site lists, without reading the pages: what its robots.txt and
|
|
121
|
+
* sitemaps name (gzipped ones too, and indexes of sitemaps), plus the links on the page you
|
|
122
|
+
* named. Each URL comes back once, without tracking parameters or a trailing slash, with
|
|
123
|
+
* `lastmod` when the sitemap gives one. Only the host you named is kept unless you set
|
|
124
|
+
* `includeSubdomains`, and `search` keeps the URLs that contain a word. To read a page, pass
|
|
125
|
+
* its URL to `scrape`.
|
|
126
|
+
*
|
|
127
|
+
* Credits: 2 credits, plus managed-proxy bandwidth past the first megabyte, every file the map
|
|
128
|
+
* read counted together. A site that lists nothing is charged, because it answered. A site
|
|
129
|
+
* that refused every file, and anything we broke, cost nothing.
|
|
130
|
+
*
|
|
131
|
+
* `POST /v1/map`
|
|
132
|
+
*/
|
|
133
|
+
map(
|
|
134
|
+
params: MapSiteParams,
|
|
135
|
+
opts?: Omit<RequestOptions, "idempotencyKey">,
|
|
136
|
+
): Promise<MapResultDto> {
|
|
137
|
+
return this.request(
|
|
138
|
+
{
|
|
139
|
+
method: "POST",
|
|
140
|
+
path: "/map",
|
|
141
|
+
repeatable: false,
|
|
142
|
+
proxy: ["pool", "server", "country"],
|
|
143
|
+
},
|
|
144
|
+
params,
|
|
145
|
+
opts,
|
|
146
|
+
);
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
/**
|
|
150
|
+
* Price a map
|
|
151
|
+
*
|
|
152
|
+
* What the same map would cost, without making it. Free, and refused by the same guards a real
|
|
153
|
+
* call meets. Bandwidth is priced per megabyte because nobody knows a site's sitemap size
|
|
154
|
+
* before reading it.
|
|
155
|
+
*
|
|
156
|
+
* Credits: 0 credits. Pricing a call is free.
|
|
157
|
+
*
|
|
158
|
+
* `POST /v1/map/quote`
|
|
159
|
+
*/
|
|
160
|
+
quoteMap(
|
|
161
|
+
params: QuoteMapParams,
|
|
162
|
+
opts?: Omit<RequestOptions, "idempotencyKey">,
|
|
163
|
+
): Promise<MapQuoteDto> {
|
|
164
|
+
return this.request(
|
|
165
|
+
{
|
|
166
|
+
method: "POST",
|
|
167
|
+
path: "/map/quote",
|
|
168
|
+
repeatable: true,
|
|
169
|
+
proxy: ["pool", "server", "country"],
|
|
170
|
+
},
|
|
171
|
+
params,
|
|
172
|
+
opts,
|
|
173
|
+
);
|
|
174
|
+
}
|
|
175
|
+
|
|
112
176
|
/**
|
|
113
177
|
* Search the web
|
|
114
178
|
*
|
package/src/generated/params.ts
CHANGED
|
@@ -35,11 +35,24 @@ export interface ScrapeParams {
|
|
|
35
35
|
retry?: number;
|
|
36
36
|
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
37
37
|
* asking for both costs no more than one. "extract" is the page read into fields by a model,
|
|
38
|
-
* and needs an `extract` block saying which ones.
|
|
39
|
-
*
|
|
40
|
-
*
|
|
41
|
-
*
|
|
38
|
+
* and needs an `extract` block saying which ones. A link to a PDF or a Word (.docx) file is
|
|
39
|
+
* read into text, so the text formats work on it too. We read files up to 25 MB and the first
|
|
40
|
+
* 200 pages, at the fetch price. "raw" is the file exactly as the site sent it, as base64 with
|
|
41
|
+
* its content type: a PDF report, an image, a spreadsheet. It uses the fetch engine and holds
|
|
42
|
+
* up to 5 MB; a larger file answers FILE_TOO_LARGE at no charge, never cut short. */
|
|
42
43
|
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf" | "extract" | "raw")[];
|
|
44
|
+
/** Read only the page's main content into `markdown`, `text` and `extract`: the article or the
|
|
45
|
+
* product, without the menus, ads and related links around it. On by default. Set `false` for
|
|
46
|
+
* the whole page. When the main content is under 50 words, you get the whole page instead.
|
|
47
|
+
* `html` and `links` always hold the whole page. */
|
|
48
|
+
onlyMainContent?: boolean;
|
|
49
|
+
/** CSS selectors for the parts of the page to keep, such as `["h1", ".price"]`. `markdown`,
|
|
50
|
+
* `text` and `extract` then hold only what they match, in page order, and `onlyMainContent` no
|
|
51
|
+
* longer applies. Hidden parts are never kept. Up to 20 selectors, 256 characters each. */
|
|
52
|
+
includeTags?: string[];
|
|
53
|
+
/** CSS selectors for the parts of the page to leave out of `markdown`, `text` and `extract`,
|
|
54
|
+
* such as `[".comments", "#newsletter"]`. Up to 20 selectors, 256 characters each. */
|
|
55
|
+
excludeTags?: string[];
|
|
43
56
|
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
44
57
|
* that comes back (a maintenance notice, a "checking your browser" page, a login form) is then
|
|
45
58
|
* not your answer. It costs nothing, and we try again from another address instead of handing
|
|
@@ -145,11 +158,24 @@ export interface QuoteScrapeParams {
|
|
|
145
158
|
retry?: number;
|
|
146
159
|
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
147
160
|
* asking for both costs no more than one. "extract" is the page read into fields by a model,
|
|
148
|
-
* and needs an `extract` block saying which ones.
|
|
149
|
-
*
|
|
150
|
-
*
|
|
151
|
-
*
|
|
161
|
+
* and needs an `extract` block saying which ones. A link to a PDF or a Word (.docx) file is
|
|
162
|
+
* read into text, so the text formats work on it too. We read files up to 25 MB and the first
|
|
163
|
+
* 200 pages, at the fetch price. "raw" is the file exactly as the site sent it, as base64 with
|
|
164
|
+
* its content type: a PDF report, an image, a spreadsheet. It uses the fetch engine and holds
|
|
165
|
+
* up to 5 MB; a larger file answers FILE_TOO_LARGE at no charge, never cut short. */
|
|
152
166
|
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf" | "extract" | "raw")[];
|
|
167
|
+
/** Read only the page's main content into `markdown`, `text` and `extract`: the article or the
|
|
168
|
+
* product, without the menus, ads and related links around it. On by default. Set `false` for
|
|
169
|
+
* the whole page. When the main content is under 50 words, you get the whole page instead.
|
|
170
|
+
* `html` and `links` always hold the whole page. */
|
|
171
|
+
onlyMainContent?: boolean;
|
|
172
|
+
/** CSS selectors for the parts of the page to keep, such as `["h1", ".price"]`. `markdown`,
|
|
173
|
+
* `text` and `extract` then hold only what they match, in page order, and `onlyMainContent` no
|
|
174
|
+
* longer applies. Hidden parts are never kept. Up to 20 selectors, 256 characters each. */
|
|
175
|
+
includeTags?: string[];
|
|
176
|
+
/** CSS selectors for the parts of the page to leave out of `markdown`, `text` and `extract`,
|
|
177
|
+
* such as `[".comments", "#newsletter"]`. Up to 20 selectors, 256 characters each. */
|
|
178
|
+
excludeTags?: string[];
|
|
153
179
|
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
154
180
|
* that comes back (a maintenance notice, a "checking your browser" page, a login form) is then
|
|
155
181
|
* not your answer. It costs nothing, and we try again from another address instead of handing
|
|
@@ -224,6 +250,68 @@ export interface QuoteScrapeParams {
|
|
|
224
250
|
timeoutMs?: number;
|
|
225
251
|
}
|
|
226
252
|
|
|
253
|
+
/** Arguments for `map()`. */
|
|
254
|
+
export interface MapSiteParams {
|
|
255
|
+
/** The site to map, as any http(s) URL on it. Private and loopback hosts are refused. */
|
|
256
|
+
url: string;
|
|
257
|
+
/** How many URLs to hand back at most, 1 to 30,000. The price is the same whatever you ask for. */
|
|
258
|
+
limit?: number;
|
|
259
|
+
/** Only URLs that contain this text, upper or lower case alike: `blog` keeps `/blog/` and
|
|
260
|
+
* `/Blog-post`. */
|
|
261
|
+
search?: string;
|
|
262
|
+
/** Also keep URLs on other hosts of the same domain, like `blog.example.com` for `example.com`.
|
|
263
|
+
* Off by default: only the host you named, with or without `www.`. */
|
|
264
|
+
includeSubdomains?: boolean;
|
|
265
|
+
/** Where to look. "include" reads the site's sitemaps and the links on the page you named;
|
|
266
|
+
* "only" reads the sitemaps alone; "skip" reads the page's links alone. */
|
|
267
|
+
sitemap?: "include" | "only" | "skip";
|
|
268
|
+
/** Where the map's requests leave from. Every file it reads goes through the same exit. */
|
|
269
|
+
proxy?: {
|
|
270
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
271
|
+
* "custom" is your own proxy, free on every plan, bytes never billed. */
|
|
272
|
+
pool?: "residential" | "custom";
|
|
273
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
274
|
+
* for the managed one. */
|
|
275
|
+
server?: string;
|
|
276
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`). Name one
|
|
277
|
+
* and the managed pool leaves from that country. Leave it out and the page sees a US
|
|
278
|
+
* browser, from an address we pick. The browser's clock and languages follow the country
|
|
279
|
+
* on every pool. */
|
|
280
|
+
country?: string;
|
|
281
|
+
};
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/** Arguments for `quoteMap()`. */
|
|
285
|
+
export interface QuoteMapParams {
|
|
286
|
+
/** The site to map, as any http(s) URL on it. Private and loopback hosts are refused. */
|
|
287
|
+
url: string;
|
|
288
|
+
/** How many URLs to hand back at most, 1 to 30,000. The price is the same whatever you ask for. */
|
|
289
|
+
limit?: number;
|
|
290
|
+
/** Only URLs that contain this text, upper or lower case alike: `blog` keeps `/blog/` and
|
|
291
|
+
* `/Blog-post`. */
|
|
292
|
+
search?: string;
|
|
293
|
+
/** Also keep URLs on other hosts of the same domain, like `blog.example.com` for `example.com`.
|
|
294
|
+
* Off by default: only the host you named, with or without `www.`. */
|
|
295
|
+
includeSubdomains?: boolean;
|
|
296
|
+
/** Where to look. "include" reads the site's sitemaps and the links on the page you named;
|
|
297
|
+
* "only" reads the sitemaps alone; "skip" reads the page's links alone. */
|
|
298
|
+
sitemap?: "include" | "only" | "skip";
|
|
299
|
+
/** Where the map's requests leave from. Every file it reads goes through the same exit. */
|
|
300
|
+
proxy?: {
|
|
301
|
+
/** Which exit to leave through. "residential" is the managed pool, metered by the megabyte;
|
|
302
|
+
* "custom" is your own proxy, free on every plan, bytes never billed. */
|
|
303
|
+
pool?: "residential" | "custom";
|
|
304
|
+
/** Your own proxy, `http(s)://[user:pass@]host:port`. Required for pool "custom", refused
|
|
305
|
+
* for the managed one. */
|
|
306
|
+
server?: string;
|
|
307
|
+
/** Where the call should look like it comes from, ISO 3166-1 alpha-2 (`us`, `br`). Name one
|
|
308
|
+
* and the managed pool leaves from that country. Leave it out and the page sees a US
|
|
309
|
+
* browser, from an address we pick. The browser's clock and languages follow the country
|
|
310
|
+
* on every pool. */
|
|
311
|
+
country?: string;
|
|
312
|
+
};
|
|
313
|
+
}
|
|
314
|
+
|
|
227
315
|
/** Arguments for `search()`. */
|
|
228
316
|
export interface SearchParams {
|
|
229
317
|
/** What to search for, in plain words: the same thing you would type. */
|
|
@@ -280,11 +368,24 @@ export interface CreateBatchParams {
|
|
|
280
368
|
retry?: number;
|
|
281
369
|
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
282
370
|
* asking for both costs no more than one. "extract" is the page read into fields by a model,
|
|
283
|
-
* and needs an `extract` block saying which ones.
|
|
284
|
-
*
|
|
285
|
-
*
|
|
286
|
-
*
|
|
371
|
+
* and needs an `extract` block saying which ones. A link to a PDF or a Word (.docx) file is
|
|
372
|
+
* read into text, so the text formats work on it too. We read files up to 25 MB and the first
|
|
373
|
+
* 200 pages, at the fetch price. "raw" is the file exactly as the site sent it, as base64 with
|
|
374
|
+
* its content type: a PDF report, an image, a spreadsheet. It uses the fetch engine and holds
|
|
375
|
+
* up to 5 MB; a larger file answers FILE_TOO_LARGE at no charge, never cut short. */
|
|
287
376
|
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf" | "extract" | "raw")[];
|
|
377
|
+
/** Read only the page's main content into `markdown`, `text` and `extract`: the article or the
|
|
378
|
+
* product, without the menus, ads and related links around it. On by default. Set `false` for
|
|
379
|
+
* the whole page. When the main content is under 50 words, you get the whole page instead.
|
|
380
|
+
* `html` and `links` always hold the whole page. */
|
|
381
|
+
onlyMainContent?: boolean;
|
|
382
|
+
/** CSS selectors for the parts of the page to keep, such as `["h1", ".price"]`. `markdown`,
|
|
383
|
+
* `text` and `extract` then hold only what they match, in page order, and `onlyMainContent` no
|
|
384
|
+
* longer applies. Hidden parts are never kept. Up to 20 selectors, 256 characters each. */
|
|
385
|
+
includeTags?: string[];
|
|
386
|
+
/** CSS selectors for the parts of the page to leave out of `markdown`, `text` and `extract`,
|
|
387
|
+
* such as `[".comments", "#newsletter"]`. Up to 20 selectors, 256 characters each. */
|
|
388
|
+
excludeTags?: string[];
|
|
288
389
|
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
289
390
|
* that comes back (a maintenance notice, a "checking your browser" page, a login form) is then
|
|
290
391
|
* not your answer. It costs nothing, and we try again from another address instead of handing
|
|
@@ -394,11 +495,24 @@ export interface QuoteBatchParams {
|
|
|
394
495
|
retry?: number;
|
|
395
496
|
/** What to hand back. "screenshot" and "pdf" come back as base64 and need the browser engine;
|
|
396
497
|
* asking for both costs no more than one. "extract" is the page read into fields by a model,
|
|
397
|
-
* and needs an `extract` block saying which ones.
|
|
398
|
-
*
|
|
399
|
-
*
|
|
400
|
-
*
|
|
498
|
+
* and needs an `extract` block saying which ones. A link to a PDF or a Word (.docx) file is
|
|
499
|
+
* read into text, so the text formats work on it too. We read files up to 25 MB and the first
|
|
500
|
+
* 200 pages, at the fetch price. "raw" is the file exactly as the site sent it, as base64 with
|
|
501
|
+
* its content type: a PDF report, an image, a spreadsheet. It uses the fetch engine and holds
|
|
502
|
+
* up to 5 MB; a larger file answers FILE_TOO_LARGE at no charge, never cut short. */
|
|
401
503
|
formats?: ("markdown" | "html" | "text" | "links" | "screenshot" | "pdf" | "extract" | "raw")[];
|
|
504
|
+
/** Read only the page's main content into `markdown`, `text` and `extract`: the article or the
|
|
505
|
+
* product, without the menus, ads and related links around it. On by default. Set `false` for
|
|
506
|
+
* the whole page. When the main content is under 50 words, you get the whole page instead.
|
|
507
|
+
* `html` and `links` always hold the whole page. */
|
|
508
|
+
onlyMainContent?: boolean;
|
|
509
|
+
/** CSS selectors for the parts of the page to keep, such as `["h1", ".price"]`. `markdown`,
|
|
510
|
+
* `text` and `extract` then hold only what they match, in page order, and `onlyMainContent` no
|
|
511
|
+
* longer applies. Hidden parts are never kept. Up to 20 selectors, 256 characters each. */
|
|
512
|
+
includeTags?: string[];
|
|
513
|
+
/** CSS selectors for the parts of the page to leave out of `markdown`, `text` and `extract`,
|
|
514
|
+
* such as `[".comments", "#newsletter"]`. Up to 20 selectors, 256 characters each. */
|
|
515
|
+
excludeTags?: string[];
|
|
402
516
|
/** What the page should answer with. Set `"json"` when you are reading an API: anything else
|
|
403
517
|
* that comes back (a maintenance notice, a "checking your browser" page, a login form) is then
|
|
404
518
|
* not your answer. It costs nothing, and we try again from another address instead of handing
|