mcp-scraper 0.42.3 → 0.43.2
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 +3284 -2130
- 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 +3 -4
- package/dist/bin/mcp-scraper-cli.js.map +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 +3361 -2817
- package/dist/bin/mcp-stdio-server.cjs.map +1 -1
- package/dist/bin/mcp-stdio-server.js +51 -24
- 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 +2 -3
- package/dist/bin/paa-harvest.js.map +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-CB5C3BPB.js → chunk-3ZUBQQPQ.js} +23 -2
- package/dist/chunk-3ZUBQQPQ.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-G5MHJGKE.js → chunk-GUI33Q27.js} +2 -2
- package/dist/{chunk-DH42LIR3.js → chunk-H7LQ6PTI.js} +24 -16
- package/dist/chunk-H7LQ6PTI.js.map +1 -0
- package/dist/chunk-MD75M2L5.js +7 -0
- package/dist/chunk-MD75M2L5.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-IMUA3FJB.js → chunk-X5WDJ7D7.js} +6 -6
- package/dist/chunk-X5WDJ7D7.js.map +1 -0
- package/dist/{chunk-QKCDYMFT.js → chunk-YJNGNMDO.js} +2196 -1584
- package/dist/chunk-YJNGNMDO.js.map +1 -0
- package/dist/{chunk-FQI5PFE7.js → chunk-ZSJHRZY5.js} +3 -5
- package/dist/{chunk-FQI5PFE7.js.map → chunk-ZSJHRZY5.js.map} +1 -1
- package/dist/{extract-bundle-FH734F3R.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 +2 -3
- package/dist/index.js.map +1 -1
- package/dist/{server-B27DR4YB.js → server-BPEXEKA6.js} +800 -336
- package/dist/server-BPEXEKA6.js.map +1 -0
- package/dist/{site-extract-repository-5CVI3OWT.js → site-extract-repository-XNI4ZK2M.js} +3 -3
- package/dist/{worker-MQJOY4YP.js → worker-2LIOH744.js} +4 -5
- package/dist/{worker-MQJOY4YP.js.map → worker-2LIOH744.js.map} +1 -1
- package/package.json +10 -7
- package/dist/chunk-2YFTFT3V.js +0 -7
- package/dist/chunk-2YFTFT3V.js.map +0 -1
- package/dist/chunk-6Q7V4IQV.js.map +0 -1
- package/dist/chunk-CB5C3BPB.js.map +0 -1
- package/dist/chunk-DH42LIR3.js.map +0 -1
- package/dist/chunk-IMUA3FJB.js.map +0 -1
- package/dist/chunk-K443GQY5.js +0 -24
- package/dist/chunk-K443GQY5.js.map +0 -1
- package/dist/chunk-QKCDYMFT.js.map +0 -1
- package/dist/server-B27DR4YB.js.map +0 -1
- /package/dist/{chunk-G5MHJGKE.js.map → chunk-GUI33Q27.js.map} +0 -0
- /package/dist/{extract-bundle-FH734F3R.js.map → extract-bundle-IOM45SFL.js.map} +0 -0
- /package/dist/{site-extract-repository-5CVI3OWT.js.map → site-extract-repository-XNI4ZK2M.js.map} +0 -0
|
@@ -6,15 +6,13 @@ import {
|
|
|
6
6
|
recordKernelSession,
|
|
7
7
|
runWithCostContext
|
|
8
8
|
} from "./chunk-DAS7L4SF.js";
|
|
9
|
-
import {
|
|
10
|
-
postToMemoryLibrary
|
|
11
|
-
} from "./chunk-K443GQY5.js";
|
|
12
9
|
import {
|
|
13
10
|
DEFAULT_PROXY_MODE,
|
|
14
11
|
HarvestOptionsSchema,
|
|
15
12
|
RawPAAItemSchema,
|
|
13
|
+
postToMemoryLibrary,
|
|
16
14
|
recencyToTbs
|
|
17
|
-
} from "./chunk-
|
|
15
|
+
} from "./chunk-3ZUBQQPQ.js";
|
|
18
16
|
import {
|
|
19
17
|
CaptchaError,
|
|
20
18
|
ExtractionError,
|
|
@@ -170,11 +168,21 @@ async function ensureKernelProfile(kernelClient, name) {
|
|
|
170
168
|
if (!isKernelProfileConflict(err)) throw err;
|
|
171
169
|
}
|
|
172
170
|
}
|
|
173
|
-
function
|
|
171
|
+
async function detectRuntimeUserAgent(browser) {
|
|
172
|
+
try {
|
|
173
|
+
const page = browser.contexts()[0]?.pages()[0];
|
|
174
|
+
if (!page) return null;
|
|
175
|
+
const ua = await page.evaluate(() => navigator.userAgent);
|
|
176
|
+
return typeof ua === "string" && /Chrome\/\d+/.test(ua) ? ua : null;
|
|
177
|
+
} catch {
|
|
178
|
+
return null;
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
function rankCheckContextOptions(config, runtimeUserAgent) {
|
|
174
182
|
return {
|
|
175
183
|
viewport: config.viewport,
|
|
176
184
|
locale: config.locale,
|
|
177
|
-
userAgent: config.userAgent ?? (config.isMobile ? MOBILE_USER_AGENT : DESKTOP_USER_AGENT),
|
|
185
|
+
userAgent: config.userAgent ?? (config.isMobile ? MOBILE_USER_AGENT : runtimeUserAgent ?? DESKTOP_USER_AGENT),
|
|
178
186
|
...config.deviceScaleFactor ? { deviceScaleFactor: config.deviceScaleFactor } : {},
|
|
179
187
|
...config.isMobile !== void 0 ? { isMobile: config.isMobile } : {},
|
|
180
188
|
...config.hasTouch !== void 0 ? { hasTouch: config.hasTouch } : {}
|
|
@@ -271,7 +279,7 @@ var BrowserDriver = class {
|
|
|
271
279
|
this.kernelHeadlessSent = useHeadless ? true : null;
|
|
272
280
|
if (costCtx?.headlessSentOut) costCtx.headlessSentOut.value = this.kernelHeadlessSent;
|
|
273
281
|
const kernelBrowser = await this.kernelClient.browsers.create({
|
|
274
|
-
stealth: true,
|
|
282
|
+
stealth: config.kernelStealth === true,
|
|
275
283
|
timeout_seconds: timeoutSeconds,
|
|
276
284
|
...useHeadless ? { headless: true } : {},
|
|
277
285
|
...config.kernelProxyId ? { proxy_id: config.kernelProxyId } : {},
|
|
@@ -336,7 +344,9 @@ var BrowserDriver = class {
|
|
|
336
344
|
await this.populateKernelRetrieveDebug(kernelDebug, config.kernelProxyId);
|
|
337
345
|
}
|
|
338
346
|
this.browser = await playwrightChromium.connectOverCDP(kernelBrowser.cdp_ws_url);
|
|
339
|
-
|
|
347
|
+
const runtimeUserAgent = await detectRuntimeUserAgent(this.browser);
|
|
348
|
+
this.debugSnapshot.context.userAgent = config.userAgent ?? (config.isMobile ? MOBILE_USER_AGENT : runtimeUserAgent ?? DESKTOP_USER_AGENT);
|
|
349
|
+
this.context = await this.browser.newContext(rankCheckContextOptions(config, runtimeUserAgent));
|
|
340
350
|
await this.installEsbuildHelperShims(this.context);
|
|
341
351
|
this.page = await this.context.newPage();
|
|
342
352
|
await this.page.setViewportSize(config.viewport);
|
|
@@ -3185,7 +3195,7 @@ async function harvest(rawOptions) {
|
|
|
3185
3195
|
const needsLocationEvidence = proxyMode === "location" && Boolean(proxyOpts.location);
|
|
3186
3196
|
const requestedMaxAttempts = raw.maxAttempts;
|
|
3187
3197
|
const baseMaxAttempts = typeof requestedMaxAttempts === "number" && Number.isInteger(requestedMaxAttempts) && requestedMaxAttempts >= 1 ? requestedMaxAttempts : maxAttemptsForProxyMode(proxyMode) + 1;
|
|
3188
|
-
const maxAttempts = baseMaxAttempts
|
|
3198
|
+
const maxAttempts = baseMaxAttempts;
|
|
3189
3199
|
const softDeadlineMs = typeof raw.softDeadlineMs === "number" ? raw.softDeadlineMs : null;
|
|
3190
3200
|
const serializer = new OutputSerializer();
|
|
3191
3201
|
let lastError = null;
|
|
@@ -3196,14 +3206,11 @@ async function harvest(rawOptions) {
|
|
|
3196
3206
|
const startedAtMs = Date.now();
|
|
3197
3207
|
try {
|
|
3198
3208
|
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({
|
|
3209
|
+
const resolution2 = await resolveKernelProxyId({
|
|
3202
3210
|
...proxyOpts,
|
|
3203
3211
|
proxyMode: effectiveProxyMode,
|
|
3204
3212
|
attemptIndex: i,
|
|
3205
|
-
fresh: effectiveProxyMode === "location"
|
|
3206
|
-
backupOnExhaustion: true
|
|
3213
|
+
fresh: effectiveProxyMode === "location"
|
|
3207
3214
|
});
|
|
3208
3215
|
if (!resolution2) break;
|
|
3209
3216
|
const mergedAttempt = {
|
|
@@ -3212,9 +3219,10 @@ async function harvest(rawOptions) {
|
|
|
3212
3219
|
kernelProxyId: resolution2.kernelProxyId,
|
|
3213
3220
|
kernelProxyResolution: resolution2.resolution,
|
|
3214
3221
|
proxyMode: effectiveProxyMode,
|
|
3222
|
+
keepDefaultProxy: i > 0,
|
|
3215
3223
|
debug: requestedDebug || needsLocationEvidence
|
|
3216
3224
|
};
|
|
3217
|
-
if (effectiveProxyMode === "none"
|
|
3225
|
+
if (effectiveProxyMode === "none") mergedAttempt.kernelProxyId = void 0;
|
|
3218
3226
|
const attemptOptions = HarvestOptionsSchema.parse(mergedAttempt);
|
|
3219
3227
|
await emitAttemptEvent(onAttemptEvent, {
|
|
3220
3228
|
type: "started",
|
|
@@ -3439,4 +3447,4 @@ export {
|
|
|
3439
3447
|
resolveKernelProxyId,
|
|
3440
3448
|
harvest
|
|
3441
3449
|
};
|
|
3442
|
-
//# sourceMappingURL=chunk-
|
|
3450
|
+
//# sourceMappingURL=chunk-H7LQ6PTI.js.map
|