@mrscraper/sdk 5.0.0 → 6.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +514 -178
- package/dist/api.d.ts +93 -106
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +251 -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.d.ts
DELETED
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import type { MrScraperResponse, ScrapeOptions } from "./api.js";
|
|
2
|
-
/** Shared page, browser, proxy, and retry controls. Output is selected by the function. */
|
|
3
|
-
export type ScraperOptions = ScrapeOptions;
|
|
4
|
-
export interface ScreenshotOptions extends Omit<ScraperOptions, "browser_rendering"> {
|
|
5
|
-
/** Defaults to true (screenshot=full); false captures the viewport. */
|
|
6
|
-
full_page?: boolean;
|
|
7
|
-
}
|
|
8
|
-
export interface ScraperJsonOptions extends ScraperOptions {
|
|
9
|
-
/** Defaults to "Extract all data as complete as possible." */
|
|
10
|
-
prompt?: string;
|
|
11
|
-
}
|
|
12
|
-
export interface ScraperMultiplePageOptions extends ScraperOptions {
|
|
13
|
-
/** Defaults to "Extract all entry data as complete as possible." */
|
|
14
|
-
prompt?: string;
|
|
15
|
-
/** Positive integer, defaults to 3. */
|
|
16
|
-
max_pages?: number;
|
|
17
|
-
}
|
|
18
|
-
export interface ScraperSitemapOptions extends ScraperOptions {
|
|
19
|
-
/** Nonnegative integer, defaults to 2. */
|
|
20
|
-
max_depth?: number;
|
|
21
|
-
/** Positive integer, defaults to 3. */
|
|
22
|
-
max_pages?: number;
|
|
23
|
-
/** Positive integer, defaults to 1000. */
|
|
24
|
-
limit?: number;
|
|
25
|
-
/** Pattern strings are forwarded unchanged; unset patterns are omitted. */
|
|
26
|
-
include_patterns?: string | null;
|
|
27
|
-
exclude_patterns?: string | null;
|
|
28
|
-
}
|
|
29
|
-
export type BrandBundle = "clean" | "full" | "none";
|
|
30
|
-
export type BrandOutput = "html" | "bundle" | "screenshot" | "screenshot_full";
|
|
31
|
-
export interface ScrapeBrandOptions extends ScraperOptions {
|
|
32
|
-
/** Defaults to clean. */
|
|
33
|
-
bundle?: BrandBundle;
|
|
34
|
-
}
|
|
35
|
-
export interface GetBrandOptions {
|
|
36
|
-
token?: string;
|
|
37
|
-
output?: BrandOutput | null;
|
|
38
|
-
/** HTTP timeout in seconds, defaults to 600. */
|
|
39
|
-
timeout?: number;
|
|
40
|
-
}
|
|
41
|
-
/** Fetch HTML. Only html=true is sent; other output flags are omitted. */
|
|
42
|
-
export declare function scraper_html<T = unknown>(url: string, options?: ScraperOptions): Promise<MrScraperResponse<T>>;
|
|
43
|
-
/** Fetch Markdown. Only markdown=true is sent; other output flags are omitted. */
|
|
44
|
-
export declare function scraper_markdown<T = unknown>(url: string, options?: ScraperOptions): Promise<MrScraperResponse<T>>;
|
|
45
|
-
/** Capture a screenshot using GET. Images are returned as Buffer in data. */
|
|
46
|
-
export declare function get_screenshot<T = unknown>(url: string, options?: ScreenshotOptions): Promise<MrScraperResponse<T>>;
|
|
47
|
-
/** Extract structured JSON with the general agent and html=true. */
|
|
48
|
-
export declare function scraper_json<T = unknown>(url: string, options?: ScraperJsonOptions): Promise<MrScraperResponse<T>>;
|
|
49
|
-
/** Extract entries across multiple pages using the listing agent. */
|
|
50
|
-
export declare function scraper_multiple_page<T = unknown>(url: string, options?: ScraperMultiplePageOptions): Promise<MrScraperResponse<T>>;
|
|
51
|
-
/** Discover URLs with the map agent; pattern strings are preserved unchanged. */
|
|
52
|
-
export declare function scraper_sitemap<T = unknown>(url: string, options?: ScraperSitemapOptions): Promise<MrScraperResponse<T>>;
|
|
53
|
-
/** Start a brand-scraping job; use the returned job ID with get_brand. */
|
|
54
|
-
export declare function scrape_brand<T = unknown>(url: string, options?: ScrapeBrandOptions): Promise<MrScraperResponse<T>>;
|
|
55
|
-
/** Read a brand job or download HTML, a ZIP bundle, or a screenshot. */
|
|
56
|
-
export declare function get_brand<T = unknown>(job_id: string, options?: GetBrandOptions): Promise<MrScraperResponse<T>>;
|
|
57
|
-
//# sourceMappingURL=internal.d.ts.map
|
package/dist/internal.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"internal.d.ts","sourceRoot":"","sources":["../src/internal.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,iBAAiB,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEjE,2FAA2F;AAC3F,MAAM,MAAM,cAAc,GAAG,aAAa,CAAC;AAE3C,MAAM,WAAW,iBAAkB,SAAQ,IAAI,CAAC,cAAc,EAAE,mBAAmB,CAAC;IAClF,uEAAuE;IACvE,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB;AAED,MAAM,WAAW,kBAAmB,SAAQ,cAAc;IACxD,8DAA8D;IAC9D,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,0BAA2B,SAAQ,cAAc;IAChE,oEAAoE;IACpE,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,qBAAsB,SAAQ,cAAc;IAC3D,0CAA0C;IAC1C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,uCAAuC;IACvC,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,2EAA2E;IAC3E,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IACjC,gBAAgB,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CAClC;AAED,MAAM,MAAM,WAAW,GAAG,OAAO,GAAG,MAAM,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eAAe,CAAC,CAAC,GAAG,OAAO,EAC/C,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,qBAA0B,GAC/C,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAM/B;AAED,0EAA0E;AAC1E,wBAAsB,YAAY,CAAC,CAAC,GAAG,OAAO,EAC5C,GAAG,EAAE,MAAM,EAAE,OAAO,GAAE,kBAAuB,GAC5C,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAE/B;AAED,wEAAwE;AACxE,wBAAsB,SAAS,CAAC,CAAC,GAAG,OAAO,EACzC,MAAM,EAAE,MAAM,EAAE,OAAO,GAAE,eAAoB,GAC5C,OAAO,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAC,CAY/B"}
|
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;QA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