@mrscraper/sdk 1.1.4 → 3.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 +104 -376
- package/dist/api.d.ts +45 -191
- package/dist/api.d.ts.map +1 -1
- package/dist/api.js +140 -225
- 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/mrscraper.jpeg +0 -0
- package/package.json +6 -7
package/dist/api.d.ts
CHANGED
|
@@ -1,200 +1,54 @@
|
|
|
1
|
+
/** An API, authentication, network, or timeout failure. */
|
|
1
2
|
export declare class MrScraperError extends Error {
|
|
2
|
-
/** HTTP status code, if the error came from the API. Undefined for network/timeout errors. */
|
|
3
3
|
readonly status: number | undefined;
|
|
4
4
|
constructor(message: string, status?: number);
|
|
5
5
|
}
|
|
6
|
-
export
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
/** The URL to fetch. */
|
|
11
|
-
url: string;
|
|
12
|
-
/** Request timeout in seconds (1–600). Defaults to 120. */
|
|
13
|
-
timeout?: number;
|
|
14
|
-
/** Two-letter ISO country code for geo-targeting. Defaults to "US". */
|
|
15
|
-
geoCode?: string;
|
|
16
|
-
/** Block images/fonts/css to speed up the request. Defaults to false. */
|
|
17
|
-
blockResources?: boolean;
|
|
18
|
-
/** Override the global MRSCRAPER_API_TOKEN for this call. */
|
|
19
|
-
token?: string;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Fetch the raw HTML (or JSON) of any URL through MrScraper's Fetch endpoint.
|
|
23
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
24
|
-
*/
|
|
25
|
-
export declare function fetchHtml<T = string>(options: FetchHtmlOptions): Promise<T>;
|
|
26
|
-
export interface CreateAiScraperOptions {
|
|
27
|
-
/** The starting URL to scrape. */
|
|
28
|
-
url: string;
|
|
29
|
-
/** Natural-language instructions for the AI (general/listing agents). */
|
|
30
|
-
message?: string;
|
|
31
|
-
/** Scraper agent type. Defaults to "general". */
|
|
32
|
-
agent?: ScraperAgent;
|
|
33
|
-
/** Two-letter proxy country code (general/listing agents). */
|
|
34
|
-
proxyCountry?: string | null;
|
|
35
|
-
/** Maximum crawl depth for map agent (0–5). Defaults to 2. */
|
|
36
|
-
maxDepth?: number;
|
|
37
|
-
/** Maximum pages for map agent (1–1000). Defaults to 50. */
|
|
38
|
-
maxPages?: number;
|
|
39
|
-
/** Maximum results for map agent (1–100000). Defaults to 1000. */
|
|
40
|
-
limit?: number;
|
|
41
|
-
/** URL patterns to include (map agent). */
|
|
42
|
-
includePatterns?: string;
|
|
43
|
-
/** URL patterns to exclude (map agent). */
|
|
44
|
-
excludePatterns?: string;
|
|
45
|
-
/** Override the global MRSCRAPER_API_TOKEN for this call. */
|
|
46
|
-
token?: string;
|
|
47
|
-
}
|
|
48
|
-
/**
|
|
49
|
-
* Create a new AI scraper (general, listing, or map).
|
|
50
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
51
|
-
*/
|
|
52
|
-
export declare function createAiScraper<T = unknown>(options: CreateAiScraperOptions): Promise<T>;
|
|
53
|
-
export interface RerunAiScraperOptions {
|
|
54
|
-
/** The ID of the AI scraper to rerun. */
|
|
55
|
-
scraperId: string;
|
|
56
|
-
/** New URL to scrape. */
|
|
57
|
-
url: string;
|
|
58
|
-
/** Maximum crawl depth (0–5). Defaults to 2. */
|
|
59
|
-
maxDepth?: number;
|
|
60
|
-
/** Maximum pages (1–1000). Defaults to 50. */
|
|
61
|
-
maxPages?: number;
|
|
62
|
-
/** Maximum results (1–100000). Defaults to 1000. */
|
|
63
|
-
limit?: number;
|
|
64
|
-
/** URL patterns to include. */
|
|
65
|
-
includePatterns?: string;
|
|
66
|
-
/** URL patterns to exclude. */
|
|
67
|
-
excludePatterns?: string;
|
|
68
|
-
/** Override the global MRSCRAPER_API_TOKEN for this call. */
|
|
69
|
-
token?: string;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* Rerun an existing AI scraper on a new URL.
|
|
73
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
74
|
-
*/
|
|
75
|
-
export declare function rerunAiScraper<T = unknown>(options: RerunAiScraperOptions): Promise<T>;
|
|
76
|
-
export interface BulkRerunAiScraperOptions {
|
|
77
|
-
/** The ID of the AI scraper to rerun. */
|
|
78
|
-
scraperId: string;
|
|
79
|
-
/** List of URLs to scrape. */
|
|
80
|
-
urls: string[];
|
|
81
|
-
/** Override the global MRSCRAPER_API_TOKEN for this call. */
|
|
82
|
-
token?: string;
|
|
83
|
-
}
|
|
84
|
-
/**
|
|
85
|
-
* Rerun an AI scraper on multiple URLs at once.
|
|
86
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
87
|
-
*/
|
|
88
|
-
export declare function bulkRerunAiScraper<T = unknown>(options: BulkRerunAiScraperOptions): Promise<T>;
|
|
89
|
-
/**
|
|
90
|
-
* **WARNING:** Scraping login-protected pages carries serious legal and compliance risks.
|
|
91
|
-
* Many websites explicitly prohibit automated access in their Terms of Service, and bypassing
|
|
92
|
-
* authentication to scrape content may expose you to legal action including lawsuits, account
|
|
93
|
-
* termination, and financial penalties. By proceeding on scraping login-protected pages, you
|
|
94
|
-
* confirm that you have read and understood the target website's Terms of Service, and you
|
|
95
|
-
* **fully accept all legal, financial, and ethical responsibility** for your actions.
|
|
96
|
-
*/
|
|
97
|
-
export interface RerunManualScraperOptions {
|
|
98
|
-
/** The ID of the manual scraper to rerun. */
|
|
99
|
-
scraperId: string;
|
|
100
|
-
/** URL to scrape. */
|
|
101
|
-
url: string;
|
|
102
|
-
/** Override the global MRSCRAPER_API_TOKEN for this call. */
|
|
103
|
-
token?: string;
|
|
104
|
-
}
|
|
105
|
-
/**
|
|
106
|
-
* **WARNING:** Scraping login-protected pages carries serious legal and compliance risks.
|
|
107
|
-
* Many websites explicitly prohibit automated access in their Terms of Service, and bypassing
|
|
108
|
-
* authentication to scrape content may expose you to legal action including lawsuits, account
|
|
109
|
-
* termination, and financial penalties. By proceeding on scraping login-protected pages, you
|
|
110
|
-
* confirm that you have read and understood the target website's Terms of Service, and you
|
|
111
|
-
* **fully accept all legal, financial, and ethical responsibility** for your actions.
|
|
112
|
-
*
|
|
113
|
-
* Rerun a manual (dashboard-configured) scraper on a URL.
|
|
114
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
115
|
-
*/
|
|
116
|
-
export declare function rerunManualScraper<T = unknown>(options: RerunManualScraperOptions): Promise<T>;
|
|
117
|
-
/**
|
|
118
|
-
* **WARNING:** Scraping login-protected pages carries serious legal and compliance risks.
|
|
119
|
-
* Many websites explicitly prohibit automated access in their Terms of Service, and bypassing
|
|
120
|
-
* authentication to scrape content may expose you to legal action including lawsuits, account
|
|
121
|
-
* termination, and financial penalties. By proceeding on scraping login-protected pages, you
|
|
122
|
-
* confirm that you have read and understood the target website's Terms of Service, and you
|
|
123
|
-
* **fully accept all legal, financial, and ethical responsibility** for your actions.
|
|
124
|
-
*/
|
|
125
|
-
export interface BulkRerunManualScraperOptions {
|
|
126
|
-
/** The ID of the manual scraper to rerun. */
|
|
127
|
-
scraperId: string;
|
|
128
|
-
/** List of URLs to scrape. */
|
|
129
|
-
urls: string[];
|
|
130
|
-
/** Override the global MRSCRAPER_API_TOKEN for this call. */
|
|
131
|
-
token?: string;
|
|
132
|
-
}
|
|
133
|
-
/**
|
|
134
|
-
* **WARNING:** Scraping login-protected pages carries serious legal and compliance risks.
|
|
135
|
-
* Many websites explicitly prohibit automated access in their Terms of Service, and bypassing
|
|
136
|
-
* authentication to scrape content may expose you to legal action including lawsuits, account
|
|
137
|
-
* termination, and financial penalties. By proceeding on scraping login-protected pages, you
|
|
138
|
-
* confirm that you have read and understood the target website's Terms of Service, and you
|
|
139
|
-
* **fully accept all legal, financial, and ethical responsibility** for your actions.
|
|
140
|
-
*
|
|
141
|
-
* Rerun a manual scraper on multiple URLs at once.
|
|
142
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
143
|
-
*/
|
|
144
|
-
export declare function bulkRerunManualScraper<T = unknown>(options: BulkRerunManualScraperOptions): Promise<T>;
|
|
145
|
-
export interface GetAllResultsOptions {
|
|
146
|
-
/** Field to sort by. Defaults to "updatedAt". */
|
|
147
|
-
sortField?: SortField;
|
|
148
|
-
/** Sort direction. Defaults to "DESC". */
|
|
149
|
-
sortOrder?: SortOrder;
|
|
150
|
-
/** Number of results per page (1–500). Defaults to 10. */
|
|
151
|
-
pageSize?: number;
|
|
152
|
-
/** Page number (1-based). Defaults to 1. */
|
|
153
|
-
page?: number;
|
|
154
|
-
/** Full-text search query. */
|
|
155
|
-
search?: string;
|
|
156
|
-
/** Column to use for date range filtering. */
|
|
157
|
-
dateRangeColumn?: string;
|
|
158
|
-
/** Start of date range (ISO 8601). */
|
|
159
|
-
startAt?: string;
|
|
160
|
-
/** End of date range (ISO 8601). */
|
|
161
|
-
endAt?: string;
|
|
162
|
-
/** Override the global MRSCRAPER_API_TOKEN for this call. */
|
|
163
|
-
token?: string;
|
|
6
|
+
export interface MrScraperResponse<T = unknown> {
|
|
7
|
+
status_code: number;
|
|
8
|
+
data: T;
|
|
9
|
+
headers: Record<string, string>;
|
|
164
10
|
}
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
168
|
-
*/
|
|
169
|
-
export declare function getAllResults<T = unknown>(options?: GetAllResultsOptions): Promise<T>;
|
|
170
|
-
export interface GetResultByIdOptions {
|
|
171
|
-
/** The ID of the result to fetch. */
|
|
172
|
-
resultId: string;
|
|
173
|
-
/** Override the global MRSCRAPER_API_TOKEN for this call. */
|
|
11
|
+
export interface ScraperApiOptions {
|
|
12
|
+
/** Overrides MRSCRAPER_API_TOKEN for this call. */
|
|
174
13
|
token?: string;
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
14
|
+
html?: boolean;
|
|
15
|
+
markdown?: boolean;
|
|
16
|
+
/** Page timeout in seconds, from 1 to 300. */
|
|
17
|
+
timeout?: number;
|
|
18
|
+
geo_code?: string;
|
|
19
|
+
proxy_country?: string | null;
|
|
20
|
+
block_resources?: boolean | null;
|
|
21
|
+
browser_rendering?: boolean | null;
|
|
22
|
+
super?: boolean;
|
|
23
|
+
use_proxy?: boolean;
|
|
24
|
+
proxy?: string | null;
|
|
25
|
+
wait_for_selector?: string | null;
|
|
26
|
+
home_page?: boolean;
|
|
27
|
+
screenshot?: boolean;
|
|
28
|
+
bypass_proxy?: boolean;
|
|
29
|
+
cookie_jar?: string | null;
|
|
30
|
+
/** Headers forwarded to the target site, not the API request. */
|
|
31
|
+
headers?: Record<string, string> | string | null;
|
|
32
|
+
max_retries?: number;
|
|
33
|
+
token_cap?: number | null;
|
|
34
|
+
stream?: boolean | null;
|
|
35
|
+
discard_token_secret?: string;
|
|
36
|
+
}
|
|
37
|
+
export interface WebSearchOptions {
|
|
38
|
+
/** Overrides MRSCRAPER_API_TOKEN for this call. */
|
|
39
|
+
token?: string;
|
|
40
|
+
/** Compatibility flag: true requests HTML even when format is "json". */
|
|
188
41
|
raw?: boolean;
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
42
|
+
region?: string | null;
|
|
43
|
+
language?: string | null;
|
|
44
|
+
page?: number | null;
|
|
45
|
+
format?: "json" | "html";
|
|
46
|
+
render_js?: boolean;
|
|
47
|
+
/** HTTP request timeout in seconds. */
|
|
48
|
+
timeout?: number;
|
|
193
49
|
}
|
|
194
|
-
/**
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
*/
|
|
199
|
-
export declare function googleSerp<T = unknown>(options: GoogleSerpOptions): Promise<T>;
|
|
50
|
+
/** Fetch a page through the MrScraper API. Options mirror the Python client's page-fetch options. */
|
|
51
|
+
export declare function scraper_api<T = unknown>(url: string, options?: ScraperApiOptions): Promise<MrScraperResponse<T>>;
|
|
52
|
+
/** Fetch Google search results. Accepts query text or a Google search URL. */
|
|
53
|
+
export declare function web_search<T = unknown>(url: string, options?: WebSearchOptions): Promise<MrScraperResponse<T>>;
|
|
200
54
|
//# sourceMappingURL=api.d.ts.map
|
package/dist/api.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,qBAAa,cAAe,SAAQ,KAAK;IACvC,QAAQ,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC;gBAExB,OAAO,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,MAAM;CAK7C;AAED,MAAM,WAAW,iBAAiB,CAAC,CAAC,GAAG,OAAO;IAC5C,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,CAAC,CAAC;IACR,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACjC;AAED,MAAM,WAAW,iBAAiB;IAChC,mDAAmD;IACnD,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8CAA8C;IAC9C,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAC9B,eAAe,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACjC,iBAAiB,CAAC,EAAE,OAAO,GAAG,IAAI,CAAC;IACnC,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,CAAC;IACpB,KAAK,CAAC,EAAE,MA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