@mrscraper/sdk 5.0.0 → 6.0.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 +523 -176
- package/dist/api.d.ts +99 -105
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +186 -185
- package/dist/api.js.map +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +6 -5
- package/dist/internal.d.ts +0 -57
- package/dist/internal.d.ts.map +0 -1
- package/dist/internal.js +0 -64
- package/dist/internal.js.map +0 -1
package/dist/internal.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
// Internal format-specific helpers from SDK 4.x. They are not re-exported from
|
|
2
|
-
// the package entry point, and the package `exports` map blocks deep imports.
|
|
3
|
-
// Public callers use `scraper_api`, `web_search`, and `account` instead.
|
|
4
|
-
import { authHeaders, request, requireToken, scrape, setIfPresent } from "./api.js";
|
|
5
|
-
/** Fetch HTML. Only html=true is sent; other output flags are omitted. */
|
|
6
|
-
export async function scraper_html(url, options = {}) {
|
|
7
|
-
return scrape(url, options, { html: true });
|
|
8
|
-
}
|
|
9
|
-
/** Fetch Markdown. Only markdown=true is sent; other output flags are omitted. */
|
|
10
|
-
export async function scraper_markdown(url, options = {}) {
|
|
11
|
-
return scrape(url, options, { markdown: true });
|
|
12
|
-
}
|
|
13
|
-
/** Capture a screenshot using GET. Images are returned as Buffer in data. */
|
|
14
|
-
export async function get_screenshot(url, options = {}) {
|
|
15
|
-
const fullPage = options.full_page === undefined ? true : options.full_page;
|
|
16
|
-
if (typeof fullPage !== "boolean")
|
|
17
|
-
throw new TypeError("full_page must be a boolean");
|
|
18
|
-
return scrape(url, {
|
|
19
|
-
...options,
|
|
20
|
-
timeout: options.timeout ?? 300,
|
|
21
|
-
wait_until: options.wait_until === undefined ? "domcontentloaded" : options.wait_until,
|
|
22
|
-
}, { method: "GET", screenshot: fullPage ? "full" : true });
|
|
23
|
-
}
|
|
24
|
-
/** Extract structured JSON with the general agent and html=true. */
|
|
25
|
-
export async function scraper_json(url, options = {}) {
|
|
26
|
-
return scrape(url, options, {
|
|
27
|
-
html: true, agent: "general", prompt: options.prompt ?? "Extract all data as complete as possible.",
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
/** Extract entries across multiple pages using the listing agent. */
|
|
31
|
-
export async function scraper_multiple_page(url, options = {}) {
|
|
32
|
-
return scrape(url, options, {
|
|
33
|
-
agent: "listing", prompt: options.prompt ?? "Extract all entry data as complete as possible.",
|
|
34
|
-
max_pages: options.max_pages ?? 3,
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
/** Discover URLs with the map agent; pattern strings are preserved unchanged. */
|
|
38
|
-
export async function scraper_sitemap(url, options = {}) {
|
|
39
|
-
return scrape(url, options, {
|
|
40
|
-
agent: "map", max_depth: options.max_depth ?? 2, max_pages: options.max_pages ?? 3,
|
|
41
|
-
limit: options.limit ?? 1000, include_patterns: options.include_patterns,
|
|
42
|
-
exclude_patterns: options.exclude_patterns,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
45
|
-
/** Start a brand-scraping job; use the returned job ID with get_brand. */
|
|
46
|
-
export async function scrape_brand(url, options = {}) {
|
|
47
|
-
return scrape(url, options, { action: "brand-scraping", bundle: options.bundle ?? "clean" });
|
|
48
|
-
}
|
|
49
|
-
/** Read a brand job or download HTML, a ZIP bundle, or a screenshot. */
|
|
50
|
-
export async function get_brand(job_id, options = {}) {
|
|
51
|
-
const token = requireToken(options.token);
|
|
52
|
-
if (typeof job_id !== "string" || !job_id.trim())
|
|
53
|
-
throw new TypeError("job_id must be a non-empty string");
|
|
54
|
-
if (options.output != null && !["html", "bundle", "screenshot", "screenshot_full"].includes(options.output)) {
|
|
55
|
-
throw new TypeError("output must be 'html', 'bundle', 'screenshot', or 'screenshot_full'");
|
|
56
|
-
}
|
|
57
|
-
const timeout = options.timeout ?? 600;
|
|
58
|
-
if (!Number.isFinite(timeout) || timeout <= 0)
|
|
59
|
-
throw new RangeError("timeout must be greater than 0 seconds");
|
|
60
|
-
const params = new URLSearchParams({ id: job_id });
|
|
61
|
-
setIfPresent(params, "output", options.output);
|
|
62
|
-
return request("GET", `https://api.mrscraper.com/neo/brand?${params}`, undefined, authHeaders(token), timeout, token);
|
|
63
|
-
}
|
|
64
|
-
//# sourceMappingURL=internal.js.map
|
package/dist/internal.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.js","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAAA,+EAA+E;AAC/E,8EAA8E;AAC9E,yEAAyE;AACzE,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAkDpF,0EAA0E;AAC1E,MAAM,CAAC,KAAK,UAAU,YAAY,CAChC,GAAW,EAAE,UAA0B,EAAE;IAEzC,OAAO,MAAM,CAAI,GAAG,EAAE,OAAO,EAAE,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;AACjD,CAAC;AAED,kFAAkF;AAClF,MAAM,CAAC,KAAK,UAAU,gBAAgB,CACpC,GAAW,EAAE,UAA0B,EAAE;IAEzC,OAAO,MAAM,CAAI,GAAG,EAAE,OAAO,EAAE,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC,CAAC;AACrD,CAAC;AAED,6EAA6E;AAC7E,MAAM,CAAC,KAAK,UAAU,cAAc,CAClC,GAAW,EAAE,UAA6B,EAAE;IAE5C,MAAM,QAAQ,GAAG,OAAO,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC;IAC5E,IAAI,OAAO,QAAQ,KAAK,SAAS;QAAE,MAAM,IAAI,SAAS,CAAC,6BAA6B,CAAC,CAAC;IACtF,OAAO,MAAM,CAAI,GAAG,EAA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