@crawlee/puppeteer 3.0.0-alpha.4 → 3.0.0-alpha.7
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/index.d.ts +0 -2
- package/index.d.ts.map +1 -1
- package/index.js +1 -2
- package/index.js.map +1 -1
- package/index.mjs +1 -2
- package/internals/puppeteer-crawler.d.ts +1 -1
- package/internals/puppeteer-crawler.d.ts.map +1 -1
- package/internals/puppeteer-crawler.js +2 -13
- package/internals/puppeteer-crawler.js.map +1 -1
- package/internals/puppeteer-launcher.d.ts +6 -25
- package/internals/puppeteer-launcher.d.ts.map +1 -1
- package/internals/puppeteer-launcher.js +1 -73
- package/internals/puppeteer-launcher.js.map +1 -1
- package/package.json +2 -2
- package/tsconfig.build.tsbuildinfo +1 -1
- package/internals/stealth/hiding_tricks.d.ts +0 -10
- package/internals/stealth/hiding_tricks.d.ts.map +0 -1
- package/internals/stealth/hiding_tricks.js +0 -334
- package/internals/stealth/hiding_tricks.js.map +0 -1
- package/internals/stealth/index.d.ts +0 -40
- package/internals/stealth/index.d.ts.map +0 -1
- package/internals/stealth/index.js +0 -108
- package/internals/stealth/index.js.map +0 -1
package/index.d.ts
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
export * from '@crawlee/browser';
|
|
2
2
|
export * from './internals/puppeteer-crawler';
|
|
3
3
|
export * from './internals/puppeteer-launcher';
|
|
4
|
-
export * as puppeteerStealth from './internals/stealth';
|
|
5
|
-
export type { StealthOptions } from './internals/stealth';
|
|
6
4
|
export * as puppeteerRequestInterception from './internals/utils/puppeteer_request_interception';
|
|
7
5
|
export type { InterceptHandler } from './internals/utils/puppeteer_request_interception';
|
|
8
6
|
export * as puppeteerUtils from './internals/utils/puppeteer_utils';
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAE/C,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAE/C,OAAO,KAAK,4BAA4B,MAAM,kDAAkD,CAAC;AACjG,YAAY,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAEzF,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAC;AACpE,YAAY,EACR,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,IAAI,gCAAgC,EAC3D,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,GACtB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,KAAK,sBAAsB,MAAM,0CAA0C,CAAC;AACnF,YAAY,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.puppeteerClickElements = exports.puppeteerUtils = exports.puppeteerRequestInterception =
|
|
3
|
+
exports.puppeteerClickElements = exports.puppeteerUtils = exports.puppeteerRequestInterception = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
tslib_1.__exportStar(require("@crawlee/browser"), exports);
|
|
6
6
|
tslib_1.__exportStar(require("./internals/puppeteer-crawler"), exports);
|
|
7
7
|
tslib_1.__exportStar(require("./internals/puppeteer-launcher"), exports);
|
|
8
|
-
exports.puppeteerStealth = tslib_1.__importStar(require("./internals/stealth"));
|
|
9
8
|
exports.puppeteerRequestInterception = tslib_1.__importStar(require("./internals/utils/puppeteer_request_interception"));
|
|
10
9
|
exports.puppeteerUtils = tslib_1.__importStar(require("./internals/utils/puppeteer_utils"));
|
|
11
10
|
exports.puppeteerClickElements = tslib_1.__importStar(require("./internals/enqueue-links/click-elements"));
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAiC;AACjC,wEAA8C;AAC9C,yEAA+C;AAE/C,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAiC;AACjC,wEAA8C;AAC9C,yEAA+C;AAE/C,yHAAiG;AAGjG,4FAAoE;AAWpE,2GAAmF"}
|
package/index.mjs
CHANGED
|
@@ -42,7 +42,6 @@ export const Snapshotter = mod.Snapshotter;
|
|
|
42
42
|
export const Statistics = mod.Statistics;
|
|
43
43
|
export const StorageManager = mod.StorageManager;
|
|
44
44
|
export const SystemStatus = mod.SystemStatus;
|
|
45
|
-
export const basicCrawlerEnqueueLinks = mod.basicCrawlerEnqueueLinks;
|
|
46
45
|
export const browserCrawlerEnqueueLinks = mod.browserCrawlerEnqueueLinks;
|
|
47
46
|
export const checkAndSerialize = mod.checkAndSerialize;
|
|
48
47
|
export const chunkBySize = mod.chunkBySize;
|
|
@@ -65,9 +64,9 @@ export const mergeCookies = mod.mergeCookies;
|
|
|
65
64
|
export const openDataset = mod.openDataset;
|
|
66
65
|
export const puppeteerClickElements = mod.puppeteerClickElements;
|
|
67
66
|
export const puppeteerRequestInterception = mod.puppeteerRequestInterception;
|
|
68
|
-
export const puppeteerStealth = mod.puppeteerStealth;
|
|
69
67
|
export const puppeteerUtils = mod.puppeteerUtils;
|
|
70
68
|
export const pushData = mod.pushData;
|
|
69
|
+
export const resolveBaseUrl = mod.resolveBaseUrl;
|
|
71
70
|
export const serializeArray = mod.serializeArray;
|
|
72
71
|
export const storage = mod.storage;
|
|
73
72
|
export const throwOnBlockedRequest = mod.throwOnBlockedRequest;
|
|
@@ -114,13 +114,13 @@ export declare class PuppeteerCrawler extends BrowserCrawler<{
|
|
|
114
114
|
}, LaunchOptions, PuppeteerCrawlContext> {
|
|
115
115
|
protected static optionsShape: {
|
|
116
116
|
browserPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
117
|
-
launchContext: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
118
117
|
handlePageFunction: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
|
|
119
118
|
gotoFunction: import("ow").Predicate<Function> & import("ow").BasePredicate<Function | undefined>;
|
|
120
119
|
gotoTimeoutSecs: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
121
120
|
navigationTimeoutSecs: import("ow").NumberPredicate & import("ow").BasePredicate<number | undefined>;
|
|
122
121
|
preNavigationHooks: import("ow").ArrayPredicate<unknown> & import("ow").BasePredicate<unknown[] | undefined>;
|
|
123
122
|
postNavigationHooks: import("ow").ArrayPredicate<unknown> & import("ow").BasePredicate<unknown[] | undefined>;
|
|
123
|
+
launchContext: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
124
124
|
sessionPoolOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
125
125
|
persistCookiesPerSession: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
126
126
|
useSessionPool: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer-crawler.d.ts","sourceRoot":"","sources":["../../src/internals/puppeteer-crawler.ts"],"names":[],"mappings":"AAAA,OAAO,EACH,cAAc,EACd,2BAA2B,EAC3B,qBAAqB,EACrB,sBAAsB,EACtB,WAAW,EACd,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EAAsB,eAAe,EAAE,MAAM,uBAAuB,CAAC;AAE5E,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,IAAI,EAAE,MAAM,WAA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,CAAC;IAErC;;;;;;;;;;;;;;OAcG;IACH,mBAAmB,CAAC,EAAE,aAAa,EAAE,CAAC;CACzC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4DG;AACH,qBAAa,gBAAiB,SAAQ,cAAc,CAAC;IAAE,cAAc,EAAE,CAAC,eAAe,CAAC,CAAA;CAAE,EAAE,aAAa,EAAE,qBAAqB,CAAC;IAC7H,iBAA0B,YAAY;;;;;;;;;;;;;;;;;;;;;;;;;;;MAGpC;IAEF;;OAEG;gBACS,OAAO,EAAE,uBAAuB;cAwBnB,kBAAkB,CAAC,eAAe,EAAE,qBAAqB,EAAE,WAAW,EAAE,uBAAuB;CAS3H"}
|
|
@@ -5,7 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const browser_1 = require("@crawlee/browser");
|
|
6
6
|
const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
7
7
|
const puppeteer_launcher_1 = require("./puppeteer-launcher");
|
|
8
|
-
const stealth_1 = require("./stealth");
|
|
9
8
|
const puppeteer_utils_1 = require("./utils/puppeteer_utils");
|
|
10
9
|
/**
|
|
11
10
|
* Provides a simple framework for parallel crawling of web pages
|
|
@@ -75,7 +74,6 @@ class PuppeteerCrawler extends browser_1.BrowserCrawler {
|
|
|
75
74
|
constructor(options) {
|
|
76
75
|
(0, ow_1.default)(options, 'PuppeteerCrawlerOptions', ow_1.default.object.exactShape(PuppeteerCrawler.optionsShape));
|
|
77
76
|
const { launchContext = {}, browserPoolOptions = {}, proxyConfiguration, ...browserCrawlerOptions } = options;
|
|
78
|
-
const { stealth = false } = launchContext;
|
|
79
77
|
if (launchContext.proxyUrl) {
|
|
80
78
|
throw new Error('PuppeteerCrawlerOptions.launchContext.proxyUrl is not allowed in PuppeteerCrawler.'
|
|
81
79
|
+ 'Use PuppeteerCrawlerOptions.proxyConfiguration');
|
|
@@ -84,18 +82,10 @@ class PuppeteerCrawler extends browser_1.BrowserCrawler {
|
|
|
84
82
|
browserPoolOptions.browserPlugins = [
|
|
85
83
|
puppeteerLauncher.createBrowserPlugin(),
|
|
86
84
|
];
|
|
87
|
-
super({ ...browserCrawlerOptions, proxyConfiguration, browserPoolOptions });
|
|
88
|
-
if (stealth) {
|
|
89
|
-
this.browserPool.postLaunchHooks.push(async (_pageId, browserController) => {
|
|
90
|
-
// TODO: We can do this better now. It is not necessary to override the page.
|
|
91
|
-
// we can modify the page in the postPageCreateHook
|
|
92
|
-
const { hideWebDriver, ...newStealthOptions } = puppeteerLauncher.stealthOptions;
|
|
93
|
-
(0, stealth_1.applyStealthToBrowser)(browserController.browser, newStealthOptions);
|
|
94
|
-
});
|
|
95
|
-
}
|
|
96
|
-
this.launchContext = launchContext;
|
|
85
|
+
super({ ...browserCrawlerOptions, launchContext, proxyConfiguration, browserPoolOptions });
|
|
97
86
|
}
|
|
98
87
|
async _navigationHandler(crawlingContext, gotoOptions) {
|
|
88
|
+
// TODO remove deprecated options in v3
|
|
99
89
|
if (this.gotoFunction) {
|
|
100
90
|
this.log.deprecated('PuppeteerCrawlerOptions.gotoFunction is deprecated. Use "preNavigationHooks" and "postNavigationHooks" instead.');
|
|
101
91
|
return this.gotoFunction(crawlingContext, gotoOptions);
|
|
@@ -111,7 +101,6 @@ Object.defineProperty(PuppeteerCrawler, "optionsShape", {
|
|
|
111
101
|
value: {
|
|
112
102
|
...browser_1.BrowserCrawler.optionsShape,
|
|
113
103
|
browserPoolOptions: ow_1.default.optional.object,
|
|
114
|
-
launchContext: ow_1.default.optional.object,
|
|
115
104
|
}
|
|
116
105
|
});
|
|
117
106
|
//# sourceMappingURL=puppeteer-crawler.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer-crawler.js","sourceRoot":"","sources":["../../src/internals/puppeteer-crawler.ts"],"names":[],"mappings":";;;;AAAA,8CAM0B;AAK1B,oDAAoB;AAEpB,6DAAiF;AACjF,
|
|
1
|
+
{"version":3,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AAW,CAAC,CAAC;IACpF,CAAC;;AAzCL,4CA0CC;AAzCG;;;;WAAyC;QACrC,GAAG,wBAAc,CAAC,YAAY;QAC9B,kBAAkB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KACzC;GAAC"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { Browser } from 'puppeteer';
|
|
2
2
|
import { PuppeteerPlugin } from '@crawlee/browser-pool';
|
|
3
3
|
import { BrowserLaunchContext, BrowserLauncher } from '@crawlee/browser';
|
|
4
|
-
import { StealthOptions } from './stealth';
|
|
5
4
|
/**
|
|
6
5
|
* Apify extends the launch options of Puppeteer.
|
|
7
6
|
* You can use any of the Puppeteer compatible
|
|
@@ -25,7 +24,7 @@ import { StealthOptions } from './stealth';
|
|
|
25
24
|
*/
|
|
26
25
|
export interface PuppeteerLaunchContext extends BrowserLaunchContext<PuppeteerPlugin['launchOptions'], unknown> {
|
|
27
26
|
/**
|
|
28
|
-
* `puppeteer.launch` [options](https://pptr.dev/#?product=Puppeteer&version=
|
|
27
|
+
* `puppeteer.launch` [options](https://pptr.dev/#?product=Puppeteer&version=v13.5.1&show=api-puppeteerlaunchoptions)
|
|
29
28
|
*/
|
|
30
29
|
launchOptions?: PuppeteerPlugin['launchOptions'];
|
|
31
30
|
/**
|
|
@@ -35,12 +34,6 @@ export interface PuppeteerLaunchContext extends BrowserLaunchContext<PuppeteerPl
|
|
|
35
34
|
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
36
35
|
*/
|
|
37
36
|
proxyUrl?: string;
|
|
38
|
-
/**
|
|
39
|
-
* The `User-Agent` HTTP header used by the browser.
|
|
40
|
-
* If not provided, the function sets `User-Agent` to a reasonable default
|
|
41
|
-
* to reduce the chance of detection of the crawler.
|
|
42
|
-
*/
|
|
43
|
-
userAgent?: string;
|
|
44
37
|
/**
|
|
45
38
|
* If `true` and `executablePath` is not set,
|
|
46
39
|
* Puppeteer will launch full Google Chrome browser available on the machine
|
|
@@ -60,15 +53,11 @@ export interface PuppeteerLaunchContext extends BrowserLaunchContext<PuppeteerPl
|
|
|
60
53
|
*/
|
|
61
54
|
launcher?: unknown;
|
|
62
55
|
/**
|
|
63
|
-
*
|
|
64
|
-
*
|
|
65
|
-
|
|
66
|
-
stealth?: boolean;
|
|
67
|
-
/**
|
|
68
|
-
* Using this configuration, you can disable some of the hiding tricks.
|
|
69
|
-
* For these settings to take effect `stealth` must be set to true
|
|
56
|
+
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
57
|
+
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
58
|
+
* @default false
|
|
70
59
|
*/
|
|
71
|
-
|
|
60
|
+
useIncognitoPages?: boolean;
|
|
72
61
|
}
|
|
73
62
|
/**
|
|
74
63
|
* `PuppeteerLauncher` is based on the `BrowserLauncher`. It launches `puppeteer` browser instance.
|
|
@@ -77,25 +66,17 @@ export interface PuppeteerLaunchContext extends BrowserLaunchContext<PuppeteerPl
|
|
|
77
66
|
export declare class PuppeteerLauncher extends BrowserLauncher<PuppeteerPlugin, unknown> {
|
|
78
67
|
protected static optionsShape: {
|
|
79
68
|
launcher: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
80
|
-
userAgent: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
81
|
-
stealth: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
82
|
-
stealthOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
83
69
|
proxyUrl: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
84
70
|
useChrome: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
85
71
|
useIncognitoPages: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
86
72
|
userDataDir: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
87
73
|
launchOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
74
|
+
userAgent: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
88
75
|
};
|
|
89
|
-
stealth?: boolean;
|
|
90
|
-
stealthOptions: StealthOptions;
|
|
91
76
|
/**
|
|
92
77
|
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
93
78
|
*/
|
|
94
79
|
constructor(launchContext?: PuppeteerLaunchContext);
|
|
95
|
-
launch(): Promise<import("packages/browser-pool/dist/puppeteer/puppeteer-proxy-per-page").Browser>;
|
|
96
|
-
createLaunchOptions(): {
|
|
97
|
-
args?: string[] | undefined;
|
|
98
|
-
} & import("packages/utils/dist").Dictionary<unknown>;
|
|
99
80
|
}
|
|
100
81
|
/**
|
|
101
82
|
* Launches headless Chrome using Puppeteer pre-configured to work within the Apify platform.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer-launcher.d.ts","sourceRoot":"","sources":["../../src/internals/puppeteer-launcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"puppeteer-launcher.d.ts","sourceRoot":"","sources":["../../src/internals/puppeteer-launcher.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAAE,eAAe,EAAE,MAAM,uBAAuB,CAAC;AACxD,OAAO,EAAE,oBAAoB,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAEzE;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,MAAM,WAAW,sBAAuB,SAAQ,oBAAoB,CAAC,eAAe,CAAC,eAAe,CAAC,EAAE,OAAO,CAAC;IAC3G;;OAEG;IACH,aAAa,CAAC,EAAE,eAAe,CAAC,eAAe,CAAC,CAAC;IAEjD;;;;;OAKG;IACH,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB;;;;;;;;OAQG;IACH,SAAS,CAAC,EAAE,OAAO,CAAC;IAEpB;;;;;;OAMG;IACH,QAAQ,CAAC,EAAE,OAAO,CAAC;IAEnB;;;;OAIG;IACH,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC/B;AAED;;;GAGG;AACH,qBAAa,iBAAkB,SAAQ,eAAe,CAAC,eAAe,EAAE,OAAO,CAAC;IAC5E,iBAA0B,YAAY;;;;;;;;MAGpC;IAEF;;OAEG;gBACS,aAAa,GAAE,sBAA2B;CAezD;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,wBAAsB,eAAe,CAAC,aAAa,CAAC,EAAE,sBAAsB,GAAG,OAAO,CAAC,OAAO,CAAC,CAI9F"}
|
|
@@ -5,16 +5,6 @@ const tslib_1 = require("tslib");
|
|
|
5
5
|
const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
6
6
|
const browser_pool_1 = require("@crawlee/browser-pool");
|
|
7
7
|
const browser_1 = require("@crawlee/browser");
|
|
8
|
-
const stealth_1 = require("./stealth");
|
|
9
|
-
/**
|
|
10
|
-
* The default user agent used by `Actor.launchPuppeteer`.
|
|
11
|
-
* Last updated on 2020-05-22.
|
|
12
|
-
*/
|
|
13
|
-
const DEFAULT_USER_AGENT = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.67 Safari/537.36';
|
|
14
|
-
const LAUNCH_PUPPETEER_DEFAULT_VIEWPORT = {
|
|
15
|
-
width: 1366,
|
|
16
|
-
height: 768,
|
|
17
|
-
};
|
|
18
8
|
/**
|
|
19
9
|
* `PuppeteerLauncher` is based on the `BrowserLauncher`. It launches `puppeteer` browser instance.
|
|
20
10
|
* @ignore
|
|
@@ -25,72 +15,13 @@ class PuppeteerLauncher extends browser_1.BrowserLauncher {
|
|
|
25
15
|
*/
|
|
26
16
|
constructor(launchContext = {}) {
|
|
27
17
|
(0, ow_1.default)(launchContext, 'PuppeteerLauncher', ow_1.default.object.exactShape(PuppeteerLauncher.optionsShape));
|
|
28
|
-
const { launcher = browser_1.BrowserLauncher.requireLauncherOrThrow('puppeteer', 'apify/actor-node-puppeteer-chrome'),
|
|
18
|
+
const { launcher = browser_1.BrowserLauncher.requireLauncherOrThrow('puppeteer', 'apify/actor-node-puppeteer-chrome'), ...browserLauncherOptions } = launchContext;
|
|
29
19
|
super({
|
|
30
20
|
...browserLauncherOptions,
|
|
31
21
|
launcher,
|
|
32
22
|
});
|
|
33
|
-
Object.defineProperty(this, "stealth", {
|
|
34
|
-
enumerable: true,
|
|
35
|
-
configurable: true,
|
|
36
|
-
writable: true,
|
|
37
|
-
value: void 0
|
|
38
|
-
});
|
|
39
|
-
Object.defineProperty(this, "stealthOptions", {
|
|
40
|
-
enumerable: true,
|
|
41
|
-
configurable: true,
|
|
42
|
-
writable: true,
|
|
43
|
-
value: void 0
|
|
44
|
-
});
|
|
45
|
-
this.userAgent = userAgent;
|
|
46
|
-
this.stealth = stealth;
|
|
47
|
-
this.stealthOptions = {
|
|
48
|
-
hideWebDriver: true,
|
|
49
|
-
...stealthOptions,
|
|
50
|
-
};
|
|
51
23
|
this.Plugin = browser_pool_1.PuppeteerPlugin;
|
|
52
24
|
}
|
|
53
|
-
async launch() {
|
|
54
|
-
const browser = await super.launch();
|
|
55
|
-
if (this.stealth) {
|
|
56
|
-
const { hideWebDriver, ...newStealthOptions } = this.stealthOptions;
|
|
57
|
-
(0, stealth_1.applyStealthToBrowser)(browser, newStealthOptions);
|
|
58
|
-
}
|
|
59
|
-
return browser;
|
|
60
|
-
}
|
|
61
|
-
createLaunchOptions() {
|
|
62
|
-
const launchOptions = super.createLaunchOptions();
|
|
63
|
-
launchOptions.args = launchOptions.args || [];
|
|
64
|
-
try {
|
|
65
|
-
// eslint-disable-next-line
|
|
66
|
-
const { isAtHome } = require('apify');
|
|
67
|
-
if (isAtHome())
|
|
68
|
-
launchOptions.args.push('--no-sandbox');
|
|
69
|
-
// eslint-disable-next-line no-empty
|
|
70
|
-
}
|
|
71
|
-
catch { }
|
|
72
|
-
launchOptions.defaultViewport ?? (launchOptions.defaultViewport = LAUNCH_PUPPETEER_DEFAULT_VIEWPORT);
|
|
73
|
-
// When User-Agent is not set and we're using Chromium or headless mode,
|
|
74
|
-
// it is better to use DEFAULT_USER_AGENT to reduce chance of detection
|
|
75
|
-
let { userAgent } = this;
|
|
76
|
-
if (!userAgent && (!launchOptions.executablePath || launchOptions.headless)) {
|
|
77
|
-
userAgent = DEFAULT_USER_AGENT;
|
|
78
|
-
}
|
|
79
|
-
if (userAgent) {
|
|
80
|
-
launchOptions.args.push(`--user-agent=${userAgent}`);
|
|
81
|
-
}
|
|
82
|
-
if (this.stealthOptions?.hideWebDriver) {
|
|
83
|
-
const idx = launchOptions.args.findIndex((arg) => arg.startsWith('--disable-blink-features='));
|
|
84
|
-
if (idx !== -1) {
|
|
85
|
-
const arg = launchOptions.args[idx];
|
|
86
|
-
launchOptions.args[idx] = `${arg},AutomationControlled`;
|
|
87
|
-
}
|
|
88
|
-
else {
|
|
89
|
-
launchOptions.args.push('--disable-blink-features=AutomationControlled');
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
return launchOptions;
|
|
93
|
-
}
|
|
94
25
|
}
|
|
95
26
|
exports.PuppeteerLauncher = PuppeteerLauncher;
|
|
96
27
|
Object.defineProperty(PuppeteerLauncher, "optionsShape", {
|
|
@@ -100,9 +31,6 @@ Object.defineProperty(PuppeteerLauncher, "optionsShape", {
|
|
|
100
31
|
value: {
|
|
101
32
|
...browser_1.BrowserLauncher.optionsShape,
|
|
102
33
|
launcher: ow_1.default.optional.object,
|
|
103
|
-
userAgent: ow_1.default.optional.string,
|
|
104
|
-
stealth: ow_1.default.optional.boolean,
|
|
105
|
-
stealthOptions: ow_1.default.optional.object,
|
|
106
34
|
}
|
|
107
35
|
});
|
|
108
36
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer-launcher.js","sourceRoot":"","sources":["../../src/internals/puppeteer-launcher.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AAEpB,wDAAwD;AACxD,8CAAyE;
|
|
1
|
+
{"version":3,"file":"puppeteer-launcher.js","sourceRoot":"","sources":["../../src/internals/puppeteer-launcher.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AAEpB,wDAAwD;AACxD,8CAAyE;AAiEzE;;;GAGG;AACH,MAAa,iBAAkB,SAAQ,yBAAyC;IAM5E;;OAEG;IACH,YAAY,gBAAwC,EAAE;QAClD,IAAA,YAAE,EAAC,aAAa,EAAE,mBAAmB,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC;QAE7F,MAAM,EACF,QAAQ,GAAG,yBAAe,CAAC,sBAAsB,CAAC,WAAW,EAAE,mCAAmC,CAAC,EACnG,GAAG,sBAAsB,EAC5B,GAAG,aAAa,CAAC;QAElB,KAAK,CAAC;YACF,GAAG,sBAAsB;YACzB,QAAQ;SACX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,8BAAe,CAAC;IAClC,CAAC;;AAvBL,8CAwBC;AAvBG;;;;WAAyC;QACrC,GAAG,yBAAe,CAAC,YAAY;QAC/B,QAAQ,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KAC/B;GAAC;AAsBN;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACI,KAAK,UAAU,eAAe,CAAC,aAAsC;IACxE,MAAM,iBAAiB,GAAG,IAAI,iBAAiB,CAAC,aAAa,CAAC,CAAC;IAE/D,OAAO,iBAAiB,CAAC,MAAM,EAAE,CAAC;AACtC,CAAC;AAJD,0CAIC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@crawlee/puppeteer",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
3
|
+
"version": "3.0.0-alpha.7",
|
|
4
4
|
"description": "The scalable web crawling and scraping library for JavaScript/Node.js. Enables development of data extraction and web automation jobs (not only) with headless Chrome and Puppeteer.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0.0"
|
|
@@ -50,7 +50,7 @@
|
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
52
|
"@apify/log": "^1.1.10",
|
|
53
|
-
"@crawlee/browser": "^3.0.0-alpha.
|
|
53
|
+
"@crawlee/browser": "^3.0.0-alpha.7"
|
|
54
54
|
},
|
|
55
55
|
"peerDependencies": {
|
|
56
56
|
"puppeteer": ">= 9.x <= 13.x"
|