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.
Files changed (64) hide show
  1. package/README.md +2 -2
  2. package/dist/bin/api-server.cjs +3284 -2130
  3. package/dist/bin/api-server.cjs.map +1 -1
  4. package/dist/bin/api-server.js +2 -2
  5. package/dist/bin/mcp-scraper-cli.cjs +1 -1
  6. package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
  7. package/dist/bin/mcp-scraper-cli.js +3 -4
  8. package/dist/bin/mcp-scraper-cli.js.map +1 -1
  9. package/dist/bin/mcp-scraper-install.cjs +2 -2
  10. package/dist/bin/mcp-scraper-install.cjs.map +1 -1
  11. package/dist/bin/mcp-scraper-install.js +2 -2
  12. package/dist/bin/mcp-stdio-server.cjs +3361 -2817
  13. package/dist/bin/mcp-stdio-server.cjs.map +1 -1
  14. package/dist/bin/mcp-stdio-server.js +51 -24
  15. package/dist/bin/mcp-stdio-server.js.map +1 -1
  16. package/dist/bin/paa-harvest.cjs +21 -21
  17. package/dist/bin/paa-harvest.cjs.map +1 -1
  18. package/dist/bin/paa-harvest.js +2 -3
  19. package/dist/bin/paa-harvest.js.map +1 -1
  20. package/dist/{chunk-MJKVDLVR.js → chunk-2K74LVV7.js} +26 -2
  21. package/dist/{chunk-MJKVDLVR.js.map → chunk-2K74LVV7.js.map} +1 -1
  22. package/dist/{chunk-CB5C3BPB.js → chunk-3ZUBQQPQ.js} +23 -2
  23. package/dist/chunk-3ZUBQQPQ.js.map +1 -0
  24. package/dist/{chunk-6Q7V4IQV.js → chunk-6WLNXYRG.js} +19 -2
  25. package/dist/chunk-6WLNXYRG.js.map +1 -0
  26. package/dist/{chunk-G5MHJGKE.js → chunk-GUI33Q27.js} +2 -2
  27. package/dist/{chunk-DH42LIR3.js → chunk-H7LQ6PTI.js} +24 -16
  28. package/dist/chunk-H7LQ6PTI.js.map +1 -0
  29. package/dist/chunk-MD75M2L5.js +7 -0
  30. package/dist/chunk-MD75M2L5.js.map +1 -0
  31. package/dist/{chunk-ENJQ2NSX.js → chunk-TC4GDB2Q.js} +2 -2
  32. package/dist/{chunk-ENJQ2NSX.js.map → chunk-TC4GDB2Q.js.map} +1 -1
  33. package/dist/{chunk-IMUA3FJB.js → chunk-X5WDJ7D7.js} +6 -6
  34. package/dist/chunk-X5WDJ7D7.js.map +1 -0
  35. package/dist/{chunk-QKCDYMFT.js → chunk-YJNGNMDO.js} +2196 -1584
  36. package/dist/chunk-YJNGNMDO.js.map +1 -0
  37. package/dist/{chunk-FQI5PFE7.js → chunk-ZSJHRZY5.js} +3 -5
  38. package/dist/{chunk-FQI5PFE7.js.map → chunk-ZSJHRZY5.js.map} +1 -1
  39. package/dist/{extract-bundle-FH734F3R.js → extract-bundle-IOM45SFL.js} +5 -5
  40. package/dist/index.cjs +21 -21
  41. package/dist/index.cjs.map +1 -1
  42. package/dist/index.d.cts +21 -57
  43. package/dist/index.d.ts +21 -57
  44. package/dist/index.js +2 -3
  45. package/dist/index.js.map +1 -1
  46. package/dist/{server-B27DR4YB.js → server-BPEXEKA6.js} +800 -336
  47. package/dist/server-BPEXEKA6.js.map +1 -0
  48. package/dist/{site-extract-repository-5CVI3OWT.js → site-extract-repository-XNI4ZK2M.js} +3 -3
  49. package/dist/{worker-MQJOY4YP.js → worker-2LIOH744.js} +4 -5
  50. package/dist/{worker-MQJOY4YP.js.map → worker-2LIOH744.js.map} +1 -1
  51. package/package.json +10 -7
  52. package/dist/chunk-2YFTFT3V.js +0 -7
  53. package/dist/chunk-2YFTFT3V.js.map +0 -1
  54. package/dist/chunk-6Q7V4IQV.js.map +0 -1
  55. package/dist/chunk-CB5C3BPB.js.map +0 -1
  56. package/dist/chunk-DH42LIR3.js.map +0 -1
  57. package/dist/chunk-IMUA3FJB.js.map +0 -1
  58. package/dist/chunk-K443GQY5.js +0 -24
  59. package/dist/chunk-K443GQY5.js.map +0 -1
  60. package/dist/chunk-QKCDYMFT.js.map +0 -1
  61. package/dist/server-B27DR4YB.js.map +0 -1
  62. /package/dist/{chunk-G5MHJGKE.js.map → chunk-GUI33Q27.js.map} +0 -0
  63. /package/dist/{extract-bundle-FH734F3R.js.map → extract-bundle-IOM45SFL.js.map} +0 -0
  64. /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-CB5C3BPB.js";
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 rankCheckContextOptions(config) {
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
- this.context = await this.browser.newContext(rankCheckContextOptions(config));
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 + (backupProxyAvailable() ? BACKUP_LAST_RESORT_ATTEMPTS : 0);
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 isBackupAttempt = i >= baseMaxAttempts;
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" && !isBackupAttempt) mergedAttempt.kernelProxyId = void 0;
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-DH42LIR3.js.map
3450
+ //# sourceMappingURL=chunk-H7LQ6PTI.js.map