mcp-scraper 0.42.2 → 0.43.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 +2 -2
- package/dist/bin/api-server.cjs +3285 -2121
- package/dist/bin/api-server.cjs.map +1 -1
- package/dist/bin/api-server.js +2 -2
- package/dist/bin/mcp-scraper-cli.cjs +1 -1
- package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
- package/dist/bin/mcp-scraper-cli.js +1 -1
- package/dist/bin/mcp-scraper-install.cjs +2 -2
- package/dist/bin/mcp-scraper-install.cjs.map +1 -1
- package/dist/bin/mcp-scraper-install.js +2 -2
- package/dist/bin/mcp-stdio-server.cjs +2170 -1510
- package/dist/bin/mcp-stdio-server.cjs.map +1 -1
- package/dist/bin/mcp-stdio-server.js +51 -23
- package/dist/bin/mcp-stdio-server.js.map +1 -1
- package/dist/bin/paa-harvest.cjs +21 -21
- package/dist/bin/paa-harvest.cjs.map +1 -1
- package/dist/bin/paa-harvest.js +1 -1
- package/dist/{chunk-MJKVDLVR.js → chunk-2K74LVV7.js} +26 -2
- package/dist/{chunk-MJKVDLVR.js.map → chunk-2K74LVV7.js.map} +1 -1
- package/dist/chunk-3CQZ3DAT.js +7 -0
- package/dist/chunk-3CQZ3DAT.js.map +1 -0
- package/dist/{chunk-6Q7V4IQV.js → chunk-6WLNXYRG.js} +19 -2
- package/dist/chunk-6WLNXYRG.js.map +1 -0
- package/dist/{chunk-4MFUKI4X.js → chunk-GUI33Q27.js} +2 -2
- package/dist/{chunk-N2B4AAWG.js → chunk-HO4DOPEG.js} +2194 -1569
- package/dist/chunk-HO4DOPEG.js.map +1 -0
- package/dist/{chunk-DH42LIR3.js → chunk-LXVIQZ7Y.js} +22 -12
- package/dist/chunk-LXVIQZ7Y.js.map +1 -0
- package/dist/{chunk-ENJQ2NSX.js → chunk-TC4GDB2Q.js} +2 -2
- package/dist/{chunk-ENJQ2NSX.js.map → chunk-TC4GDB2Q.js.map} +1 -1
- package/dist/{chunk-SBLGBZZB.js → chunk-X5WDJ7D7.js} +9 -9
- package/dist/chunk-X5WDJ7D7.js.map +1 -0
- package/dist/{extract-bundle-DMZ63HZU.js → extract-bundle-IOM45SFL.js} +5 -5
- package/dist/index.cjs +21 -21
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +21 -57
- package/dist/index.d.ts +21 -57
- package/dist/index.js +1 -1
- package/dist/{server-2S7KQTPC.js → server-WAB6Z47N.js} +798 -333
- package/dist/server-WAB6Z47N.js.map +1 -0
- package/dist/{site-extract-repository-B42SIGAZ.js → site-extract-repository-XNI4ZK2M.js} +3 -3
- package/dist/{worker-4R3UWQZS.js → worker-E6MIVF33.js} +3 -3
- package/package.json +10 -7
- package/dist/chunk-6Q7V4IQV.js.map +0 -1
- package/dist/chunk-DH42LIR3.js.map +0 -1
- package/dist/chunk-N2B4AAWG.js.map +0 -1
- package/dist/chunk-SBLGBZZB.js.map +0 -1
- package/dist/chunk-UQ7XJINF.js +0 -7
- package/dist/chunk-UQ7XJINF.js.map +0 -1
- package/dist/server-2S7KQTPC.js.map +0 -1
- /package/dist/{chunk-4MFUKI4X.js.map → chunk-GUI33Q27.js.map} +0 -0
- /package/dist/{extract-bundle-DMZ63HZU.js.map → extract-bundle-IOM45SFL.js.map} +0 -0
- /package/dist/{site-extract-repository-B42SIGAZ.js.map → site-extract-repository-XNI4ZK2M.js.map} +0 -0
- /package/dist/{worker-4R3UWQZS.js.map → worker-E6MIVF33.js.map} +0 -0
|
@@ -170,11 +170,21 @@ async function ensureKernelProfile(kernelClient, name) {
|
|
|
170
170
|
if (!isKernelProfileConflict(err)) throw err;
|
|
171
171
|
}
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
async function detectRuntimeUserAgent(browser) {
|
|
174
|
+
try {
|
|
175
|
+
const page = browser.contexts()[0]?.pages()[0];
|
|
176
|
+
if (!page) return null;
|
|
177
|
+
const ua = await page.evaluate(() => navigator.userAgent);
|
|
178
|
+
return typeof ua === "string" && /Chrome\/\d+/.test(ua) ? ua : null;
|
|
179
|
+
} catch {
|
|
180
|
+
return null;
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
function rankCheckContextOptions(config, runtimeUserAgent) {
|
|
174
184
|
return {
|
|
175
185
|
viewport: config.viewport,
|
|
176
186
|
locale: config.locale,
|
|
177
|
-
userAgent: config.userAgent ?? (config.isMobile ? MOBILE_USER_AGENT : DESKTOP_USER_AGENT),
|
|
187
|
+
userAgent: config.userAgent ?? (config.isMobile ? MOBILE_USER_AGENT : runtimeUserAgent ?? DESKTOP_USER_AGENT),
|
|
178
188
|
...config.deviceScaleFactor ? { deviceScaleFactor: config.deviceScaleFactor } : {},
|
|
179
189
|
...config.isMobile !== void 0 ? { isMobile: config.isMobile } : {},
|
|
180
190
|
...config.hasTouch !== void 0 ? { hasTouch: config.hasTouch } : {}
|
|
@@ -271,7 +281,7 @@ var BrowserDriver = class {
|
|
|
271
281
|
this.kernelHeadlessSent = useHeadless ? true : null;
|
|
272
282
|
if (costCtx?.headlessSentOut) costCtx.headlessSentOut.value = this.kernelHeadlessSent;
|
|
273
283
|
const kernelBrowser = await this.kernelClient.browsers.create({
|
|
274
|
-
stealth: true,
|
|
284
|
+
stealth: config.kernelStealth === true,
|
|
275
285
|
timeout_seconds: timeoutSeconds,
|
|
276
286
|
...useHeadless ? { headless: true } : {},
|
|
277
287
|
...config.kernelProxyId ? { proxy_id: config.kernelProxyId } : {},
|
|
@@ -336,7 +346,9 @@ var BrowserDriver = class {
|
|
|
336
346
|
await this.populateKernelRetrieveDebug(kernelDebug, config.kernelProxyId);
|
|
337
347
|
}
|
|
338
348
|
this.browser = await playwrightChromium.connectOverCDP(kernelBrowser.cdp_ws_url);
|
|
339
|
-
|
|
349
|
+
const runtimeUserAgent = await detectRuntimeUserAgent(this.browser);
|
|
350
|
+
this.debugSnapshot.context.userAgent = config.userAgent ?? (config.isMobile ? MOBILE_USER_AGENT : runtimeUserAgent ?? DESKTOP_USER_AGENT);
|
|
351
|
+
this.context = await this.browser.newContext(rankCheckContextOptions(config, runtimeUserAgent));
|
|
340
352
|
await this.installEsbuildHelperShims(this.context);
|
|
341
353
|
this.page = await this.context.newPage();
|
|
342
354
|
await this.page.setViewportSize(config.viewport);
|
|
@@ -3185,7 +3197,7 @@ async function harvest(rawOptions) {
|
|
|
3185
3197
|
const needsLocationEvidence = proxyMode === "location" && Boolean(proxyOpts.location);
|
|
3186
3198
|
const requestedMaxAttempts = raw.maxAttempts;
|
|
3187
3199
|
const baseMaxAttempts = typeof requestedMaxAttempts === "number" && Number.isInteger(requestedMaxAttempts) && requestedMaxAttempts >= 1 ? requestedMaxAttempts : maxAttemptsForProxyMode(proxyMode) + 1;
|
|
3188
|
-
const maxAttempts = baseMaxAttempts
|
|
3200
|
+
const maxAttempts = baseMaxAttempts;
|
|
3189
3201
|
const softDeadlineMs = typeof raw.softDeadlineMs === "number" ? raw.softDeadlineMs : null;
|
|
3190
3202
|
const serializer = new OutputSerializer();
|
|
3191
3203
|
let lastError = null;
|
|
@@ -3196,14 +3208,11 @@ async function harvest(rawOptions) {
|
|
|
3196
3208
|
const startedAtMs = Date.now();
|
|
3197
3209
|
try {
|
|
3198
3210
|
if (signal?.aborted) throw abortReason(signal);
|
|
3199
|
-
const
|
|
3200
|
-
if (isBackupAttempt && softDeadlineMs !== null && Date.now() >= softDeadlineMs) break;
|
|
3201
|
-
const resolution2 = isBackupAttempt ? await resolveBackupKernelProxyId({ kernelApiKey, proxyMode: effectiveProxyMode, attemptIndex: i }) : await resolveKernelProxyId({
|
|
3211
|
+
const resolution2 = await resolveKernelProxyId({
|
|
3202
3212
|
...proxyOpts,
|
|
3203
3213
|
proxyMode: effectiveProxyMode,
|
|
3204
3214
|
attemptIndex: i,
|
|
3205
|
-
fresh: effectiveProxyMode === "location"
|
|
3206
|
-
backupOnExhaustion: true
|
|
3215
|
+
fresh: effectiveProxyMode === "location"
|
|
3207
3216
|
});
|
|
3208
3217
|
if (!resolution2) break;
|
|
3209
3218
|
const mergedAttempt = {
|
|
@@ -3212,9 +3221,10 @@ async function harvest(rawOptions) {
|
|
|
3212
3221
|
kernelProxyId: resolution2.kernelProxyId,
|
|
3213
3222
|
kernelProxyResolution: resolution2.resolution,
|
|
3214
3223
|
proxyMode: effectiveProxyMode,
|
|
3224
|
+
keepDefaultProxy: i > 0,
|
|
3215
3225
|
debug: requestedDebug || needsLocationEvidence
|
|
3216
3226
|
};
|
|
3217
|
-
if (effectiveProxyMode === "none"
|
|
3227
|
+
if (effectiveProxyMode === "none") mergedAttempt.kernelProxyId = void 0;
|
|
3218
3228
|
const attemptOptions = HarvestOptionsSchema.parse(mergedAttempt);
|
|
3219
3229
|
await emitAttemptEvent(onAttemptEvent, {
|
|
3220
3230
|
type: "started",
|
|
@@ -3439,4 +3449,4 @@ export {
|
|
|
3439
3449
|
resolveKernelProxyId,
|
|
3440
3450
|
harvest
|
|
3441
3451
|
};
|
|
3442
|
-
//# sourceMappingURL=chunk-
|
|
3452
|
+
//# sourceMappingURL=chunk-LXVIQZ7Y.js.map
|