@mrscraper/sdk 1.1.3 → 2.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 +86 -382
- package/dist/api.d.ts +43 -189
- 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 +7 -7
package/dist/api.js
CHANGED
|
@@ -1,9 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
// ---------------------------------------------------------------------------
|
|
3
|
-
// Error class
|
|
4
|
-
// ---------------------------------------------------------------------------
|
|
1
|
+
/** An API, authentication, network, or timeout failure. */
|
|
5
2
|
export class MrScraperError extends Error {
|
|
6
|
-
/** HTTP status code, if the error came from the API. Undefined for network/timeout errors. */
|
|
7
3
|
status;
|
|
8
4
|
constructor(message, status) {
|
|
9
5
|
super(message);
|
|
@@ -11,243 +7,162 @@ export class MrScraperError extends Error {
|
|
|
11
7
|
this.status = status;
|
|
12
8
|
}
|
|
13
9
|
}
|
|
14
|
-
// ---------------------------------------------------------------------------
|
|
15
|
-
// Internal helpers
|
|
16
|
-
// ---------------------------------------------------------------------------
|
|
17
10
|
function requireToken(explicitToken) {
|
|
18
|
-
const token = explicitToken
|
|
19
|
-
if (!token) {
|
|
20
|
-
throw new MrScraperError("
|
|
11
|
+
const token = explicitToken || process.env.MRSCRAPER_API_TOKEN || "";
|
|
12
|
+
if (!token.trim()) {
|
|
13
|
+
throw new MrScraperError("API token is not set. Pass token in the options or set MRSCRAPER_API_TOKEN. Get your token at https://app.mrscraper.com.");
|
|
21
14
|
}
|
|
22
15
|
return token;
|
|
23
16
|
}
|
|
24
|
-
|
|
17
|
+
function authHeaders(token) {
|
|
18
|
+
return {
|
|
19
|
+
"Content-Type": "application/json",
|
|
20
|
+
accept: "application/json",
|
|
21
|
+
Authorization: `Bearer ${token}`,
|
|
22
|
+
"x-api-token": token,
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
function setIfPresent(params, key, value) {
|
|
26
|
+
if (value !== null && value !== undefined) {
|
|
27
|
+
params.set(key, typeof value === "boolean" ? String(value) : String(value));
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
async function post(url, body, headers, timeoutSeconds, token) {
|
|
25
31
|
const controller = new AbortController();
|
|
26
|
-
const
|
|
32
|
+
const timer = setTimeout(() => controller.abort(), timeoutSeconds * 1000);
|
|
27
33
|
try {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
:
|
|
33
|
-
|
|
34
|
-
|
|
34
|
+
const response = await fetch(url, {
|
|
35
|
+
method: "POST",
|
|
36
|
+
headers,
|
|
37
|
+
body: JSON.stringify(body),
|
|
38
|
+
signal: controller.signal,
|
|
39
|
+
});
|
|
40
|
+
if (response.status === 401) {
|
|
41
|
+
throw new MrScraperError("Unauthorized or invalid token. Please go to https://app.mrscraper.com to get your token.", 401);
|
|
35
42
|
}
|
|
36
|
-
|
|
43
|
+
const contentType = response.headers.get("content-type")?.toLowerCase() ?? "";
|
|
44
|
+
const data = contentType.includes("application/json")
|
|
45
|
+
? await response.json()
|
|
46
|
+
: await response.text();
|
|
47
|
+
if (!response.ok) {
|
|
37
48
|
const message = typeof data === "string" ? data : JSON.stringify(data);
|
|
38
|
-
throw new MrScraperError(message,
|
|
49
|
+
throw new MrScraperError(message.replaceAll(token, "[REDACTED]"), response.status);
|
|
39
50
|
}
|
|
40
|
-
return
|
|
51
|
+
return {
|
|
52
|
+
status_code: response.status,
|
|
53
|
+
data: data,
|
|
54
|
+
headers: Object.fromEntries(response.headers.entries()),
|
|
55
|
+
};
|
|
41
56
|
}
|
|
42
|
-
catch (
|
|
43
|
-
if (
|
|
44
|
-
throw
|
|
45
|
-
|
|
57
|
+
catch (error) {
|
|
58
|
+
if (error instanceof MrScraperError)
|
|
59
|
+
throw error;
|
|
60
|
+
const message = error instanceof Error ? error.message : String(error);
|
|
61
|
+
throw new MrScraperError(message.replaceAll(token, "[REDACTED]"));
|
|
46
62
|
}
|
|
47
63
|
finally {
|
|
48
|
-
clearTimeout(
|
|
64
|
+
clearTimeout(timer);
|
|
49
65
|
}
|
|
50
66
|
}
|
|
51
|
-
/**
|
|
52
|
-
|
|
53
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
54
|
-
*/
|
|
55
|
-
export async function fetchHtml(options) {
|
|
56
|
-
const token = requireToken(options.token);
|
|
57
|
-
const timeoutSecs = options.timeout ?? 120;
|
|
58
|
-
const params = new URLSearchParams({
|
|
59
|
-
token,
|
|
60
|
-
timeout: String(timeoutSecs),
|
|
61
|
-
geoCode: options.geoCode ?? "US",
|
|
62
|
-
url: options.url,
|
|
63
|
-
blockResources: String(!!options.blockResources),
|
|
64
|
-
});
|
|
65
|
-
const base = new URL("https://api.mrscraper.com/");
|
|
66
|
-
base.search = params.toString();
|
|
67
|
-
return request(base.toString(), {}, (timeoutSecs + 30) * 1000);
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Create a new AI scraper (general, listing, or map).
|
|
71
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
72
|
-
*/
|
|
73
|
-
export async function createAiScraper(options) {
|
|
74
|
-
const token = requireToken(options.token);
|
|
75
|
-
const agent = options.agent ?? "general";
|
|
76
|
-
const body = agent === "map"
|
|
77
|
-
? {
|
|
78
|
-
url: options.url,
|
|
79
|
-
agent,
|
|
80
|
-
maxDepth: options.maxDepth ?? 2,
|
|
81
|
-
maxPages: options.maxPages ?? 50,
|
|
82
|
-
limit: options.limit ?? 1000,
|
|
83
|
-
includePatterns: options.includePatterns ?? "",
|
|
84
|
-
excludePatterns: options.excludePatterns ?? "",
|
|
85
|
-
}
|
|
86
|
-
: {
|
|
87
|
-
url: options.url,
|
|
88
|
-
message: options.message ?? "",
|
|
89
|
-
agent,
|
|
90
|
-
proxyCountry: options.proxyCountry ?? null,
|
|
91
|
-
};
|
|
92
|
-
return request("https://api.app.mrscraper.com/api/v1/scrapers-ai", {
|
|
93
|
-
method: "POST",
|
|
94
|
-
headers: {
|
|
95
|
-
"content-type": "application/json",
|
|
96
|
-
accept: "application/json",
|
|
97
|
-
"x-api-token": token,
|
|
98
|
-
},
|
|
99
|
-
body: JSON.stringify(body),
|
|
100
|
-
}, 600_000);
|
|
101
|
-
}
|
|
102
|
-
/**
|
|
103
|
-
* Rerun an existing AI scraper on a new URL.
|
|
104
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
105
|
-
*/
|
|
106
|
-
export async function rerunAiScraper(options) {
|
|
107
|
-
const token = requireToken(options.token);
|
|
108
|
-
return request("https://api.app.mrscraper.com/api/v1/scrapers-ai-rerun", {
|
|
109
|
-
method: "POST",
|
|
110
|
-
headers: {
|
|
111
|
-
"content-type": "application/json",
|
|
112
|
-
accept: "application/json",
|
|
113
|
-
"x-api-token": token,
|
|
114
|
-
},
|
|
115
|
-
body: JSON.stringify({
|
|
116
|
-
scraperId: options.scraperId,
|
|
117
|
-
url: options.url,
|
|
118
|
-
maxDepth: options.maxDepth ?? 2,
|
|
119
|
-
maxPages: options.maxPages ?? 50,
|
|
120
|
-
limit: options.limit ?? 1000,
|
|
121
|
-
includePatterns: options.includePatterns ?? "",
|
|
122
|
-
excludePatterns: options.excludePatterns ?? "",
|
|
123
|
-
}),
|
|
124
|
-
}, 600_000);
|
|
125
|
-
}
|
|
126
|
-
/**
|
|
127
|
-
* Rerun an AI scraper on multiple URLs at once.
|
|
128
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
129
|
-
*/
|
|
130
|
-
export async function bulkRerunAiScraper(options) {
|
|
131
|
-
const token = requireToken(options.token);
|
|
132
|
-
return request("https://api.app.mrscraper.com/api/v1/scrapers-ai-rerun/bulk", {
|
|
133
|
-
method: "POST",
|
|
134
|
-
headers: {
|
|
135
|
-
"content-type": "application/json",
|
|
136
|
-
accept: "application/json",
|
|
137
|
-
"x-api-token": token,
|
|
138
|
-
},
|
|
139
|
-
body: JSON.stringify({ scraperId: options.scraperId, urls: options.urls }),
|
|
140
|
-
}, 600_000);
|
|
141
|
-
}
|
|
142
|
-
/**
|
|
143
|
-
* **WARNING:** Scraping login-protected pages carries serious legal and compliance risks.
|
|
144
|
-
* Many websites explicitly prohibit automated access in their Terms of Service, and bypassing
|
|
145
|
-
* authentication to scrape content may expose you to legal action including lawsuits, account
|
|
146
|
-
* termination, and financial penalties. By proceeding on scraping login-protected pages, you
|
|
147
|
-
* confirm that you have read and understood the target website's Terms of Service, and you
|
|
148
|
-
* **fully accept all legal, financial, and ethical responsibility** for your actions.
|
|
149
|
-
*
|
|
150
|
-
* Rerun a manual (dashboard-configured) scraper on a URL.
|
|
151
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
152
|
-
*/
|
|
153
|
-
export async function rerunManualScraper(options) {
|
|
67
|
+
/** Fetch a page through the MrScraper API. Options mirror Python's fetch_content. */
|
|
68
|
+
export async function fetch_content(url, options = {}) {
|
|
154
69
|
const token = requireToken(options.token);
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
params.set("search", options.search);
|
|
202
|
-
if (options.dateRangeColumn)
|
|
203
|
-
params.set("dateRangeColumn", options.dateRangeColumn);
|
|
204
|
-
if (options.startAt)
|
|
205
|
-
params.set("startAt", options.startAt);
|
|
206
|
-
if (options.endAt)
|
|
207
|
-
params.set("endAt", options.endAt);
|
|
208
|
-
const url = `https://api.app.mrscraper.com/api/v1/results?${params.toString()}`;
|
|
209
|
-
return request(url, {
|
|
210
|
-
method: "GET",
|
|
211
|
-
headers: {
|
|
212
|
-
accept: "application/json",
|
|
213
|
-
"x-api-token": token,
|
|
214
|
-
},
|
|
215
|
-
}, 600_000);
|
|
70
|
+
const timeout = options.timeout ?? 120;
|
|
71
|
+
const maxRetries = options.max_retries ?? 3;
|
|
72
|
+
if (!Number.isFinite(timeout) || timeout < 1 || timeout > 300) {
|
|
73
|
+
throw new RangeError("timeout must be between 1 and 300 seconds");
|
|
74
|
+
}
|
|
75
|
+
if (!Number.isInteger(maxRetries) || maxRetries < 0) {
|
|
76
|
+
throw new RangeError("max_retries must be greater than or equal to 0");
|
|
77
|
+
}
|
|
78
|
+
if (options.token_cap != null && (!Number.isInteger(options.token_cap) || options.token_cap < 0)) {
|
|
79
|
+
throw new RangeError("token_cap must be greater than or equal to 0");
|
|
80
|
+
}
|
|
81
|
+
if (options.screenshot !== undefined && typeof options.screenshot !== "boolean") {
|
|
82
|
+
throw new TypeError("screenshot must be a boolean");
|
|
83
|
+
}
|
|
84
|
+
if (options.super !== undefined && typeof options.super !== "boolean") {
|
|
85
|
+
throw new TypeError("super must be a boolean");
|
|
86
|
+
}
|
|
87
|
+
const params = new URLSearchParams();
|
|
88
|
+
setIfPresent(params, "token", token);
|
|
89
|
+
setIfPresent(params, "timeout", timeout);
|
|
90
|
+
setIfPresent(params, "geoCode", options.geo_code ?? "US");
|
|
91
|
+
setIfPresent(params, "proxyCountry", options.proxy_country);
|
|
92
|
+
setIfPresent(params, "browserRendering", options.screenshot ? true : options.browser_rendering);
|
|
93
|
+
setIfPresent(params, "super", options.super ? true : null);
|
|
94
|
+
setIfPresent(params, "useProxy", options.use_proxy === false ? false : null);
|
|
95
|
+
setIfPresent(params, "proxy", options.proxy);
|
|
96
|
+
setIfPresent(params, "html", options.html ?? true);
|
|
97
|
+
setIfPresent(params, "markdown", options.markdown ?? false);
|
|
98
|
+
setIfPresent(params, "waitForSelector", options.wait_for_selector);
|
|
99
|
+
setIfPresent(params, "warmStart", options.home_page ? true : null);
|
|
100
|
+
setIfPresent(params, "screenshot", options.screenshot ? true : null);
|
|
101
|
+
setIfPresent(params, "blockResources", options.block_resources ? true : null);
|
|
102
|
+
setIfPresent(params, "bypassProxy", options.bypass_proxy ? true : null);
|
|
103
|
+
setIfPresent(params, "cookieJar", options.cookie_jar);
|
|
104
|
+
setIfPresent(params, "headers", typeof options.headers === "object" && options.headers !== null
|
|
105
|
+
? JSON.stringify(options.headers)
|
|
106
|
+
: options.headers);
|
|
107
|
+
setIfPresent(params, "stream", options.stream);
|
|
108
|
+
const headers = authHeaders(token);
|
|
109
|
+
if (options.discard_token_secret) {
|
|
110
|
+
headers["x-discard-token-secret"] = options.discard_token_secret;
|
|
111
|
+
}
|
|
112
|
+
const body = { url, maxRetries };
|
|
113
|
+
if (options.token_cap != null)
|
|
114
|
+
body.tokenCap = options.token_cap;
|
|
115
|
+
return post(`https://api.mrscraper.com/?${params}`, body, headers, timeout + 30, token);
|
|
216
116
|
}
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
117
|
+
function normalizeSerpInput(input) {
|
|
118
|
+
const value = input.trim();
|
|
119
|
+
if (!value)
|
|
120
|
+
throw new TypeError("A Google search query or URL is required");
|
|
121
|
+
if (!/^https?:\/\//i.test(value)) {
|
|
122
|
+
return { query: value, region: null, language: null, page: null };
|
|
123
|
+
}
|
|
124
|
+
const parsed = new URL(value);
|
|
125
|
+
const query = (parsed.searchParams.get("q") ?? "").trim();
|
|
126
|
+
if (!query)
|
|
127
|
+
throw new TypeError("Google search URL must contain a q parameter");
|
|
128
|
+
const startValue = (parsed.searchParams.get("start") ?? "0").trim();
|
|
129
|
+
const start = /^[+-]?\d+$/.test(startValue) ? Number(startValue) : 0;
|
|
130
|
+
return {
|
|
131
|
+
query,
|
|
132
|
+
region: parsed.searchParams.get("gl"),
|
|
133
|
+
language: parsed.searchParams.get("hl"),
|
|
134
|
+
page: start > 0 ? Math.floor(start / 10) + 1 : null,
|
|
135
|
+
};
|
|
231
136
|
}
|
|
232
|
-
/**
|
|
233
|
-
|
|
234
|
-
* Uses Bearer authentication on the sync scraper host.
|
|
235
|
-
* Throws {@link MrScraperError} on API or network errors.
|
|
236
|
-
*/
|
|
237
|
-
export async function googleSerp(options) {
|
|
137
|
+
/** Fetch Google search results. Accepts query text or a Google search URL. */
|
|
138
|
+
export async function google_serp(url, options = {}) {
|
|
238
139
|
const token = requireToken(options.token);
|
|
239
|
-
const
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
140
|
+
const format = options.format ?? "json";
|
|
141
|
+
if (format !== "json" && format !== "html") {
|
|
142
|
+
throw new TypeError("format must be 'json' or 'html'");
|
|
143
|
+
}
|
|
144
|
+
if (options.page != null && (!Number.isInteger(options.page) || options.page < 1)) {
|
|
145
|
+
throw new RangeError("page must be a positive integer");
|
|
146
|
+
}
|
|
147
|
+
const timeout = options.timeout ?? 600;
|
|
148
|
+
if (!Number.isFinite(timeout) || timeout <= 0) {
|
|
149
|
+
throw new RangeError("timeout must be greater than 0 seconds");
|
|
150
|
+
}
|
|
151
|
+
const normalized = normalizeSerpInput(url);
|
|
152
|
+
const body = {
|
|
153
|
+
query: normalized.query,
|
|
154
|
+
format: (options.raw ?? true) ? "html" : format,
|
|
155
|
+
renderJs: Boolean(options.render_js ?? false),
|
|
156
|
+
};
|
|
157
|
+
const region = options.region || normalized.region;
|
|
158
|
+
const language = options.language || normalized.language;
|
|
159
|
+
const page = options.page || normalized.page;
|
|
160
|
+
if (region != null)
|
|
161
|
+
body.region = region;
|
|
162
|
+
if (language != null)
|
|
163
|
+
body.language = language;
|
|
164
|
+
if (page != null)
|
|
165
|
+
body.page = page;
|
|
166
|
+
return post("https://sync.scraper.mrscraper.com/api/google/serp/v2/sync", body, authHeaders(token), timeout, token);
|
|
252
167
|
}
|
|
253
168
|
//# sourceMappingURL=api.js.map
|
package/dist/api.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../src/api.ts"],"names":[],"mappings":"AAAA,2DAA2D;AAC3D,MAAM,OAAO,cAAe,SAAQ,KAAK;IAC9B,MAAM,CAAqB;IAEpC,YAAY,OAAe,EAAE,MAAe;QAC1C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,gBAAgB,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAiDD,SAAS,YAAY,CAAC,aAAsB;IAC1C,MAAM,KAAK,GAAG,aAAa,IAAI,OAAO,CAAC,GAAG,CAAC,mBAAmB,IAAI,EAAE,CAAC;IACrE,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,CAAC;QAClB,MAAM,IAAI,cAAc,CACtB,0HAA0H,CAC3H,CAAC;IACJ,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC;AAED,SAAS,WAAW,CAAC,KAAa;IAChC,OAAO;QACL,cAAc,EAAE,kBAAkB;QAClC,MAAM,EA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serp } from "./api.js";
|
|
2
|
+
export type { FetchContentOptions, GoogleSerpOptions, MrScraperResponse } from "./api.js";
|
|
3
3
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACtE,YAAY,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
export { MrScraperError,
|
|
1
|
+
export { MrScraperError, fetch_content, google_serp } from "./api.js";
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC"}
|
package/mrscraper.jpeg
ADDED
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mrscraper/sdk",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "Official Node.js SDK for
|
|
3
|
+
"version": "2.0.0",
|
|
4
|
+
"description": "Official Node.js SDK for MrScraper content fetching and Google SERP.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -15,18 +15,18 @@
|
|
|
15
15
|
"files": [
|
|
16
16
|
"dist",
|
|
17
17
|
"README.md",
|
|
18
|
-
"LICENSE"
|
|
18
|
+
"LICENSE",
|
|
19
|
+
"mrscraper.jpeg"
|
|
19
20
|
],
|
|
20
21
|
"scripts": {
|
|
21
22
|
"build": "tsc -p tsconfig.json",
|
|
22
23
|
"clean": "rm -rf dist",
|
|
23
24
|
"prepublishOnly": "npm run clean && npm run build",
|
|
24
|
-
"test
|
|
25
|
+
"test": "npm run build && node --test tests/*.test.mjs",
|
|
26
|
+
"test:manual": "npm run build && node file.js"
|
|
25
27
|
},
|
|
26
28
|
"devDependencies": {
|
|
27
29
|
"@types/node": "^25.3.3",
|
|
28
|
-
"dotenv": "^17.3.1",
|
|
29
|
-
"tsx": "^4.19.4",
|
|
30
30
|
"typescript": "^5.6.0"
|
|
31
31
|
},
|
|
32
32
|
"engines": {
|
|
@@ -42,7 +42,7 @@
|
|
|
42
42
|
],
|
|
43
43
|
"repository": {
|
|
44
44
|
"type": "git",
|
|
45
|
-
"url": "https://github.com/mrscraper-com/sdk-node.git"
|
|
45
|
+
"url": "git+https://github.com/mrscraper-com/sdk-node.git"
|
|
46
46
|
},
|
|
47
47
|
"homepage": "https://mrscraper.com"
|
|
48
48
|
}
|