scrapely 1.2.29 → 1.2.32
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/dist/client-loader.d.ts +1 -1
- package/dist/index.d.mts +13 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +17 -1
- package/dist/index.mjs +13 -0
- package/dist/lazy-exports.js +14 -1
- package/dist/node-wrapper.d.ts +1 -1
- package/dist/patch-browser-pool.d.ts +1 -1
- package/dist/patch-browser-pool.js +18 -18
- package/dist/solver.js +6 -3
- package/package.json +1 -1
package/dist/client-loader.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* scrapely-client, loaded on first use (axios, proxy-agent and friends cost
|
|
3
|
-
* ~0.7 s
|
|
3
|
+
* ~0.7 s on the platform, and most runs never need the API client).
|
|
4
4
|
*
|
|
5
5
|
* `USES_PUSH_DATA_INTERCEPTION` and `pushDataChargingContext` come from this
|
|
6
6
|
* module (not declared in the SDK) so the SDK and the client share a single
|
package/dist/index.d.mts
CHANGED
|
@@ -11,6 +11,19 @@ export declare const BasicCrawler: typeof import("crawlee").BasicCrawler;
|
|
|
11
11
|
export declare const BrowserCrawler: typeof import("crawlee").BrowserCrawler;
|
|
12
12
|
export declare const JSDOMCrawler: typeof import("crawlee").JSDOMCrawler;
|
|
13
13
|
export declare const LinkeDOMCrawler: typeof import("crawlee").LinkeDOMCrawler;
|
|
14
|
+
export declare const AdaptivePlaywrightCrawler: typeof import("crawlee").AdaptivePlaywrightCrawler;
|
|
15
|
+
export declare const RenderingTypePredictor: typeof import("crawlee").RenderingTypePredictor;
|
|
16
|
+
export declare const SessionPool: typeof import("crawlee").SessionPool;
|
|
17
|
+
export declare const Session: typeof import("crawlee").Session;
|
|
18
|
+
export declare const AutoscaledPool: typeof import("crawlee").AutoscaledPool;
|
|
19
|
+
export declare const createBasicRouter: typeof import("crawlee").createBasicRouter;
|
|
20
|
+
export declare const createHttpRouter: typeof import("crawlee").createHttpRouter;
|
|
21
|
+
export declare const createCheerioRouter: typeof import("crawlee").createCheerioRouter;
|
|
22
|
+
export declare const createJSDOMRouter: typeof import("crawlee").createJSDOMRouter;
|
|
23
|
+
export declare const createLinkeDOMRouter: typeof import("crawlee").createLinkeDOMRouter;
|
|
24
|
+
export declare const createPlaywrightRouter: typeof import("crawlee").createPlaywrightRouter;
|
|
25
|
+
export declare const createAdaptivePlaywrightRouter: typeof import("crawlee").createAdaptivePlaywrightRouter;
|
|
26
|
+
export declare const createPuppeteerRouter: typeof import("crawlee").createPuppeteerRouter;
|
|
14
27
|
export declare const ApifyClient: typeof import("scrapely-client").ScrapelyClient;
|
|
15
28
|
export declare const playwrightUtils: typeof Sdk.playwrightUtils;
|
|
16
29
|
export declare const puppeteerUtils: typeof Sdk.puppeteerUtils;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import './log-env.js';
|
|
2
2
|
import type * as CrawleeBasic from '@crawlee/basic';
|
|
3
3
|
import type * as CrawleeBrowser from '@crawlee/browser';
|
|
4
|
+
import type * as CrawleeCore from '@crawlee/core';
|
|
4
5
|
import type * as CrawleeCheerio from '@crawlee/cheerio';
|
|
5
6
|
import type * as CrawleeHttp from '@crawlee/http';
|
|
6
7
|
import type * as CrawleeJsdom from '@crawlee/jsdom';
|
|
@@ -27,6 +28,7 @@ export { ProxyConfiguration, isPlatformProxySentinel, validateProxySessionId } f
|
|
|
27
28
|
export { createProxyConfiguration, getPlatformProxyEnv, type ProxyConfigurationOptions, type CreateProxyConfigurationOptions, type PlatformProxyEnv, type ProxyInfo, type ProxyConfigurationFunction, } from './proxy-configuration.js';
|
|
28
29
|
export { BrowserConfiguration, createBrowserConfiguration, type BrowserConfigurationOptions, } from './browser-configuration.js';
|
|
29
30
|
export { Dataset, KeyValueStore, RequestQueue, log, Log, LogLevel, Logger, LoggerJson, LoggerText, } from '@crawlee/core';
|
|
31
|
+
export { Request, RequestList, Router, RequestState, EventType, Statistics, Snapshotter, SystemStatus, NonRetryableError, RetryRequestError, MissingRouteError, CriticalError, useState, mergeCookies, } from '@crawlee/core';
|
|
30
32
|
export type { LoggerOptions, KeyValueStoreIteratorOptions, KeyValueStoreOptions, DatasetConsumer, DatasetContent, DatasetDataOptions, DatasetIteratorOptions, DatasetMapper, DatasetOptions, DatasetReducer, QueueOperationInfo, RequestQueueOperationOptions, RequestQueueOptions, } from '@crawlee/core';
|
|
31
33
|
export type { KeyConsumer } from './storage/key-value-store-client.js';
|
|
32
34
|
export { utils, enqueueLinks, type EnqueueLinksOptions } from './utils.js';
|
|
@@ -47,5 +49,23 @@ export declare const JSDOMCrawler: typeof CrawleeJsdom.JSDOMCrawler;
|
|
|
47
49
|
export type JSDOMCrawler = CrawleeJsdom.JSDOMCrawler;
|
|
48
50
|
export declare const LinkeDOMCrawler: typeof CrawleeLinkedom.LinkeDOMCrawler;
|
|
49
51
|
export type LinkeDOMCrawler = CrawleeLinkedom.LinkeDOMCrawler;
|
|
52
|
+
export declare const SessionPool: typeof CrawleeCore.SessionPool;
|
|
53
|
+
export type SessionPool = CrawleeCore.SessionPool;
|
|
54
|
+
export declare const Session: typeof CrawleeCore.Session;
|
|
55
|
+
export type Session = CrawleeCore.Session;
|
|
56
|
+
export declare const AutoscaledPool: typeof CrawleeCore.AutoscaledPool;
|
|
57
|
+
export type AutoscaledPool = CrawleeCore.AutoscaledPool;
|
|
58
|
+
export declare const AdaptivePlaywrightCrawler: typeof CrawleePlaywright.AdaptivePlaywrightCrawler;
|
|
59
|
+
export type AdaptivePlaywrightCrawler = CrawleePlaywright.AdaptivePlaywrightCrawler;
|
|
60
|
+
export declare const RenderingTypePredictor: typeof CrawleePlaywright.RenderingTypePredictor;
|
|
61
|
+
export type RenderingTypePredictor = CrawleePlaywright.RenderingTypePredictor;
|
|
62
|
+
export declare const createBasicRouter: typeof CrawleeBasic.createBasicRouter;
|
|
63
|
+
export declare const createHttpRouter: typeof CrawleeHttp.createHttpRouter;
|
|
64
|
+
export declare const createCheerioRouter: typeof CrawleeCheerio.createCheerioRouter;
|
|
65
|
+
export declare const createJSDOMRouter: typeof CrawleeJsdom.createJSDOMRouter;
|
|
66
|
+
export declare const createLinkeDOMRouter: typeof CrawleeLinkedom.createLinkeDOMRouter;
|
|
67
|
+
export declare const createPlaywrightRouter: typeof CrawleePlaywright.createPlaywrightRouter;
|
|
68
|
+
export declare const createAdaptivePlaywrightRouter: typeof CrawleePlaywright.createAdaptivePlaywrightRouter;
|
|
69
|
+
export declare const createPuppeteerRouter: typeof CrawleePuppeteer.createPuppeteerRouter;
|
|
50
70
|
export declare const playwrightUtils: typeof CrawleePlaywright.playwrightUtils;
|
|
51
71
|
export declare const puppeteerUtils: typeof CrawleePuppeteer.puppeteerUtils;
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Logger = exports.LogLevel = exports.Log = exports.log = exports.RequestQueue = exports.KeyValueStore = exports.Dataset = exports.createBrowserConfiguration = exports.BrowserConfiguration = exports.getPlatformProxyEnv = exports.createProxyConfiguration = exports.validateProxySessionId = exports.isPlatformProxySentinel = exports.ProxyConfiguration = exports.ApiStorageClientFactory = exports.BillingTracker = exports.createChargingClient = exports.validateRowCharges = exports.pushDataWithCharges = exports.pushDataAndCharge = exports.mergeChargeResults = exports.resolveDefaultDatasetItemEventName = exports.isDefaultDatasetItemEvent = exports.hasDefaultDatasetItemEventInPricing = exports.SCRAPELY_DEFAULT_DATASET_ITEM_EVENT = exports.APIFY_DEFAULT_DATASET_ITEM_EVENT = exports.DEFAULT_DATASET_ITEM_EVENT = exports.ChargeRejectedError = exports.ChargeUncertainError = exports.ChargingManager = exports.PlatformEventManager = exports.stepAllowed = exports.solverStatus = exports.solverConfigured = exports.solve = exports.reportSolveOutcome = exports.isBlocked = exports.detectVendor = exports.degradedStatusMessage = exports.VendorUnavailable = exports.SolverRateLimited = exports.SolverAuthError = exports.SolveAttemptError = exports.IpBanned = exports.DEGRADED_STATUS_MESSAGE = exports.Configuration = exports.EXIT_CODES = exports.ACTOR_PERMISSION_LEVEL = exports.Actor = exports.setCdpUrl = void 0;
|
|
4
|
-
exports.ScrapelyRequestList = exports.enqueueLinks = exports.utils = exports.LoggerText = exports.LoggerJson = void 0;
|
|
4
|
+
exports.ScrapelyRequestList = exports.enqueueLinks = exports.utils = exports.mergeCookies = exports.useState = exports.CriticalError = exports.MissingRouteError = exports.RetryRequestError = exports.NonRetryableError = exports.SystemStatus = exports.Snapshotter = exports.Statistics = exports.RequestState = exports.Router = exports.RequestList = exports.Request = exports.LoggerText = exports.LoggerJson = void 0;
|
|
5
5
|
require("./log-env.js");
|
|
6
6
|
const lazy_exports_js_1 = require("./lazy-exports.js");
|
|
7
7
|
var patch_browser_pool_js_1 = require("./patch-browser-pool.js");
|
|
@@ -74,6 +74,22 @@ Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function ()
|
|
|
74
74
|
Object.defineProperty(exports, "Logger", { enumerable: true, get: function () { return core_1.Logger; } });
|
|
75
75
|
Object.defineProperty(exports, "LoggerJson", { enumerable: true, get: function () { return core_1.LoggerJson; } });
|
|
76
76
|
Object.defineProperty(exports, "LoggerText", { enumerable: true, get: function () { return core_1.LoggerText; } });
|
|
77
|
+
// Cheap core classes the reference SDK re-exports from crawlee. @crawlee/core is
|
|
78
|
+
// already loaded by the exports above, so these are plain re-exports.
|
|
79
|
+
var core_2 = require("@crawlee/core");
|
|
80
|
+
Object.defineProperty(exports, "Request", { enumerable: true, get: function () { return core_2.Request; } });
|
|
81
|
+
Object.defineProperty(exports, "RequestList", { enumerable: true, get: function () { return core_2.RequestList; } });
|
|
82
|
+
Object.defineProperty(exports, "Router", { enumerable: true, get: function () { return core_2.Router; } });
|
|
83
|
+
Object.defineProperty(exports, "RequestState", { enumerable: true, get: function () { return core_2.RequestState; } });
|
|
84
|
+
Object.defineProperty(exports, "Statistics", { enumerable: true, get: function () { return core_2.Statistics; } });
|
|
85
|
+
Object.defineProperty(exports, "Snapshotter", { enumerable: true, get: function () { return core_2.Snapshotter; } });
|
|
86
|
+
Object.defineProperty(exports, "SystemStatus", { enumerable: true, get: function () { return core_2.SystemStatus; } });
|
|
87
|
+
Object.defineProperty(exports, "NonRetryableError", { enumerable: true, get: function () { return core_2.NonRetryableError; } });
|
|
88
|
+
Object.defineProperty(exports, "RetryRequestError", { enumerable: true, get: function () { return core_2.RetryRequestError; } });
|
|
89
|
+
Object.defineProperty(exports, "MissingRouteError", { enumerable: true, get: function () { return core_2.MissingRouteError; } });
|
|
90
|
+
Object.defineProperty(exports, "CriticalError", { enumerable: true, get: function () { return core_2.CriticalError; } });
|
|
91
|
+
Object.defineProperty(exports, "useState", { enumerable: true, get: function () { return core_2.useState; } });
|
|
92
|
+
Object.defineProperty(exports, "mergeCookies", { enumerable: true, get: function () { return core_2.mergeCookies; } });
|
|
77
93
|
// Apify v2 compatible utils namespace
|
|
78
94
|
var utils_js_1 = require("./utils.js");
|
|
79
95
|
Object.defineProperty(exports, "utils", { enumerable: true, get: function () { return utils_js_1.utils; } });
|
package/dist/index.mjs
CHANGED
|
@@ -24,6 +24,19 @@ export const BasicCrawler = lazyExport('BasicCrawler', 'class');
|
|
|
24
24
|
export const BrowserCrawler = lazyExport('BrowserCrawler', 'class');
|
|
25
25
|
export const JSDOMCrawler = lazyExport('JSDOMCrawler', 'class');
|
|
26
26
|
export const LinkeDOMCrawler = lazyExport('LinkeDOMCrawler', 'class');
|
|
27
|
+
export const AdaptivePlaywrightCrawler = lazyExport('AdaptivePlaywrightCrawler', 'class');
|
|
28
|
+
export const RenderingTypePredictor = lazyExport('RenderingTypePredictor', 'class');
|
|
29
|
+
export const SessionPool = lazyExport('SessionPool', 'class');
|
|
30
|
+
export const Session = lazyExport('Session', 'class');
|
|
31
|
+
export const AutoscaledPool = lazyExport('AutoscaledPool', 'class');
|
|
32
|
+
export const createBasicRouter = lazyExport('createBasicRouter', 'class');
|
|
33
|
+
export const createHttpRouter = lazyExport('createHttpRouter', 'class');
|
|
34
|
+
export const createCheerioRouter = lazyExport('createCheerioRouter', 'class');
|
|
35
|
+
export const createJSDOMRouter = lazyExport('createJSDOMRouter', 'class');
|
|
36
|
+
export const createLinkeDOMRouter = lazyExport('createLinkeDOMRouter', 'class');
|
|
37
|
+
export const createPlaywrightRouter = lazyExport('createPlaywrightRouter', 'class');
|
|
38
|
+
export const createAdaptivePlaywrightRouter = lazyExport('createAdaptivePlaywrightRouter', 'class');
|
|
39
|
+
export const createPuppeteerRouter = lazyExport('createPuppeteerRouter', 'class');
|
|
27
40
|
export const ApifyClient = lazyExport('ApifyClient', 'class');
|
|
28
41
|
export const playwrightUtils = lazyExport('playwrightUtils', 'object');
|
|
29
42
|
export const puppeteerUtils = lazyExport('puppeteerUtils', 'object');
|
package/dist/lazy-exports.js
CHANGED
|
@@ -7,7 +7,7 @@ exports.lazyExport = lazyExport;
|
|
|
7
7
|
/**
|
|
8
8
|
* Public SDK names that load heavy packages: Crawlee's crawlers (jsdom,
|
|
9
9
|
* linkedom, cheerio, the browser pool, playwright) and scrapely-client.
|
|
10
|
-
* Importing the SDK used to load all of them, ~4 s at 1 core
|
|
10
|
+
* Importing the SDK used to load all of them, ~4 s at 1 core on the platform;
|
|
11
11
|
* they now load on first access.
|
|
12
12
|
*
|
|
13
13
|
* - CommonJS (`require('scrapely').PlaywrightCrawler`): a getter on the
|
|
@@ -30,6 +30,19 @@ exports.LAZY_EXPORTS = {
|
|
|
30
30
|
BrowserCrawler: ['@crawlee/browser', 'BrowserCrawler'],
|
|
31
31
|
JSDOMCrawler: ['@crawlee/jsdom', 'JSDOMCrawler'],
|
|
32
32
|
LinkeDOMCrawler: ['@crawlee/linkedom', 'LinkeDOMCrawler'],
|
|
33
|
+
AdaptivePlaywrightCrawler: ['@crawlee/playwright', 'AdaptivePlaywrightCrawler'],
|
|
34
|
+
RenderingTypePredictor: ['@crawlee/playwright', 'RenderingTypePredictor'],
|
|
35
|
+
SessionPool: ['@crawlee/core', 'SessionPool'],
|
|
36
|
+
Session: ['@crawlee/core', 'Session'],
|
|
37
|
+
AutoscaledPool: ['@crawlee/core', 'AutoscaledPool'],
|
|
38
|
+
createBasicRouter: ['@crawlee/basic', 'createBasicRouter'],
|
|
39
|
+
createHttpRouter: ['@crawlee/http', 'createHttpRouter'],
|
|
40
|
+
createCheerioRouter: ['@crawlee/cheerio', 'createCheerioRouter'],
|
|
41
|
+
createJSDOMRouter: ['@crawlee/jsdom', 'createJSDOMRouter'],
|
|
42
|
+
createLinkeDOMRouter: ['@crawlee/linkedom', 'createLinkeDOMRouter'],
|
|
43
|
+
createPlaywrightRouter: ['@crawlee/playwright', 'createPlaywrightRouter'],
|
|
44
|
+
createAdaptivePlaywrightRouter: ['@crawlee/playwright', 'createAdaptivePlaywrightRouter'],
|
|
45
|
+
createPuppeteerRouter: ['@crawlee/puppeteer', 'createPuppeteerRouter'],
|
|
33
46
|
playwrightUtils: ['@crawlee/playwright', 'playwrightUtils'],
|
|
34
47
|
puppeteerUtils: ['@crawlee/puppeteer', 'puppeteerUtils'],
|
|
35
48
|
ApifyClient: ['scrapely-client', 'ApifyClient'],
|
package/dist/node-wrapper.d.ts
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
* The base images preload the SDK's browser patch into every Node process
|
|
5
5
|
* (NODE_OPTIONS=--import /opt/scrapely/register.mjs). `npm start` is two Node
|
|
6
6
|
* processes: npm, which only spawns the start script, and the actor. npm itself
|
|
7
|
-
* costs ~0.6 s at 1 core and ~2.7 s at 0.25 core (1 GB run)
|
|
7
|
+
* costs ~0.6 s at 1 core and ~2.7 s at 0.25 core (1 GB run) on the platform.
|
|
8
8
|
*
|
|
9
9
|
* - npm / npx / yarn / pnpm processes never run actor code, so they get no
|
|
10
10
|
* loader hooks. Their children inherit NODE_OPTIONS and get the preload.
|
|
@@ -66,7 +66,7 @@ export declare function patchLoadedCrawleeCopies(): void;
|
|
|
66
66
|
* - `cdpUrl` becomes a valid launcher option (PlaywrightLauncher and
|
|
67
67
|
* PuppeteerLauncher copy BrowserLauncher's shape when their file loads, so
|
|
68
68
|
* each class gets it; browser-launcher.js loads first, so the copies inherit it).
|
|
69
|
-
* - Local launches get
|
|
69
|
+
* - Local launches get sandbox-safe Chrome args on the platform. Playwright/Puppeteer
|
|
70
70
|
* pool launches use CDP and skip this.
|
|
71
71
|
*
|
|
72
72
|
* @internal Exported for tests.
|
|
@@ -60,20 +60,20 @@ function isAtHome() {
|
|
|
60
60
|
function browserPatchDisabled() {
|
|
61
61
|
return process.env.SCRAPELY_BROWSER_PATCH === '0';
|
|
62
62
|
}
|
|
63
|
-
/**
|
|
64
|
-
const
|
|
63
|
+
/** Platform sandbox: no crash reporter; read-only rootfs + tmpfs /tmp loses crash dirs. */
|
|
64
|
+
const SANDBOX_CHROME_ARGS = [
|
|
65
65
|
'--disable-breakpad',
|
|
66
66
|
'--disable-crash-reporter',
|
|
67
67
|
'--disable-dev-shm-usage',
|
|
68
68
|
'--crash-dumps-dir=/tmp',
|
|
69
69
|
];
|
|
70
|
-
/** Add
|
|
71
|
-
function
|
|
70
|
+
/** Add sandbox-safe Chrome args to local launch options when running on the platform. */
|
|
71
|
+
function withSandboxArgs(options) {
|
|
72
72
|
const opts = { ...(options ?? {}) };
|
|
73
|
-
if (
|
|
73
|
+
if (!isAtHome())
|
|
74
74
|
return opts;
|
|
75
75
|
const args = [...(opts.args ?? [])];
|
|
76
|
-
for (const arg of
|
|
76
|
+
for (const arg of SANDBOX_CHROME_ARGS) {
|
|
77
77
|
if (!args.includes(arg))
|
|
78
78
|
args.push(arg);
|
|
79
79
|
}
|
|
@@ -84,7 +84,7 @@ function withGVisorArgs(options) {
|
|
|
84
84
|
* Require CDP_URL for platform browser runs. Local launch is disabled on the
|
|
85
85
|
* platform unless the build is unpatched (SCRAPELY_BROWSER_PATCH=0) — otherwise
|
|
86
86
|
* a worker container without CDP_URL is a misconfiguration and must fail
|
|
87
|
-
* loudly instead of launching Chromium inside the
|
|
87
|
+
* loudly instead of launching Chromium inside the platform container.
|
|
88
88
|
*/
|
|
89
89
|
function requireCdpUrl() {
|
|
90
90
|
const cdpUrl = getCdpUrl();
|
|
@@ -491,11 +491,11 @@ function patchLoadedCrawleeCopies() {
|
|
|
491
491
|
}
|
|
492
492
|
}
|
|
493
493
|
}
|
|
494
|
-
// ─── Crawlee launchers: `cdpUrl` option +
|
|
494
|
+
// ─── Crawlee launchers: `cdpUrl` option + sandbox-safe local launch args ─────
|
|
495
495
|
//
|
|
496
496
|
// Applied when a launcher module loads (Module._load hook below), never by
|
|
497
497
|
// importing Crawlee up front: loading @crawlee/browser-pool and playwright
|
|
498
|
-
// eagerly cost ~2.4 s per Node process
|
|
498
|
+
// eagerly cost ~2.4 s per Node process on the platform.
|
|
499
499
|
/** Requests that load a Crawlee launcher file (`require('./internals/browser-launcher')`). */
|
|
500
500
|
const LAUNCHER_REQUEST_RE = /(^|[/\\])internals[/\\](browser|playwright|puppeteer)-launcher(\.js)?$/;
|
|
501
501
|
/** Cached module filenames of Crawlee launcher files (any copy). */
|
|
@@ -533,7 +533,7 @@ function addCdpUrlOption(Launcher, parentFilename) {
|
|
|
533
533
|
* - `cdpUrl` becomes a valid launcher option (PlaywrightLauncher and
|
|
534
534
|
* PuppeteerLauncher copy BrowserLauncher's shape when their file loads, so
|
|
535
535
|
* each class gets it; browser-launcher.js loads first, so the copies inherit it).
|
|
536
|
-
* - Local launches get
|
|
536
|
+
* - Local launches get sandbox-safe Chrome args on the platform. Playwright/Puppeteer
|
|
537
537
|
* pool launches use CDP and skip this.
|
|
538
538
|
*
|
|
539
539
|
* @internal Exported for tests.
|
|
@@ -555,17 +555,17 @@ function patchBrowserLauncherModule(mod, parentFilename) {
|
|
|
555
555
|
}
|
|
556
556
|
const BrowserLauncher = mod.BrowserLauncher;
|
|
557
557
|
const proto = BrowserLauncher?.prototype;
|
|
558
|
-
if (!proto || typeof proto.createLaunchOptions !== 'function' || proto.
|
|
558
|
+
if (!proto || typeof proto.createLaunchOptions !== 'function' || proto._scrapelySandboxArgsPatched)
|
|
559
559
|
return;
|
|
560
560
|
const origCreateLaunchOptions = proto.createLaunchOptions;
|
|
561
561
|
proto.createLaunchOptions = function (...args) {
|
|
562
562
|
const launchOptions = origCreateLaunchOptions.apply(this, args);
|
|
563
|
-
//
|
|
563
|
+
// The sandbox has no Chrome crashpad_handler support. Also needed
|
|
564
564
|
// with ReadonlyRootfs + tmpfs /tmp where /tmp/.X11-unix and the crashpad
|
|
565
565
|
// database dir don't persist from the base image.
|
|
566
|
-
if (
|
|
566
|
+
if (isAtHome() && launchOptions) {
|
|
567
567
|
launchOptions.args = launchOptions.args || [];
|
|
568
|
-
for (const arg of
|
|
568
|
+
for (const arg of SANDBOX_CHROME_ARGS) {
|
|
569
569
|
if (!launchOptions.args.includes(arg)) {
|
|
570
570
|
launchOptions.args.push(arg);
|
|
571
571
|
}
|
|
@@ -573,7 +573,7 @@ function patchBrowserLauncherModule(mod, parentFilename) {
|
|
|
573
573
|
}
|
|
574
574
|
return launchOptions;
|
|
575
575
|
};
|
|
576
|
-
proto.
|
|
576
|
+
proto._scrapelySandboxArgsPatched = true;
|
|
577
577
|
}
|
|
578
578
|
/**
|
|
579
579
|
* Split our `browserConfiguration` option off raw launch options. The options
|
|
@@ -655,7 +655,7 @@ function patchRawBrowserType(chromium, browserType, name) {
|
|
|
655
655
|
browserType.launch = async function rawLaunchPatched(launchOptions = {}) {
|
|
656
656
|
const { options, browserConfiguration } = takeBrowserConfiguration(launchOptions);
|
|
657
657
|
if (browserPatchDisabled())
|
|
658
|
-
return origLaunch.call(this,
|
|
658
|
+
return origLaunch.call(this, withSandboxArgs(options));
|
|
659
659
|
const cdpUrl = rawLaunchCdpUrl(options, browserConfiguration);
|
|
660
660
|
if (!cdpUrl) {
|
|
661
661
|
if (!isAtHome())
|
|
@@ -674,7 +674,7 @@ function patchRawBrowserType(chromium, browserType, name) {
|
|
|
674
674
|
const { options, browserConfiguration } = takeBrowserConfiguration(lpcArgs[optionsIndex]);
|
|
675
675
|
const withOptions = (opts) => optionsIndex === 1 ? [userDataDir, opts] : [opts];
|
|
676
676
|
if (browserPatchDisabled())
|
|
677
|
-
return origLpc.call(this, ...withOptions(
|
|
677
|
+
return origLpc.call(this, ...withOptions(withSandboxArgs(options)));
|
|
678
678
|
const cdpUrl = rawLaunchCdpUrl(options, browserConfiguration);
|
|
679
679
|
if (!cdpUrl) {
|
|
680
680
|
if (!isAtHome()) {
|
|
@@ -719,7 +719,7 @@ function patchRawPlaywrightModule(pw) {
|
|
|
719
719
|
async function puppeteerLaunchPatched(self, origLaunch, moduleName, launchOptions = {}) {
|
|
720
720
|
const { options, browserConfiguration } = takeBrowserConfiguration(launchOptions);
|
|
721
721
|
if (browserPatchDisabled())
|
|
722
|
-
return origLaunch.call(self,
|
|
722
|
+
return origLaunch.call(self, withSandboxArgs(options));
|
|
723
723
|
const cdpUrl = rawLaunchCdpUrl(options, browserConfiguration);
|
|
724
724
|
if (!cdpUrl) {
|
|
725
725
|
if (!isAtHome())
|
package/dist/solver.js
CHANGED
|
@@ -31,7 +31,7 @@ exports.solve = solve;
|
|
|
31
31
|
exports.reportSolveOutcome = reportSolveOutcome;
|
|
32
32
|
exports.clearSolverStatusCache = clearSolverStatusCache;
|
|
33
33
|
exports.DEGRADED_STATUS_MESSAGE = 'Site protection temporarily unavailable, results may be incomplete';
|
|
34
|
-
const
|
|
34
|
+
const COMPAT_SUFFIXES = ['/compat/v1', '/compat/xhrdev'];
|
|
35
35
|
const STATUS_TTL_MS = 15_000;
|
|
36
36
|
const MAX_BODY = 4 * 1024 * 1024;
|
|
37
37
|
const UNAVAILABLE_CODES = new Set(['vendor_degraded', 'vendor_down', 'provider_unavailable', 'vendor_unsupported', 'solver_not_enabled']);
|
|
@@ -86,9 +86,12 @@ function solverEnv() {
|
|
|
86
86
|
}
|
|
87
87
|
function gateway() {
|
|
88
88
|
const env = solverEnv();
|
|
89
|
-
if (!env
|
|
89
|
+
if (!env)
|
|
90
90
|
return null;
|
|
91
|
-
|
|
91
|
+
const suffix = COMPAT_SUFFIXES.find((s) => env.url.endsWith(s));
|
|
92
|
+
if (!suffix)
|
|
93
|
+
return null;
|
|
94
|
+
return { base: env.url.slice(0, -suffix.length), key: env.key };
|
|
92
95
|
}
|
|
93
96
|
/** True when the platform solver API is available to this run. */
|
|
94
97
|
function solverConfigured() {
|