mcp-scraper 0.30.0 → 0.32.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 +1 -1
- package/dist/bin/api-server.cjs +93 -41
- package/dist/bin/api-server.cjs.map +1 -1
- package/dist/bin/api-server.js +2 -2
- package/dist/bin/mcp-scraper-cli.cjs +4 -1
- package/dist/bin/mcp-scraper-cli.cjs.map +1 -1
- package/dist/bin/mcp-scraper-cli.js +3 -3
- package/dist/bin/mcp-scraper-install.cjs +1 -1
- package/dist/bin/mcp-scraper-install.cjs.map +1 -1
- package/dist/bin/mcp-scraper-install.js +1 -1
- package/dist/bin/mcp-stdio-server.cjs +38 -34
- package/dist/bin/mcp-stdio-server.cjs.map +1 -1
- package/dist/bin/mcp-stdio-server.js +3 -3
- package/dist/bin/paa-harvest.cjs +26 -4
- package/dist/bin/paa-harvest.cjs.map +1 -1
- package/dist/bin/paa-harvest.js +2 -2
- package/dist/{chunk-KAMKTSJQ.js → chunk-55M5CE5L.js} +2 -2
- package/dist/chunk-CPQF3PYW.js +7 -0
- package/dist/chunk-CPQF3PYW.js.map +1 -0
- package/dist/{chunk-ZQSHKWV4.js → chunk-PTHY7NYD.js} +4 -1
- package/dist/chunk-PTHY7NYD.js.map +1 -0
- package/dist/{chunk-YH5DRFWQ.js → chunk-RDCCU7CQ.js} +25 -6
- package/dist/chunk-RDCCU7CQ.js.map +1 -0
- package/dist/{chunk-T2CIPAOK.js → chunk-YOOEAXWP.js} +37 -36
- package/dist/chunk-YOOEAXWP.js.map +1 -0
- package/dist/index.cjs +26 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -0
- package/dist/index.d.ts +9 -0
- package/dist/index.js +2 -2
- package/dist/{server-PBPXND5G.js → server-OBOTNFD6.js} +40 -10
- package/dist/{server-PBPXND5G.js.map → server-OBOTNFD6.js.map} +1 -1
- package/dist/{worker-RYP5EOV5.js → worker-7DJYUACV.js} +3 -3
- package/docs/mcp-tool-manifest.generated.json +29 -29
- package/package.json +2 -2
- package/dist/chunk-T2CIPAOK.js.map +0 -1
- package/dist/chunk-WQUF7AH7.js +0 -7
- package/dist/chunk-WQUF7AH7.js.map +0 -1
- package/dist/chunk-YH5DRFWQ.js.map +0 -1
- package/dist/chunk-ZQSHKWV4.js.map +0 -1
- /package/dist/{chunk-KAMKTSJQ.js.map → chunk-55M5CE5L.js.map} +0 -0
- /package/dist/{worker-RYP5EOV5.js.map → worker-7DJYUACV.js.map} +0 -0
package/dist/index.cjs
CHANGED
|
@@ -48,6 +48,9 @@ var HarvestOptionsSchema = import_zod.z.object({
|
|
|
48
48
|
device: import_zod.z.enum(["desktop", "mobile"]).default("desktop"),
|
|
49
49
|
proxyMode: import_zod.z.enum(["location", "configured", "none"]).default(DEFAULT_PROXY_MODE),
|
|
50
50
|
proxyZip: import_zod.z.string().regex(/^\d{5}$/).optional(),
|
|
51
|
+
keepDefaultProxy: import_zod.z.boolean().optional(),
|
|
52
|
+
requireUsEgress: import_zod.z.boolean().optional(),
|
|
53
|
+
maxAttempts: import_zod.z.number().int().min(1).max(12).optional(),
|
|
51
54
|
debug: import_zod.z.boolean().default(false),
|
|
52
55
|
depth: import_zod.z.number().int().min(1).max(30).default(3),
|
|
53
56
|
maxQuestions: import_zod.z.number().int().min(1).max(1e3).default(100),
|
|
@@ -544,6 +547,15 @@ function positiveIntFromEnv(name, fallback) {
|
|
|
544
547
|
function proxyIdSuffix(proxyId) {
|
|
545
548
|
return proxyId ? proxyId.slice(-6) : null;
|
|
546
549
|
}
|
|
550
|
+
function serpArrivalUrl(googleUrl) {
|
|
551
|
+
const base = process.env.SERP_REDIRECT_BASE?.trim().replace(/\/+$/, "");
|
|
552
|
+
if (!base) return googleUrl;
|
|
553
|
+
return `${base}/g/${Buffer.from(googleUrl, "utf8").toString("base64url")}`;
|
|
554
|
+
}
|
|
555
|
+
function isUsCountry(country) {
|
|
556
|
+
if (!country) return false;
|
|
557
|
+
return /united states|u\.?s\.?a?\.?|^us$/i.test(country.trim());
|
|
558
|
+
}
|
|
547
559
|
function errorText(err) {
|
|
548
560
|
return err instanceof Error ? err.message : String(err);
|
|
549
561
|
}
|
|
@@ -677,7 +689,7 @@ var BrowserDriver = class {
|
|
|
677
689
|
this.kernelProxyType = config.kernelProxyResolution?.proxyType ?? null;
|
|
678
690
|
let defaultProxyDisabled = null;
|
|
679
691
|
let defaultProxyDisableError = null;
|
|
680
|
-
if (!config.kernelProxyId) {
|
|
692
|
+
if (!config.kernelProxyId && !config.keepDefaultProxy) {
|
|
681
693
|
try {
|
|
682
694
|
await withTimeout(
|
|
683
695
|
this.kernelClient.browsers.update(this.kernelSessionId, { disable_default_proxy: true }),
|
|
@@ -727,9 +739,15 @@ var BrowserDriver = class {
|
|
|
727
739
|
await this.installEsbuildHelperShims(this.context);
|
|
728
740
|
this.page = await this.context.newPage();
|
|
729
741
|
await this.page.setViewportSize(config.viewport);
|
|
730
|
-
if (this.debugEnabled) {
|
|
742
|
+
if (this.debugEnabled || config.requireUsEgress) {
|
|
731
743
|
this.debugSnapshot.networkLocation = await this.captureBrowserNetworkLocation();
|
|
732
744
|
}
|
|
745
|
+
if (config.requireUsEgress) {
|
|
746
|
+
const country = this.debugSnapshot.networkLocation?.country ?? null;
|
|
747
|
+
if (!isUsCountry(country)) {
|
|
748
|
+
throw new CaptchaError(`Non-US egress (${country ?? "unknown"}) \u2014 retrying with a fresh session`);
|
|
749
|
+
}
|
|
750
|
+
}
|
|
733
751
|
return;
|
|
734
752
|
}
|
|
735
753
|
const launchOpts = {
|
|
@@ -869,6 +887,7 @@ var BrowserDriver = class {
|
|
|
869
887
|
if (options?.num) params.set("num", String(options.num));
|
|
870
888
|
if (uule) params.set("uule", uule);
|
|
871
889
|
const url = "https://www.google.com/search?" + params.toString();
|
|
890
|
+
const navUrl = serpArrivalUrl(url);
|
|
872
891
|
const navDebug = options?.debug ? {
|
|
873
892
|
requestedUrl: url,
|
|
874
893
|
finalUrl: null,
|
|
@@ -881,7 +900,7 @@ var BrowserDriver = class {
|
|
|
881
900
|
} : null;
|
|
882
901
|
if (navDebug) this.debugSnapshot.serpNavigation = navDebug;
|
|
883
902
|
try {
|
|
884
|
-
await this.page.goto(
|
|
903
|
+
await this.page.goto(navUrl, { waitUntil: "domcontentloaded", timeout: 45e3 });
|
|
885
904
|
} catch (err) {
|
|
886
905
|
await this.updateSerpNavigationDebug(navDebug, url, { hasPaa: null, captchaDetected: null });
|
|
887
906
|
const diag = await this.captureDiagnostics(url);
|
|
@@ -2407,6 +2426,8 @@ var PAAExtractor = class {
|
|
|
2407
2426
|
kernelProxyId: options.kernelProxyId,
|
|
2408
2427
|
kernelProxyResolution: options.kernelProxyResolution,
|
|
2409
2428
|
proxyMode: options.proxyMode,
|
|
2429
|
+
keepDefaultProxy: options.keepDefaultProxy,
|
|
2430
|
+
requireUsEgress: options.requireUsEgress,
|
|
2410
2431
|
viewport: isMobile ? { width: 390, height: 844 } : { width: 1280, height: 800 },
|
|
2411
2432
|
locale: `${options.hl}-${options.gl.toUpperCase()}`,
|
|
2412
2433
|
userAgent: isMobile ? MOBILE_USER_AGENT2 : DESKTOP_USER_AGENT2,
|
|
@@ -3357,7 +3378,8 @@ async function harvest(rawOptions) {
|
|
|
3357
3378
|
};
|
|
3358
3379
|
const requestedDebug = typeof raw.debug === "boolean" ? raw.debug : false;
|
|
3359
3380
|
const needsLocationEvidence = proxyMode === "location" && Boolean(proxyOpts.location);
|
|
3360
|
-
const
|
|
3381
|
+
const requestedMaxAttempts = raw.maxAttempts;
|
|
3382
|
+
const maxAttempts = typeof requestedMaxAttempts === "number" && Number.isInteger(requestedMaxAttempts) && requestedMaxAttempts >= 1 ? requestedMaxAttempts : maxAttemptsForProxyMode(proxyMode) + 1;
|
|
3361
3383
|
const serializer = new OutputSerializer();
|
|
3362
3384
|
let lastError = null;
|
|
3363
3385
|
let effectiveProxyMode = proxyMode;
|