scrapfly-sdk 0.7.2 → 0.9.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/esm/browserconfig.d.ts +59 -0
- package/esm/browserconfig.d.ts.map +1 -0
- package/esm/browserconfig.js +207 -0
- package/esm/client.d.ts +193 -1
- package/esm/client.d.ts.map +1 -1
- package/esm/client.js +786 -5
- package/esm/crawl.d.ts +118 -0
- package/esm/crawl.d.ts.map +1 -0
- package/esm/crawl.js +230 -0
- package/esm/crawlerconfig.d.ts +119 -0
- package/esm/crawlerconfig.d.ts.map +1 -0
- package/esm/crawlerconfig.js +398 -0
- package/esm/crawlerresult.d.ts +253 -0
- package/esm/crawlerresult.d.ts.map +1 -0
- package/esm/crawlerresult.js +327 -0
- package/esm/errors.d.ts +4 -0
- package/esm/errors.d.ts.map +1 -1
- package/esm/errors.js +6 -0
- package/esm/extractionconfig.d.ts +2 -0
- package/esm/extractionconfig.d.ts.map +1 -1
- package/esm/extractionconfig.js +10 -0
- package/esm/main.d.ts +8 -1
- package/esm/main.d.ts.map +1 -1
- package/esm/main.js +6 -1
- package/esm/polyfill.d.ts +2 -0
- package/esm/polyfill.d.ts.map +1 -1
- package/esm/polyfill.js +12 -0
- package/esm/scrapeconfig.d.ts +27 -0
- package/esm/scrapeconfig.d.ts.map +1 -1
- package/esm/scrapeconfig.js +44 -1
- package/esm/screenshotconfig.d.ts +2 -2
- package/esm/screenshotconfig.d.ts.map +1 -1
- package/esm/utils.d.ts.map +1 -1
- package/esm/utils.js +16 -2
- package/esm/webhookserver.d.ts +1 -0
- package/esm/webhookserver.d.ts.map +1 -1
- package/esm/webhookserver.js +1 -0
- package/package.json +1 -1
- package/script/browserconfig.d.ts +59 -0
- package/script/browserconfig.d.ts.map +1 -0
- package/script/browserconfig.js +211 -0
- package/script/client.d.ts +193 -1
- package/script/client.d.ts.map +1 -1
- package/script/client.js +785 -4
- package/script/crawl.d.ts +118 -0
- package/script/crawl.d.ts.map +1 -0
- package/script/crawl.js +257 -0
- package/script/crawlerconfig.d.ts +119 -0
- package/script/crawlerconfig.d.ts.map +1 -0
- package/script/crawlerconfig.js +402 -0
- package/script/crawlerresult.d.ts +253 -0
- package/script/crawlerresult.d.ts.map +1 -0
- package/script/crawlerresult.js +335 -0
- package/script/errors.d.ts +4 -0
- package/script/errors.d.ts.map +1 -1
- package/script/errors.js +9 -1
- package/script/extractionconfig.d.ts +2 -0
- package/script/extractionconfig.d.ts.map +1 -1
- package/script/extractionconfig.js +10 -0
- package/script/main.d.ts +8 -1
- package/script/main.d.ts.map +1 -1
- package/script/main.js +17 -1
- package/script/polyfill.d.ts +2 -0
- package/script/polyfill.d.ts.map +1 -1
- package/script/polyfill.js +14 -1
- package/script/scrapeconfig.d.ts +27 -0
- package/script/scrapeconfig.d.ts.map +1 -1
- package/script/scrapeconfig.js +44 -1
- package/script/screenshotconfig.d.ts +2 -2
- package/script/screenshotconfig.d.ts.map +1 -1
- package/script/utils.d.ts.map +1 -1
- package/script/utils.js +16 -2
- package/script/webhookserver.d.ts +1 -0
- package/script/webhookserver.d.ts.map +1 -1
- package/script/webhookserver.js +2 -1
|
@@ -0,0 +1,335 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CrawlerArtifact = exports.CrawlerContents = exports.CrawlerUrls = exports.CrawlerStatus = void 0;
|
|
4
|
+
exports.parseCrawlerWebhook = parseCrawlerWebhook;
|
|
5
|
+
const polyfill_js_1 = require("./polyfill.js");
|
|
6
|
+
/**
|
|
7
|
+
* Pull a required field out of an API response body and fail loud if it's
|
|
8
|
+
* missing or the wrong type. Using this consistently across the response
|
|
9
|
+
* classes means a server-side contract change surfaces as a clear error at
|
|
10
|
+
* parse time instead of a silent fallback to 0/null/empty later.
|
|
11
|
+
*/
|
|
12
|
+
function requireField(data, key, typeName, contextClass) {
|
|
13
|
+
if (!(key in data)) {
|
|
14
|
+
throw new Error(`${contextClass}: required field '${key}' is missing from API response`);
|
|
15
|
+
}
|
|
16
|
+
const value = data[key];
|
|
17
|
+
if (value === null || value === undefined) {
|
|
18
|
+
throw new Error(`${contextClass}: required field '${key}' is null/undefined`);
|
|
19
|
+
}
|
|
20
|
+
const actual = Array.isArray(value) ? 'array' : typeof value;
|
|
21
|
+
if (typeName === 'array' ? actual !== 'array' : actual !== typeName) {
|
|
22
|
+
throw new Error(`${contextClass}: field '${key}' must be ${typeName}, got ${actual} (${JSON.stringify(value).slice(0, 100)})`);
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Like `requireField` but for optional fields that the server may legitimately
|
|
28
|
+
* omit or send as `null`. Returns `null` when absent; validates type otherwise.
|
|
29
|
+
*/
|
|
30
|
+
function optionalField(data, key, typeName, contextClass) {
|
|
31
|
+
if (!(key in data))
|
|
32
|
+
return null;
|
|
33
|
+
const value = data[key];
|
|
34
|
+
if (value === null || value === undefined)
|
|
35
|
+
return null;
|
|
36
|
+
const actual = Array.isArray(value) ? 'array' : typeof value;
|
|
37
|
+
if (typeName === 'array' ? actual !== 'array' : actual !== typeName) {
|
|
38
|
+
throw new Error(`${contextClass}: field '${key}' must be ${typeName} or null, got ${actual}`);
|
|
39
|
+
}
|
|
40
|
+
return value;
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Wraps the JSON response of `GET /crawl/{uuid}/status`.
|
|
44
|
+
*
|
|
45
|
+
* Strict parsing: every field documented in the public API contract is
|
|
46
|
+
* required. A missing or wrong-typed field throws a clear error at parse
|
|
47
|
+
* time so API contract drift surfaces loud and early instead of silently
|
|
48
|
+
* producing zero-valued metrics.
|
|
49
|
+
*/
|
|
50
|
+
class CrawlerStatus {
|
|
51
|
+
constructor(data) {
|
|
52
|
+
Object.defineProperty(this, "crawler_uuid", {
|
|
53
|
+
enumerable: true,
|
|
54
|
+
configurable: true,
|
|
55
|
+
writable: true,
|
|
56
|
+
value: void 0
|
|
57
|
+
});
|
|
58
|
+
Object.defineProperty(this, "status", {
|
|
59
|
+
enumerable: true,
|
|
60
|
+
configurable: true,
|
|
61
|
+
writable: true,
|
|
62
|
+
value: void 0
|
|
63
|
+
});
|
|
64
|
+
Object.defineProperty(this, "is_finished", {
|
|
65
|
+
enumerable: true,
|
|
66
|
+
configurable: true,
|
|
67
|
+
writable: true,
|
|
68
|
+
value: void 0
|
|
69
|
+
});
|
|
70
|
+
/** `null` while the crawler is still running; bool once terminal. */
|
|
71
|
+
Object.defineProperty(this, "is_success", {
|
|
72
|
+
enumerable: true,
|
|
73
|
+
configurable: true,
|
|
74
|
+
writable: true,
|
|
75
|
+
value: void 0
|
|
76
|
+
});
|
|
77
|
+
Object.defineProperty(this, "state", {
|
|
78
|
+
enumerable: true,
|
|
79
|
+
configurable: true,
|
|
80
|
+
writable: true,
|
|
81
|
+
value: void 0
|
|
82
|
+
});
|
|
83
|
+
// Canonical API field name is `crawler_uuid`; accept short `uuid` as a
|
|
84
|
+
// legacy fallback but throw if neither is present.
|
|
85
|
+
if ('crawler_uuid' in data && typeof data.crawler_uuid === 'string' && data.crawler_uuid) {
|
|
86
|
+
this.crawler_uuid = data.crawler_uuid;
|
|
87
|
+
}
|
|
88
|
+
else if ('uuid' in data && typeof data.uuid === 'string' && data.uuid) {
|
|
89
|
+
this.crawler_uuid = data.uuid;
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
throw new Error("CrawlerStatus: required field 'crawler_uuid' (or legacy 'uuid') is missing from API response");
|
|
93
|
+
}
|
|
94
|
+
this.status = requireField(data, 'status', 'string', 'CrawlerStatus');
|
|
95
|
+
this.is_finished = requireField(data, 'is_finished', 'boolean', 'CrawlerStatus');
|
|
96
|
+
// `is_success` is documented as nullable while the crawler is running.
|
|
97
|
+
const isSuccessRaw = 'is_success' in data ? data.is_success : null;
|
|
98
|
+
if (isSuccessRaw !== null && typeof isSuccessRaw !== 'boolean') {
|
|
99
|
+
throw new Error(`CrawlerStatus: field 'is_success' must be bool or null, got ${typeof isSuccessRaw}`);
|
|
100
|
+
}
|
|
101
|
+
this.is_success = isSuccessRaw;
|
|
102
|
+
const state = requireField(data, 'state', 'object', 'CrawlerStatus');
|
|
103
|
+
this.state = {
|
|
104
|
+
// URL counters and `duration` are always present and numeric (0 during PENDING).
|
|
105
|
+
urls_visited: requireField(state, 'urls_visited', 'number', 'CrawlerStatus.state'),
|
|
106
|
+
urls_extracted: requireField(state, 'urls_extracted', 'number', 'CrawlerStatus.state'),
|
|
107
|
+
urls_failed: requireField(state, 'urls_failed', 'number', 'CrawlerStatus.state'),
|
|
108
|
+
urls_skipped: requireField(state, 'urls_skipped', 'number', 'CrawlerStatus.state'),
|
|
109
|
+
urls_to_crawl: requireField(state, 'urls_to_crawl', 'number', 'CrawlerStatus.state'),
|
|
110
|
+
api_credit_used: requireField(state, 'api_credit_used', 'number', 'CrawlerStatus.state'),
|
|
111
|
+
duration: requireField(state, 'duration', 'number', 'CrawlerStatus.state'),
|
|
112
|
+
// `start_time` / `stop_time` / `stop_reason` are null until the crawler
|
|
113
|
+
// actually starts / stops — verified against the live server behavior.
|
|
114
|
+
start_time: optionalField(state, 'start_time', 'number', 'CrawlerStatus.state'),
|
|
115
|
+
stop_time: optionalField(state, 'stop_time', 'number', 'CrawlerStatus.state'),
|
|
116
|
+
stop_reason: optionalField(state, 'stop_reason', 'string', 'CrawlerStatus.state'),
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/** True while the crawler is still working (PENDING or RUNNING). */
|
|
120
|
+
get isRunning() {
|
|
121
|
+
return this.status === 'PENDING' || this.status === 'RUNNING';
|
|
122
|
+
}
|
|
123
|
+
/** True if the crawler reached a terminal state successfully. */
|
|
124
|
+
get isComplete() {
|
|
125
|
+
return this.status === 'DONE' && this.is_success === true;
|
|
126
|
+
}
|
|
127
|
+
/** True if the crawler reached a terminal state but failed. */
|
|
128
|
+
get isFailed() {
|
|
129
|
+
return this.status === 'DONE' && this.is_success === false;
|
|
130
|
+
}
|
|
131
|
+
/** True if the crawler was cancelled by the user. */
|
|
132
|
+
get isCancelled() {
|
|
133
|
+
return this.status === 'CANCELLED';
|
|
134
|
+
}
|
|
135
|
+
/**
|
|
136
|
+
* Rough progress estimate based on visited vs. extracted URLs (0–100).
|
|
137
|
+
* Returns 0 when nothing has been extracted yet.
|
|
138
|
+
*/
|
|
139
|
+
get progressPct() {
|
|
140
|
+
return this.state.urls_extracted > 0 ? (this.state.urls_visited / this.state.urls_extracted) * 100 : 0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
exports.CrawlerStatus = CrawlerStatus;
|
|
144
|
+
/**
|
|
145
|
+
* Wraps the streaming text response of `GET /crawl/{uuid}/urls`.
|
|
146
|
+
*
|
|
147
|
+
* The server returns one record per line with `Content-Type: text/plain`;
|
|
148
|
+
* this class parses that stream into a materialised list for caller
|
|
149
|
+
* convenience. For very large jobs, prefer {@link ScrapflyClient.crawlUrlsStream}
|
|
150
|
+
* (if provided) or call the endpoint via `client.fetch` directly and iterate
|
|
151
|
+
* the body as a stream.
|
|
152
|
+
*
|
|
153
|
+
* Pagination metadata fields (`page`, `per_page`) are echoes of the caller's
|
|
154
|
+
* request parameters — the wire protocol carries no global `total`, only the
|
|
155
|
+
* records in the current page. Use `urls.length` for the page size and
|
|
156
|
+
* request further pages by incrementing `page` until an empty response.
|
|
157
|
+
*/
|
|
158
|
+
class CrawlerUrls {
|
|
159
|
+
constructor(urls, page, perPage) {
|
|
160
|
+
Object.defineProperty(this, "urls", {
|
|
161
|
+
enumerable: true,
|
|
162
|
+
configurable: true,
|
|
163
|
+
writable: true,
|
|
164
|
+
value: void 0
|
|
165
|
+
});
|
|
166
|
+
Object.defineProperty(this, "page", {
|
|
167
|
+
enumerable: true,
|
|
168
|
+
configurable: true,
|
|
169
|
+
writable: true,
|
|
170
|
+
value: void 0
|
|
171
|
+
});
|
|
172
|
+
Object.defineProperty(this, "per_page", {
|
|
173
|
+
enumerable: true,
|
|
174
|
+
configurable: true,
|
|
175
|
+
writable: true,
|
|
176
|
+
value: void 0
|
|
177
|
+
});
|
|
178
|
+
this.urls = urls;
|
|
179
|
+
this.page = page;
|
|
180
|
+
this.per_page = perPage;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Parse the raw text body returned by `GET /crawl/{uuid}/urls`.
|
|
184
|
+
*
|
|
185
|
+
* - Empty lines are ignored (trailing newlines, blank records).
|
|
186
|
+
* - `visited` status → one URL per line, record has `{url, status: 'visited'}`.
|
|
187
|
+
* - `failed`/`skipped` status → `url,reason`, record includes `reason`.
|
|
188
|
+
* - When the caller didn't pass a `status` filter, the server defaults to
|
|
189
|
+
* `visited`; we pass that as the `statusHint` so every parsed record gets
|
|
190
|
+
* the right status tag.
|
|
191
|
+
*
|
|
192
|
+
* @param body Raw text body of the response.
|
|
193
|
+
* @param statusHint The status filter passed on the request (for tagging).
|
|
194
|
+
* @param page Caller-provided page (echoed on the response object).
|
|
195
|
+
* @param perPage Caller-provided per_page (echoed on the response object).
|
|
196
|
+
*/
|
|
197
|
+
static fromText(body, statusHint, page, perPage) {
|
|
198
|
+
const urls = [];
|
|
199
|
+
for (const rawLine of body.split(/\r?\n/)) {
|
|
200
|
+
const line = rawLine.trim();
|
|
201
|
+
if (!line)
|
|
202
|
+
continue;
|
|
203
|
+
if (statusHint === 'visited' || statusHint === 'pending') {
|
|
204
|
+
// Plain URL per line.
|
|
205
|
+
urls.push({ url: line, status: statusHint });
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
// `url,reason` — split on the first comma.
|
|
209
|
+
const commaIdx = line.indexOf(',');
|
|
210
|
+
if (commaIdx === -1) {
|
|
211
|
+
urls.push({ url: line, status: statusHint });
|
|
212
|
+
}
|
|
213
|
+
else {
|
|
214
|
+
urls.push({
|
|
215
|
+
url: line.slice(0, commaIdx),
|
|
216
|
+
status: statusHint,
|
|
217
|
+
reason: line.slice(commaIdx + 1),
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
return new CrawlerUrls(urls, page, perPage);
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
exports.CrawlerUrls = CrawlerUrls;
|
|
226
|
+
/**
|
|
227
|
+
* Wraps the JSON-mode response of `GET /crawl/{uuid}/contents` (i.e. `plain=false`).
|
|
228
|
+
*
|
|
229
|
+
* The `contents` field maps each URL to a map of format → content. When
|
|
230
|
+
* `plain=true` is used instead, {@link ScrapflyClient.crawlContents} returns
|
|
231
|
+
* a raw `string` directly rather than this class.
|
|
232
|
+
*
|
|
233
|
+
* Strict parsing: `contents` and `links` are both required per the documented
|
|
234
|
+
* contract. A response missing either field indicates an API contract change
|
|
235
|
+
* and throws at parse time rather than producing an empty envelope that looks
|
|
236
|
+
* valid.
|
|
237
|
+
*/
|
|
238
|
+
class CrawlerContents {
|
|
239
|
+
constructor(data) {
|
|
240
|
+
Object.defineProperty(this, "contents", {
|
|
241
|
+
enumerable: true,
|
|
242
|
+
configurable: true,
|
|
243
|
+
writable: true,
|
|
244
|
+
value: void 0
|
|
245
|
+
});
|
|
246
|
+
Object.defineProperty(this, "links", {
|
|
247
|
+
enumerable: true,
|
|
248
|
+
configurable: true,
|
|
249
|
+
writable: true,
|
|
250
|
+
value: void 0
|
|
251
|
+
});
|
|
252
|
+
this.contents = requireField(data, 'contents', 'object', 'CrawlerContents');
|
|
253
|
+
this.links = requireField(data, 'links', 'object', 'CrawlerContents');
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
exports.CrawlerContents = CrawlerContents;
|
|
257
|
+
/**
|
|
258
|
+
* Holds the raw bytes of a downloaded WARC or HAR artifact.
|
|
259
|
+
*
|
|
260
|
+
* **Note on parsing:** the SDK does NOT bundle WARC or HAR parsers. Use a dedicated
|
|
261
|
+
* library (e.g. `warcio` on npm for WARC) if you need to walk the records. The
|
|
262
|
+
* `save()` method is provided for the common case of writing the artifact to disk.
|
|
263
|
+
*/
|
|
264
|
+
class CrawlerArtifact {
|
|
265
|
+
constructor(type, data) {
|
|
266
|
+
Object.defineProperty(this, "type", {
|
|
267
|
+
enumerable: true,
|
|
268
|
+
configurable: true,
|
|
269
|
+
writable: true,
|
|
270
|
+
value: void 0
|
|
271
|
+
});
|
|
272
|
+
Object.defineProperty(this, "data", {
|
|
273
|
+
enumerable: true,
|
|
274
|
+
configurable: true,
|
|
275
|
+
writable: true,
|
|
276
|
+
value: void 0
|
|
277
|
+
});
|
|
278
|
+
this.type = type;
|
|
279
|
+
this.data = data;
|
|
280
|
+
}
|
|
281
|
+
/** Write the artifact to a file on disk. */
|
|
282
|
+
async save(filepath) {
|
|
283
|
+
await (0, polyfill_js_1.writeFile)(filepath, this.data);
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
exports.CrawlerArtifact = CrawlerArtifact;
|
|
287
|
+
const LIFECYCLE_EVENTS = new Set([
|
|
288
|
+
'crawler_started',
|
|
289
|
+
'crawler_stopped',
|
|
290
|
+
'crawler_cancelled',
|
|
291
|
+
'crawler_finished',
|
|
292
|
+
]);
|
|
293
|
+
/**
|
|
294
|
+
* Parse a raw webhook body (JSON-decoded object) into a typed crawler webhook payload.
|
|
295
|
+
*
|
|
296
|
+
* Throws `Error` if the body is not an object, has no `event` field, or carries an
|
|
297
|
+
* unknown event name. Use this in your webhook handler after `JSON.parse()`.
|
|
298
|
+
*
|
|
299
|
+
* @example
|
|
300
|
+
* ```ts
|
|
301
|
+
* import { parseCrawlerWebhook } from '@scrapfly/scrapfly-sdk';
|
|
302
|
+
*
|
|
303
|
+
* app.post('/webhook', async (req, res) => {
|
|
304
|
+
* const body = await req.json();
|
|
305
|
+
* const webhook = parseCrawlerWebhook(body);
|
|
306
|
+
* if (webhook.event === 'crawler_finished') {
|
|
307
|
+
* console.log('done', webhook.payload.state.urls_visited);
|
|
308
|
+
* }
|
|
309
|
+
* });
|
|
310
|
+
* ```
|
|
311
|
+
*/
|
|
312
|
+
function parseCrawlerWebhook(body) {
|
|
313
|
+
if (typeof body !== 'object' || body === null) {
|
|
314
|
+
throw new Error('Crawler webhook body must be a JSON object');
|
|
315
|
+
}
|
|
316
|
+
const obj = body;
|
|
317
|
+
const event = obj.event;
|
|
318
|
+
if (typeof event !== 'string') {
|
|
319
|
+
throw new Error('Crawler webhook body is missing required `event` string field');
|
|
320
|
+
}
|
|
321
|
+
if (typeof obj.payload !== 'object' || obj.payload === null) {
|
|
322
|
+
throw new Error('Crawler webhook body is missing required `payload` object field');
|
|
323
|
+
}
|
|
324
|
+
if (LIFECYCLE_EVENTS.has(event) ||
|
|
325
|
+
event === 'crawler_url_visited' ||
|
|
326
|
+
event === 'crawler_url_skipped' ||
|
|
327
|
+
event === 'crawler_url_discovered' ||
|
|
328
|
+
event === 'crawler_url_failed') {
|
|
329
|
+
// The body has already been validated to have an `event` and `payload`. The
|
|
330
|
+
// narrower per-event field shapes are runtime-checked by the discriminated union
|
|
331
|
+
// — TypeScript users get the typed view; runtime users get a permissive bag.
|
|
332
|
+
return obj;
|
|
333
|
+
}
|
|
334
|
+
throw new Error(`Unknown crawler webhook event: ${event}`);
|
|
335
|
+
}
|
package/script/errors.d.ts
CHANGED
|
@@ -8,6 +8,8 @@ export declare class ScreenshotConfigError extends ScrapflyError {
|
|
|
8
8
|
}
|
|
9
9
|
export declare class ExtractionConfigError extends ScrapflyError {
|
|
10
10
|
}
|
|
11
|
+
export declare class CrawlerConfigError extends ScrapflyError {
|
|
12
|
+
}
|
|
11
13
|
export declare class EncodeError extends ScrapflyError {
|
|
12
14
|
}
|
|
13
15
|
export declare class ContentTypeError extends ScrapflyError {
|
|
@@ -50,4 +52,6 @@ export declare class ScreenshotApiError extends ApiHttpClientError {
|
|
|
50
52
|
}
|
|
51
53
|
export declare class ExtractionApiError extends ApiHttpClientError {
|
|
52
54
|
}
|
|
55
|
+
export declare class ScrapflyCrawlerError extends HttpError {
|
|
56
|
+
}
|
|
53
57
|
//# sourceMappingURL=errors.d.ts.map
|
package/script/errors.d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AAQ,SAAS;CAAG;AACpD,qBAAa,mBAAoB,SAAQ,SAAS;CAAG;AAErD,qBAAa,kBAAmB,SAAQ,SAAS;CAAG;AACpD,qBAAa,qBAAsB,SAAQ,SAAS;CAAG;AAEvD,qBAAa,gBAAiB,SAAQ,SAAS;CAAG;AAClD,qBAAa,qBAAsB,SAAQ,SAAS;CAAG;AAEvD,qBAAa,oBAAqB,SAAQ,SAAS;CAAG;AAEtD,qBAAa,oBAAqB,SAAQ,SAAS;CAAG;AAEtD,qBAAa,yBAA0B,SAAQ,SAAS;CAAG;AAE3D,qBAAa,iBAAkB,SAAQ,SAAS;CAAG;AAEnD,qBAAa,kBAAmB,SAAQ,kBAAkB;CAAG;AAE7D,qBAAa,kBAAmB,SAAQ,kBAAkB;CAAG;AAE7D,qBAAa,oBAAqB,SAAQ,SAAS;CAAG"}
|
package/script/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ExtractionApiError = exports.ScreenshotApiError = exports.QuotaLimitReached = exports.TooManyConcurrentRequests = exports.ScrapflySessionError = exports.ScrapflyWebhookError = exports.ScrapflyScheduleError = exports.ScrapflyAspError = exports.ScrapflyThrottleError = exports.ScrapflyProxyError = exports.ScrapflyScrapeError = exports.ApiHttpServerError = exports.TooManyRequests = exports.BadApiKeyError = exports.ApiHttpClientError = exports.UpstreamHttpServerError = exports.UpstreamHttpClientError = exports.UpstreamHttpError = exports.HttpError = exports.ContentTypeError = exports.EncodeError = exports.ExtractionConfigError = exports.ScreenshotConfigError = exports.ScrapeConfigError = exports.ScrapflyError = void 0;
|
|
3
|
+
exports.ScrapflyCrawlerError = exports.ExtractionApiError = exports.ScreenshotApiError = exports.QuotaLimitReached = exports.TooManyConcurrentRequests = exports.ScrapflySessionError = exports.ScrapflyWebhookError = exports.ScrapflyScheduleError = exports.ScrapflyAspError = exports.ScrapflyThrottleError = exports.ScrapflyProxyError = exports.ScrapflyScrapeError = exports.ApiHttpServerError = exports.TooManyRequests = exports.BadApiKeyError = exports.ApiHttpClientError = exports.UpstreamHttpServerError = exports.UpstreamHttpClientError = exports.UpstreamHttpError = exports.HttpError = exports.ContentTypeError = exports.EncodeError = exports.CrawlerConfigError = exports.ExtractionConfigError = exports.ScreenshotConfigError = exports.ScrapeConfigError = exports.ScrapflyError = void 0;
|
|
4
4
|
class ScrapflyError extends Error {
|
|
5
5
|
constructor(message, args = {}) {
|
|
6
6
|
super(message);
|
|
@@ -26,6 +26,10 @@ exports.ScreenshotConfigError = ScreenshotConfigError;
|
|
|
26
26
|
class ExtractionConfigError extends ScrapflyError {
|
|
27
27
|
}
|
|
28
28
|
exports.ExtractionConfigError = ExtractionConfigError;
|
|
29
|
+
// raised when crawler config is invalid
|
|
30
|
+
class CrawlerConfigError extends ScrapflyError {
|
|
31
|
+
}
|
|
32
|
+
exports.CrawlerConfigError = CrawlerConfigError;
|
|
29
33
|
// raised when scrape parameters cannot be encoded
|
|
30
34
|
class EncodeError extends ScrapflyError {
|
|
31
35
|
}
|
|
@@ -100,3 +104,7 @@ exports.ScreenshotApiError = ScreenshotApiError;
|
|
|
100
104
|
class ExtractionApiError extends ApiHttpClientError {
|
|
101
105
|
}
|
|
102
106
|
exports.ExtractionApiError = ExtractionApiError;
|
|
107
|
+
// raised with Scrapfly crawler API related errors (job lifecycle: ALREADY_STARTED, NOT_STARTED, FAILED, CANCELLED, TIMEOUT, etc.)
|
|
108
|
+
class ScrapflyCrawlerError extends HttpError {
|
|
109
|
+
}
|
|
110
|
+
exports.ScrapflyCrawlerError = ScrapflyCrawlerError;
|
|
@@ -24,6 +24,7 @@ type ExtractionConfigOptions = {
|
|
|
24
24
|
is_document_compressed?: boolean;
|
|
25
25
|
document_compression_format?: 'gzip' | 'zstd' | 'deflate' | CompressionFormat;
|
|
26
26
|
webhook?: string;
|
|
27
|
+
timeout?: number;
|
|
27
28
|
template?: string;
|
|
28
29
|
ephemeral_template?: object;
|
|
29
30
|
};
|
|
@@ -39,6 +40,7 @@ export declare class ExtractionConfig {
|
|
|
39
40
|
is_document_compressed?: boolean;
|
|
40
41
|
document_compression_format?: 'gzip' | 'zstd' | 'deflate' | CompressionFormat;
|
|
41
42
|
webhook?: string;
|
|
43
|
+
timeout?: number;
|
|
42
44
|
template?: string;
|
|
43
45
|
ephemeral_template?: object;
|
|
44
46
|
constructor(options: ExtractionConfigOptions);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extractionconfig.d.ts","sourceRoot":"","sources":["../src/extractionconfig.ts"],"names":[],"mappings":"AAIA,oBAAY,iBAAiB;IAC3B;;;;;;;;SAQK;IACL,IAAI,SAAS;IACb,IAAI,SAAS;IACb,OAAO,YAAY;CACpB;AAED,KAAK,uBAAuB,GAAG;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,2BAA2B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,iBAAiB,CAAC;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;CAC7B,CAAC;AAEF,qBAAa,gBAAgB;IAC3B,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE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C;IAC1B,YAAY,EAAE,MAAM,CAAC;IACrB,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,6BAA6B,CAAC,EAAE,MAAM,CAAC;IACvC,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC,2BAA2B,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,GAAG,iBAAiB,CAAC;IAC9E,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;IAGjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,CAAC;gBAEhB,OAAO,EAAE,uBAAuB;IAyC5C,OAAO,CAAC,eAAe;IASvB,WAAW,CAAC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC;CAoE3D"}
|
|
@@ -110,6 +110,12 @@ class ExtractionConfig {
|
|
|
110
110
|
writable: true,
|
|
111
111
|
value: void 0
|
|
112
112
|
});
|
|
113
|
+
Object.defineProperty(this, "timeout", {
|
|
114
|
+
enumerable: true,
|
|
115
|
+
configurable: true,
|
|
116
|
+
writable: true,
|
|
117
|
+
value: void 0
|
|
118
|
+
});
|
|
113
119
|
// // deprecated options
|
|
114
120
|
Object.defineProperty(this, "template", {
|
|
115
121
|
enumerable: true,
|
|
@@ -153,6 +159,7 @@ class ExtractionConfig {
|
|
|
153
159
|
this.is_document_compressed = options.is_document_compressed ?? this.is_document_compressed;
|
|
154
160
|
this.document_compression_format = options.document_compression_format ?? this.document_compression_format;
|
|
155
161
|
this.webhook = options.webhook ?? this.webhook;
|
|
162
|
+
this.timeout = options.timeout ?? this.timeout;
|
|
156
163
|
}
|
|
157
164
|
validateOptions(options) {
|
|
158
165
|
const validKeys = new Set(Object.keys(this));
|
|
@@ -209,6 +216,9 @@ class ExtractionConfig {
|
|
|
209
216
|
if (this.webhook) {
|
|
210
217
|
params.webhook_name = this.webhook;
|
|
211
218
|
}
|
|
219
|
+
if (this.timeout) {
|
|
220
|
+
params.timeout = this.timeout;
|
|
221
|
+
}
|
|
212
222
|
return params;
|
|
213
223
|
}
|
|
214
224
|
}
|
package/script/main.d.ts
CHANGED
|
@@ -1,10 +1,17 @@
|
|
|
1
1
|
export { ScrapflyClient } from './client.js';
|
|
2
2
|
export { Format as ScrapeFormat, FormatOption as ScrapeFormatOptions, ScrapeConfig, ScreenshotFlags, } from './scrapeconfig.js';
|
|
3
|
-
export { Format as ScreenshotFormat, Options as ScreenshotOptions, ScreenshotConfig } from './screenshotconfig.js';
|
|
3
|
+
export { Format as ScreenshotFormat, Options as ScreenshotOptions, ScreenshotConfig, VisionDeficiency, } from './screenshotconfig.js';
|
|
4
4
|
export { ExtractionConfig } from './extractionconfig.js';
|
|
5
|
+
export { BrowserConfig, ProxyPool, OperatingSystem } from './browserconfig.js';
|
|
6
|
+
export type { BrowserConfigOptions } from './browserconfig.js';
|
|
5
7
|
export * as errors from './errors.js';
|
|
6
8
|
export { ExtractionResult, ScrapeResult, ScreenshotResult } from './result.js';
|
|
7
9
|
export type { AccountData, ConfigData, ContextData, ResultData, ScreenshotMetadata } from './result.js';
|
|
10
|
+
export { CrawlerConfig } from './crawlerconfig.js';
|
|
11
|
+
export type { CrawlerConfigOptions, CrawlerContentFormat, CrawlerWebhookEventName } from './crawlerconfig.js';
|
|
12
|
+
export { Crawl } from './crawl.js';
|
|
13
|
+
export { CrawlerArtifact, CrawlerContents, CrawlerStatus, CrawlerUrls, parseCrawlerWebhook, } from './crawlerresult.js';
|
|
14
|
+
export type { CrawlerArtifactType, CrawlerLifecycleWebhook, CrawlerState, CrawlerStatusValue, CrawlerStopReason, CrawlerUrlDiscoveredWebhook, CrawlerUrlEntry, CrawlerUrlFailedWebhook, CrawlerUrlSkippedWebhook, CrawlerUrlVisitedWebhook, CrawlerWebhookCommon, CrawlerWebhookPayload, } from './crawlerresult.js';
|
|
8
15
|
export { log } from './logger.js';
|
|
9
16
|
export { createServer, verifySignature } from './webhookserver.js';
|
|
10
17
|
//# sourceMappingURL=main.d.ts.map
|
package/script/main.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,IAAI,mBAAmB,EACnC,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,
|
|
1
|
+
{"version":3,"file":"main.d.ts","sourceRoot":"","sources":["../src/main.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,MAAM,IAAI,YAAY,EACtB,YAAY,IAAI,mBAAmB,EACnC,YAAY,EACZ,eAAe,GAChB,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EACL,MAAM,IAAI,gBAAgB,EAC1B,OAAO,IAAI,iBAAiB,EAC5B,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AACzD,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAC/E,YAAY,EAAE,oBAAoB,EAAE,MAAM,oBAAoB,CAAC;AAC/D,OAAO,KAAK,MAAM,MAAM,aAAa,CAAC;AAEtC,OAAO,EAAE,gBAAgB,EAAE,YAAY,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/E,YAAY,EAAE,WAAW,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAGxG,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,YAAY,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AAC9G,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EACL,eAAe,EACf,eAAe,EACf,aAAa,EACb,WAAW,EACX,mBAAmB,GACpB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EACV,mBAAmB,EACnB,uBAAuB,EACvB,YAAY,EACZ,kBAAkB,EAClB,iBAAiB,EACjB,2BAA2B,EAC3B,eAAe,EACf,uBAAuB,EACvB,wBAAwB,EACxB,wBAAwB,EACxB,oBAAoB,EACpB,qBAAqB,GACtB,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,GAAG,EAAE,MAAM,aAAa,CAAC;AAElC,OAAO,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC"}
|
package/script/main.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.verifySignature = exports.createServer = exports.log = exports.ScreenshotResult = exports.ScrapeResult = exports.ExtractionResult = exports.errors = exports.ExtractionConfig = exports.ScreenshotConfig = exports.ScreenshotOptions = exports.ScreenshotFormat = exports.ScreenshotFlags = exports.ScrapeConfig = exports.ScrapeFormatOptions = exports.ScrapeFormat = exports.ScrapflyClient = void 0;
|
|
26
|
+
exports.verifySignature = exports.createServer = exports.log = exports.parseCrawlerWebhook = exports.CrawlerUrls = exports.CrawlerStatus = exports.CrawlerContents = exports.CrawlerArtifact = exports.Crawl = exports.CrawlerConfig = exports.ScreenshotResult = exports.ScrapeResult = exports.ExtractionResult = exports.errors = exports.OperatingSystem = exports.ProxyPool = exports.BrowserConfig = exports.ExtractionConfig = exports.VisionDeficiency = exports.ScreenshotConfig = exports.ScreenshotOptions = exports.ScreenshotFormat = exports.ScreenshotFlags = exports.ScrapeConfig = exports.ScrapeFormatOptions = exports.ScrapeFormat = exports.ScrapflyClient = void 0;
|
|
27
27
|
var client_js_1 = require("./client.js");
|
|
28
28
|
Object.defineProperty(exports, "ScrapflyClient", { enumerable: true, get: function () { return client_js_1.ScrapflyClient; } });
|
|
29
29
|
var scrapeconfig_js_1 = require("./scrapeconfig.js");
|
|
@@ -35,13 +35,29 @@ var screenshotconfig_js_1 = require("./screenshotconfig.js");
|
|
|
35
35
|
Object.defineProperty(exports, "ScreenshotFormat", { enumerable: true, get: function () { return screenshotconfig_js_1.Format; } });
|
|
36
36
|
Object.defineProperty(exports, "ScreenshotOptions", { enumerable: true, get: function () { return screenshotconfig_js_1.Options; } });
|
|
37
37
|
Object.defineProperty(exports, "ScreenshotConfig", { enumerable: true, get: function () { return screenshotconfig_js_1.ScreenshotConfig; } });
|
|
38
|
+
Object.defineProperty(exports, "VisionDeficiency", { enumerable: true, get: function () { return screenshotconfig_js_1.VisionDeficiency; } });
|
|
38
39
|
var extractionconfig_js_1 = require("./extractionconfig.js");
|
|
39
40
|
Object.defineProperty(exports, "ExtractionConfig", { enumerable: true, get: function () { return extractionconfig_js_1.ExtractionConfig; } });
|
|
41
|
+
var browserconfig_js_1 = require("./browserconfig.js");
|
|
42
|
+
Object.defineProperty(exports, "BrowserConfig", { enumerable: true, get: function () { return browserconfig_js_1.BrowserConfig; } });
|
|
43
|
+
Object.defineProperty(exports, "ProxyPool", { enumerable: true, get: function () { return browserconfig_js_1.ProxyPool; } });
|
|
44
|
+
Object.defineProperty(exports, "OperatingSystem", { enumerable: true, get: function () { return browserconfig_js_1.OperatingSystem; } });
|
|
40
45
|
exports.errors = __importStar(require("./errors.js"));
|
|
41
46
|
var result_js_1 = require("./result.js");
|
|
42
47
|
Object.defineProperty(exports, "ExtractionResult", { enumerable: true, get: function () { return result_js_1.ExtractionResult; } });
|
|
43
48
|
Object.defineProperty(exports, "ScrapeResult", { enumerable: true, get: function () { return result_js_1.ScrapeResult; } });
|
|
44
49
|
Object.defineProperty(exports, "ScreenshotResult", { enumerable: true, get: function () { return result_js_1.ScreenshotResult; } });
|
|
50
|
+
// Crawler API
|
|
51
|
+
var crawlerconfig_js_1 = require("./crawlerconfig.js");
|
|
52
|
+
Object.defineProperty(exports, "CrawlerConfig", { enumerable: true, get: function () { return crawlerconfig_js_1.CrawlerConfig; } });
|
|
53
|
+
var crawl_js_1 = require("./crawl.js");
|
|
54
|
+
Object.defineProperty(exports, "Crawl", { enumerable: true, get: function () { return crawl_js_1.Crawl; } });
|
|
55
|
+
var crawlerresult_js_1 = require("./crawlerresult.js");
|
|
56
|
+
Object.defineProperty(exports, "CrawlerArtifact", { enumerable: true, get: function () { return crawlerresult_js_1.CrawlerArtifact; } });
|
|
57
|
+
Object.defineProperty(exports, "CrawlerContents", { enumerable: true, get: function () { return crawlerresult_js_1.CrawlerContents; } });
|
|
58
|
+
Object.defineProperty(exports, "CrawlerStatus", { enumerable: true, get: function () { return crawlerresult_js_1.CrawlerStatus; } });
|
|
59
|
+
Object.defineProperty(exports, "CrawlerUrls", { enumerable: true, get: function () { return crawlerresult_js_1.CrawlerUrls; } });
|
|
60
|
+
Object.defineProperty(exports, "parseCrawlerWebhook", { enumerable: true, get: function () { return crawlerresult_js_1.parseCrawlerWebhook; } });
|
|
45
61
|
var logger_js_1 = require("./logger.js");
|
|
46
62
|
Object.defineProperty(exports, "log", { enumerable: true, get: function () { return logger_js_1.log; } });
|
|
47
63
|
var webhookserver_js_1 = require("./webhookserver.js");
|
package/script/polyfill.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import * as dntShim from "./_dnt.shims.js";
|
|
2
2
|
export declare const isDeno: boolean;
|
|
3
|
+
export declare const isBun: boolean;
|
|
4
|
+
export declare function readFileSync(path: string): Uint8Array;
|
|
3
5
|
export declare function mkdir(path: string | URL, options: dntShim.Deno.MkdirOptions): Promise<void>;
|
|
4
6
|
export declare function writeFile(path: string | URL, data: Uint8Array, options?: dntShim.Deno.WriteFileOptions): Promise<void>;
|
|
5
7
|
//# sourceMappingURL=polyfill.d.ts.map
|
package/script/polyfill.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"polyfill.d.ts","sourceRoot":"","sources":["../src/polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,eAAO,MAAM,MAAM,SAAsC,CAAC;AAE1D,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjG;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,gBAAqB,GAC1C,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
|
1
|
+
{"version":3,"file":"polyfill.d.ts","sourceRoot":"","sources":["../src/polyfill.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,OAAO,MAAM,iBAAiB,CAAC;AAC3C,eAAO,MAAM,MAAM,SAAsC,CAAC;AAE1D,eAAO,MAAM,KAAK,SAA6B,CAAC;AAEhD,wBAAgB,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CASrD;AAED,wBAAsB,KAAK,CAAC,IAAI,EAAE,MAAM,GAAG,GAAG,EAAE,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAOjG;AAED,wBAAsB,SAAS,CAC7B,IAAI,EAAE,MAAM,GAAG,GAAG,EAClB,IAAI,EAAE,UAAU,EAChB,OAAO,GAAE,OAAO,CAAC,IAAI,CAAC,gBAAqB,GAC1C,OAAO,CAAC,IAAI,CAAC,CAOf"}
|
package/script/polyfill.js
CHANGED
|
@@ -23,11 +23,24 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
return result;
|
|
24
24
|
};
|
|
25
25
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.isDeno = void 0;
|
|
26
|
+
exports.isBun = exports.isDeno = void 0;
|
|
27
|
+
exports.readFileSync = readFileSync;
|
|
27
28
|
exports.mkdir = mkdir;
|
|
28
29
|
exports.writeFile = writeFile;
|
|
29
30
|
const dntShim = __importStar(require("./_dnt.shims.js"));
|
|
30
31
|
exports.isDeno = typeof dntShim.Deno !== 'undefined';
|
|
32
|
+
// @ts-ignore: Bun global
|
|
33
|
+
exports.isBun = typeof Bun !== 'undefined';
|
|
34
|
+
function readFileSync(path) {
|
|
35
|
+
if (exports.isDeno) {
|
|
36
|
+
return dntShim.Deno.readFileSync(path);
|
|
37
|
+
}
|
|
38
|
+
// Node.js / Bun — both support require('fs')
|
|
39
|
+
// deno-lint-ignore no-var
|
|
40
|
+
// @ts-ignore: dynamic require for Node/Bun
|
|
41
|
+
var fs = require('fs');
|
|
42
|
+
return new Uint8Array(fs.readFileSync(path));
|
|
43
|
+
}
|
|
31
44
|
async function mkdir(path, options) {
|
|
32
45
|
if (exports.isDeno) {
|
|
33
46
|
await dntShim.Deno.mkdir(path, options);
|
package/script/scrapeconfig.d.ts
CHANGED
|
@@ -75,6 +75,29 @@ type ScrapeConfigOptions = {
|
|
|
75
75
|
os?: string;
|
|
76
76
|
lang?: string[];
|
|
77
77
|
auto_scroll?: boolean;
|
|
78
|
+
/**
|
|
79
|
+
* Chromium-based browser brand used for fingerprint generation.
|
|
80
|
+
* One of "chrome" | "edge" | "brave" | "opera". Defaults to "chrome"
|
|
81
|
+
* when omitted. Invalid values are silently dropped by the server.
|
|
82
|
+
*/
|
|
83
|
+
browser_brand?: string;
|
|
84
|
+
/**
|
|
85
|
+
* Return the raw upstream response (target's status, headers, body)
|
|
86
|
+
* instead of the JSON envelope. When true, ScrapflyClient.scrape()
|
|
87
|
+
* returns the raw fetch Response so callers can drive it like any
|
|
88
|
+
* HTTP response. Scrapfly metadata is on the X-Scrapfly-* headers.
|
|
89
|
+
*/
|
|
90
|
+
proxified_response?: boolean;
|
|
91
|
+
/**
|
|
92
|
+
* Controls when the browser considers the page loaded.
|
|
93
|
+
* "complete" (default) or "domcontentloaded" for faster scrapes.
|
|
94
|
+
*/
|
|
95
|
+
rendering_stage?: 'complete' | 'domcontentloaded';
|
|
96
|
+
/**
|
|
97
|
+
* Spoof browser geolocation. Format: "latitude,longitude"
|
|
98
|
+
* e.g. "48.856614,2.3522219" for Paris.
|
|
99
|
+
*/
|
|
100
|
+
geolocation?: string;
|
|
78
101
|
};
|
|
79
102
|
export declare class ScrapeConfig {
|
|
80
103
|
static PUBLIC_DATACENTER_POOL: string;
|
|
@@ -119,6 +142,10 @@ export declare class ScrapeConfig {
|
|
|
119
142
|
lang?: string[];
|
|
120
143
|
os?: string;
|
|
121
144
|
auto_scroll?: boolean;
|
|
145
|
+
browser_brand?: string;
|
|
146
|
+
proxified_response?: boolean;
|
|
147
|
+
rendering_stage?: 'complete' | 'domcontentloaded';
|
|
148
|
+
geolocation?: string;
|
|
122
149
|
constructor(options: ScrapeConfigOptions);
|
|
123
150
|
private validateOptions;
|
|
124
151
|
toApiParams(options: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"scrapeconfig.d.ts","sourceRoot":"","sources":["../src/scrapeconfig.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,YAAY,CAAC;AAGlD,oBAAY,eAAe;IACzB;;;;;;;QAOI;IACJ,WAAW,gBAAgB;IAC3B,SAAS,cAAc;IACvB,aAAa,kBAAkB;IAC/B,kBAAkB,uBAAuB;IACzC,YAAY,iBAAiB;CAC9B;AAED,oBAAY,MAAM;IAChB;;;;;;;QAOI;IACJ,IAAI,SAAS;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