apify 2.3.1-beta.4 → 3.0.0-alpha.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 +6 -5
- package/package.json +69 -128
- package/build/actor.d.ts +0 -113
- package/build/actor.d.ts.map +0 -1
- package/build/actor.js +0 -582
- package/build/actor.js.map +0 -1
- package/build/apify.d.ts +0 -752
- package/build/apify.d.ts.map +0 -1
- package/build/apify.js +0 -877
- package/build/apify.js.map +0 -1
- package/build/autoscaling/autoscaled_pool.d.ts +0 -384
- package/build/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/build/autoscaling/autoscaled_pool.js +0 -557
- package/build/autoscaling/autoscaled_pool.js.map +0 -1
- package/build/autoscaling/snapshotter.d.ts +0 -278
- package/build/autoscaling/snapshotter.d.ts.map +0 -1
- package/build/autoscaling/snapshotter.js +0 -447
- package/build/autoscaling/snapshotter.js.map +0 -1
- package/build/autoscaling/system_status.d.ts +0 -224
- package/build/autoscaling/system_status.d.ts.map +0 -1
- package/build/autoscaling/system_status.js +0 -228
- package/build/autoscaling/system_status.js.map +0 -1
- package/build/browser_launchers/browser_launcher.d.ts +0 -154
- package/build/browser_launchers/browser_launcher.d.ts.map +0 -1
- package/build/browser_launchers/browser_launcher.js +0 -160
- package/build/browser_launchers/browser_launcher.js.map +0 -1
- package/build/browser_launchers/browser_plugin.d.ts +0 -23
- package/build/browser_launchers/browser_plugin.d.ts.map +0 -1
- package/build/browser_launchers/browser_plugin.js +0 -25
- package/build/browser_launchers/browser_plugin.js.map +0 -1
- package/build/browser_launchers/playwright_launcher.d.ts +0 -131
- package/build/browser_launchers/playwright_launcher.d.ts.map +0 -1
- package/build/browser_launchers/playwright_launcher.js +0 -150
- package/build/browser_launchers/playwright_launcher.js.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.d.ts +0 -153
- package/build/browser_launchers/puppeteer_launcher.d.ts.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.js +0 -197
- package/build/browser_launchers/puppeteer_launcher.js.map +0 -1
- package/build/cache_container.d.ts +0 -31
- package/build/cache_container.d.ts.map +0 -1
- package/build/cache_container.js +0 -48
- package/build/cache_container.js.map +0 -1
- package/build/configuration.d.ts +0 -226
- package/build/configuration.d.ts.map +0 -1
- package/build/configuration.js +0 -325
- package/build/configuration.js.map +0 -1
- package/build/constants.d.ts +0 -37
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js +0 -41
- package/build/constants.js.map +0 -1
- package/build/crawlers/basic_crawler.d.ts +0 -443
- package/build/crawlers/basic_crawler.d.ts.map +0 -1
- package/build/crawlers/basic_crawler.js +0 -664
- package/build/crawlers/basic_crawler.js.map +0 -1
- package/build/crawlers/browser_crawler.d.ts +0 -512
- package/build/crawlers/browser_crawler.d.ts.map +0 -1
- package/build/crawlers/browser_crawler.js +0 -540
- package/build/crawlers/browser_crawler.js.map +0 -1
- package/build/crawlers/cheerio_crawler.d.ts +0 -931
- package/build/crawlers/cheerio_crawler.d.ts.map +0 -1
- package/build/crawlers/cheerio_crawler.js +0 -913
- package/build/crawlers/cheerio_crawler.js.map +0 -1
- package/build/crawlers/crawler_extension.d.ts +0 -10
- package/build/crawlers/crawler_extension.d.ts.map +0 -1
- package/build/crawlers/crawler_extension.js +0 -19
- package/build/crawlers/crawler_extension.js.map +0 -1
- package/build/crawlers/crawler_utils.d.ts +0 -34
- package/build/crawlers/crawler_utils.d.ts.map +0 -1
- package/build/crawlers/crawler_utils.js +0 -87
- package/build/crawlers/crawler_utils.js.map +0 -1
- package/build/crawlers/playwright_crawler.d.ts +0 -448
- package/build/crawlers/playwright_crawler.d.ts.map +0 -1
- package/build/crawlers/playwright_crawler.js +0 -299
- package/build/crawlers/playwright_crawler.js.map +0 -1
- package/build/crawlers/puppeteer_crawler.d.ts +0 -425
- package/build/crawlers/puppeteer_crawler.d.ts.map +0 -1
- package/build/crawlers/puppeteer_crawler.js +0 -299
- package/build/crawlers/puppeteer_crawler.js.map +0 -1
- package/build/crawlers/statistics.d.ts +0 -185
- package/build/crawlers/statistics.d.ts.map +0 -1
- package/build/crawlers/statistics.js +0 -331
- package/build/crawlers/statistics.js.map +0 -1
- package/build/enqueue_links/click_elements.d.ts +0 -179
- package/build/enqueue_links/click_elements.d.ts.map +0 -1
- package/build/enqueue_links/click_elements.js +0 -434
- package/build/enqueue_links/click_elements.js.map +0 -1
- package/build/enqueue_links/enqueue_links.d.ts +0 -117
- package/build/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/build/enqueue_links/enqueue_links.js +0 -163
- package/build/enqueue_links/enqueue_links.js.map +0 -1
- package/build/enqueue_links/shared.d.ts +0 -42
- package/build/enqueue_links/shared.d.ts.map +0 -1
- package/build/enqueue_links/shared.js +0 -121
- package/build/enqueue_links/shared.js.map +0 -1
- package/build/errors.d.ts +0 -29
- package/build/errors.d.ts.map +0 -1
- package/build/errors.js +0 -38
- package/build/errors.js.map +0 -1
- package/build/events.d.ts +0 -11
- package/build/events.d.ts.map +0 -1
- package/build/events.js +0 -147
- package/build/events.js.map +0 -1
- package/build/index.d.ts +0 -4
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -7
- package/build/index.js.map +0 -1
- package/build/main.d.ts +0 -179
- package/build/main.d.ts.map +0 -1
- package/build/main.js +0 -81
- package/build/main.js.map +0 -1
- package/build/playwright_utils.d.ts +0 -9
- package/build/playwright_utils.d.ts.map +0 -1
- package/build/playwright_utils.js +0 -90
- package/build/playwright_utils.js.map +0 -1
- package/build/proxy_configuration.d.ts +0 -411
- package/build/proxy_configuration.d.ts.map +0 -1
- package/build/proxy_configuration.js +0 -517
- package/build/proxy_configuration.js.map +0 -1
- package/build/pseudo_url.d.ts +0 -86
- package/build/pseudo_url.d.ts.map +0 -1
- package/build/pseudo_url.js +0 -153
- package/build/pseudo_url.js.map +0 -1
- package/build/puppeteer_request_interception.d.ts +0 -8
- package/build/puppeteer_request_interception.d.ts.map +0 -1
- package/build/puppeteer_request_interception.js +0 -235
- package/build/puppeteer_request_interception.js.map +0 -1
- package/build/puppeteer_utils.d.ts +0 -250
- package/build/puppeteer_utils.d.ts.map +0 -1
- package/build/puppeteer_utils.js +0 -551
- package/build/puppeteer_utils.js.map +0 -1
- package/build/request.d.ts +0 -180
- package/build/request.d.ts.map +0 -1
- package/build/request.js +0 -261
- package/build/request.js.map +0 -1
- package/build/request_list.d.ts +0 -581
- package/build/request_list.d.ts.map +0 -1
- package/build/request_list.js +0 -826
- package/build/request_list.js.map +0 -1
- package/build/serialization.d.ts +0 -5
- package/build/serialization.d.ts.map +0 -1
- package/build/serialization.js +0 -139
- package/build/serialization.js.map +0 -1
- package/build/session_pool/errors.d.ts +0 -11
- package/build/session_pool/errors.d.ts.map +0 -1
- package/build/session_pool/errors.js +0 -18
- package/build/session_pool/errors.js.map +0 -1
- package/build/session_pool/events.d.ts +0 -5
- package/build/session_pool/events.d.ts.map +0 -1
- package/build/session_pool/events.js +0 -6
- package/build/session_pool/events.js.map +0 -1
- package/build/session_pool/session.d.ts +0 -286
- package/build/session_pool/session.d.ts.map +0 -1
- package/build/session_pool/session.js +0 -355
- package/build/session_pool/session.js.map +0 -1
- package/build/session_pool/session_pool.d.ts +0 -280
- package/build/session_pool/session_pool.d.ts.map +0 -1
- package/build/session_pool/session_pool.js +0 -393
- package/build/session_pool/session_pool.js.map +0 -1
- package/build/session_pool/session_utils.d.ts +0 -4
- package/build/session_pool/session_utils.d.ts.map +0 -1
- package/build/session_pool/session_utils.js +0 -24
- package/build/session_pool/session_utils.js.map +0 -1
- package/build/stealth/hiding_tricks.d.ts +0 -22
- package/build/stealth/hiding_tricks.d.ts.map +0 -1
- package/build/stealth/hiding_tricks.js +0 -308
- package/build/stealth/hiding_tricks.js.map +0 -1
- package/build/stealth/stealth.d.ts +0 -56
- package/build/stealth/stealth.d.ts.map +0 -1
- package/build/stealth/stealth.js +0 -125
- package/build/stealth/stealth.js.map +0 -1
- package/build/storages/dataset.d.ts +0 -288
- package/build/storages/dataset.d.ts.map +0 -1
- package/build/storages/dataset.js +0 -480
- package/build/storages/dataset.js.map +0 -1
- package/build/storages/key_value_store.d.ts +0 -243
- package/build/storages/key_value_store.d.ts.map +0 -1
- package/build/storages/key_value_store.js +0 -462
- package/build/storages/key_value_store.js.map +0 -1
- package/build/storages/request_queue.d.ts +0 -318
- package/build/storages/request_queue.d.ts.map +0 -1
- package/build/storages/request_queue.js +0 -636
- package/build/storages/request_queue.js.map +0 -1
- package/build/storages/storage_manager.d.ts +0 -87
- package/build/storages/storage_manager.d.ts.map +0 -1
- package/build/storages/storage_manager.js +0 -150
- package/build/storages/storage_manager.js.map +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- package/build/typedefs.d.ts +0 -146
- package/build/typedefs.d.ts.map +0 -1
- package/build/typedefs.js +0 -88
- package/build/typedefs.js.map +0 -1
- package/build/utils.d.ts +0 -175
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -731
- package/build/utils.js.map +0 -1
- package/build/utils_log.d.ts +0 -41
- package/build/utils_log.d.ts.map +0 -1
- package/build/utils_log.js +0 -192
- package/build/utils_log.js.map +0 -1
- package/build/utils_request.d.ts +0 -77
- package/build/utils_request.d.ts.map +0 -1
- package/build/utils_request.js +0 -385
- package/build/utils_request.js.map +0 -1
- package/build/utils_social.d.ts +0 -210
- package/build/utils_social.d.ts.map +0 -1
- package/build/utils_social.js +0 -787
- package/build/utils_social.js.map +0 -1
- package/build/validators.d.ts +0 -23
- package/build/validators.d.ts.map +0 -1
- package/build/validators.js +0 -29
- package/build/validators.js.map +0 -1
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Apify extends the launch options of Playwright.
|
|
3
|
-
* You can use any of the Playwright compatible
|
|
4
|
-
* [`LaunchOptions`](https://playwright.dev/docs/api/class-browsertype#browsertypelaunchoptions)
|
|
5
|
-
* options by providing the `launchOptions` property.
|
|
6
|
-
*
|
|
7
|
-
* **Example:**
|
|
8
|
-
* ```js
|
|
9
|
-
* // launch a headless Chrome (not Chromium)
|
|
10
|
-
* const launchContext = {
|
|
11
|
-
* // Apify helpers
|
|
12
|
-
* useChrome: true,
|
|
13
|
-
* proxyUrl: 'http://user:password@some.proxy.com'
|
|
14
|
-
* // Native Playwright options
|
|
15
|
-
* launchOptions: {
|
|
16
|
-
* headless: true,
|
|
17
|
-
* args: ['--some-flag'],
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @typedef PlaywrightLaunchContext
|
|
23
|
-
* @property {LaunchOptions} [launchOptions]
|
|
24
|
-
* `browserType.launch` [options](https://playwright.dev/docs/api/class-browsertype#browser-type-launch)
|
|
25
|
-
* @property {string} [proxyUrl]
|
|
26
|
-
* URL to a HTTP proxy server. It must define the port number,
|
|
27
|
-
* and it may also contain proxy username and password.
|
|
28
|
-
*
|
|
29
|
-
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
30
|
-
* @property {boolean} [useChrome=false]
|
|
31
|
-
* If `true` and `executablePath` is not set,
|
|
32
|
-
* Playwright will launch full Google Chrome browser available on the machine
|
|
33
|
-
* rather than the bundled Chromium. The path to Chrome executable
|
|
34
|
-
* is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
|
|
35
|
-
* or defaults to the typical Google Chrome executable location specific for the operating system.
|
|
36
|
-
* @property {boolean} [useIncognitoPages=false]
|
|
37
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
38
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
39
|
-
* @property {string} [userDataDir]
|
|
40
|
-
* Sets the [User Data Directory](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md) path.
|
|
41
|
-
* The user data directory contains profile data such as history, bookmarks, and cookies, as well as other per-installation local state.
|
|
42
|
-
* If not specified, a temporary directory is used instead.
|
|
43
|
-
* @property {*} [launcher]
|
|
44
|
-
// @ts-ignore optional peer dependency
|
|
45
|
-
* By default this function uses `require("playwright").chromium`.
|
|
46
|
-
// @ts-ignore optional peer dependency
|
|
47
|
-
* If you want to use a different browser you can pass it by this property as e.g. `require("playwright").firefox`
|
|
48
|
-
*/
|
|
49
|
-
/**
|
|
50
|
-
* `PlaywrightLauncher` is based on the `BrowserLauncher`. It launches `playwright` browser instance.
|
|
51
|
-
* @ignore
|
|
52
|
-
*/
|
|
53
|
-
export class PlaywrightLauncher extends BrowserLauncher {
|
|
54
|
-
static optionsShape: {
|
|
55
|
-
launcher: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
56
|
-
proxyUrl: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
57
|
-
useChrome: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
58
|
-
useIncognitoPages: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
59
|
-
userDataDir: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
60
|
-
launchOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* @param {PlaywrightLaunchContext} launchContext
|
|
64
|
-
* All `PlaywrightLauncher` parameters are passed via this launchContext object.
|
|
65
|
-
*/
|
|
66
|
-
constructor(launchContext?: PlaywrightLaunchContext);
|
|
67
|
-
}
|
|
68
|
-
export function launchPlaywright(launchContext?: PlaywrightLaunchContext | undefined): Promise<any>;
|
|
69
|
-
/**
|
|
70
|
-
* Apify extends the launch options of Playwright.
|
|
71
|
-
* You can use any of the Playwright compatible
|
|
72
|
-
* [`LaunchOptions`](https://playwright.dev/docs/api/class-browsertype#browsertypelaunchoptions)
|
|
73
|
-
* options by providing the `launchOptions` property.
|
|
74
|
-
*
|
|
75
|
-
* **Example:**
|
|
76
|
-
* ```js
|
|
77
|
-
* // launch a headless Chrome (not Chromium)
|
|
78
|
-
* const launchContext = {
|
|
79
|
-
* // Apify helpers
|
|
80
|
-
* useChrome: true,
|
|
81
|
-
* proxyUrl: 'http://user:password@some.proxy.com'
|
|
82
|
-
* // Native Playwright options
|
|
83
|
-
* launchOptions: {
|
|
84
|
-
* headless: true,
|
|
85
|
-
* args: ['--some-flag'],
|
|
86
|
-
* }
|
|
87
|
-
* }
|
|
88
|
-
* ```
|
|
89
|
-
*/
|
|
90
|
-
export type PlaywrightLaunchContext = {
|
|
91
|
-
/**
|
|
92
|
-
* `browserType.launch` [options](https://playwright.dev/docs/api/class-browsertype#browser-type-launch)
|
|
93
|
-
*/
|
|
94
|
-
launchOptions?: LaunchOptions | undefined;
|
|
95
|
-
/**
|
|
96
|
-
* URL to a HTTP proxy server. It must define the port number,
|
|
97
|
-
* and it may also contain proxy username and password.
|
|
98
|
-
*
|
|
99
|
-
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
100
|
-
*/
|
|
101
|
-
proxyUrl?: string | undefined;
|
|
102
|
-
/**
|
|
103
|
-
* If `true` and `executablePath` is not set,
|
|
104
|
-
* Playwright will launch full Google Chrome browser available on the machine
|
|
105
|
-
* rather than the bundled Chromium. The path to Chrome executable
|
|
106
|
-
* is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
|
|
107
|
-
* or defaults to the typical Google Chrome executable location specific for the operating system.
|
|
108
|
-
*/
|
|
109
|
-
useChrome?: boolean | undefined;
|
|
110
|
-
/**
|
|
111
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
112
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
113
|
-
*/
|
|
114
|
-
useIncognitoPages?: boolean | undefined;
|
|
115
|
-
/**
|
|
116
|
-
* Sets the [User Data Directory](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md) path.
|
|
117
|
-
* The user data directory contains profile data such as history, bookmarks, and cookies, as well as other per-installation local state.
|
|
118
|
-
* If not specified, a temporary directory is used instead.
|
|
119
|
-
*/
|
|
120
|
-
userDataDir?: string | undefined;
|
|
121
|
-
/**
|
|
122
|
-
// @ts-ignore optional peer dependency
|
|
123
|
-
* By default this function uses `require("playwright").chromium`.
|
|
124
|
-
// @ts-ignore optional peer dependency
|
|
125
|
-
* If you want to use a different browser you can pass it by this property as e.g. `require("playwright").firefox`
|
|
126
|
-
*/
|
|
127
|
-
launcher?: any;
|
|
128
|
-
};
|
|
129
|
-
import BrowserLauncher from "./browser_launcher";
|
|
130
|
-
import { LaunchOptions } from "playwright-core";
|
|
131
|
-
//# sourceMappingURL=playwright_launcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playwright_launcher.d.ts","sourceRoot":"","sources":["../../src/browser_launchers/playwright_launcher.js"],"names":[],"mappings":"AAKA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH;;;GAGG;AACH;IACI;;;;;;;MAGE;IAEF;;;MAGE;IACF,4BAHU,uBAAuB,EAsBhC;CACJ;AA+DM,uFANM,YAAU,CAUtB"}
|
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.launchPlaywright = exports.PlaywrightLauncher = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const ow_1 = (0, tslib_1.__importDefault)(require("ow"));
|
|
6
|
-
const browser_pool_1 = require("browser-pool");
|
|
7
|
-
const browser_launcher_1 = (0, tslib_1.__importDefault)(require("./browser_launcher"));
|
|
8
|
-
/**
|
|
9
|
-
* Apify extends the launch options of Playwright.
|
|
10
|
-
* You can use any of the Playwright compatible
|
|
11
|
-
* [`LaunchOptions`](https://playwright.dev/docs/api/class-browsertype#browsertypelaunchoptions)
|
|
12
|
-
* options by providing the `launchOptions` property.
|
|
13
|
-
*
|
|
14
|
-
* **Example:**
|
|
15
|
-
* ```js
|
|
16
|
-
* // launch a headless Chrome (not Chromium)
|
|
17
|
-
* const launchContext = {
|
|
18
|
-
* // Apify helpers
|
|
19
|
-
* useChrome: true,
|
|
20
|
-
* proxyUrl: 'http://user:password@some.proxy.com'
|
|
21
|
-
* // Native Playwright options
|
|
22
|
-
* launchOptions: {
|
|
23
|
-
* headless: true,
|
|
24
|
-
* args: ['--some-flag'],
|
|
25
|
-
* }
|
|
26
|
-
* }
|
|
27
|
-
* ```
|
|
28
|
-
*
|
|
29
|
-
* @typedef PlaywrightLaunchContext
|
|
30
|
-
* @property {LaunchOptions} [launchOptions]
|
|
31
|
-
* `browserType.launch` [options](https://playwright.dev/docs/api/class-browsertype#browser-type-launch)
|
|
32
|
-
* @property {string} [proxyUrl]
|
|
33
|
-
* URL to a HTTP proxy server. It must define the port number,
|
|
34
|
-
* and it may also contain proxy username and password.
|
|
35
|
-
*
|
|
36
|
-
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
37
|
-
* @property {boolean} [useChrome=false]
|
|
38
|
-
* If `true` and `executablePath` is not set,
|
|
39
|
-
* Playwright will launch full Google Chrome browser available on the machine
|
|
40
|
-
* rather than the bundled Chromium. The path to Chrome executable
|
|
41
|
-
* is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
|
|
42
|
-
* or defaults to the typical Google Chrome executable location specific for the operating system.
|
|
43
|
-
* @property {boolean} [useIncognitoPages=false]
|
|
44
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
45
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
46
|
-
* @property {string} [userDataDir]
|
|
47
|
-
* Sets the [User Data Directory](https://chromium.googlesource.com/chromium/src/+/master/docs/user_data_dir.md) path.
|
|
48
|
-
* The user data directory contains profile data such as history, bookmarks, and cookies, as well as other per-installation local state.
|
|
49
|
-
* If not specified, a temporary directory is used instead.
|
|
50
|
-
* @property {*} [launcher]
|
|
51
|
-
* By default this function uses `require("playwright").chromium`.
|
|
52
|
-
* If you want to use a different browser you can pass it by this property as e.g. `require("playwright").firefox`
|
|
53
|
-
*/
|
|
54
|
-
/**
|
|
55
|
-
* `PlaywrightLauncher` is based on the `BrowserLauncher`. It launches `playwright` browser instance.
|
|
56
|
-
* @ignore
|
|
57
|
-
*/
|
|
58
|
-
class PlaywrightLauncher extends browser_launcher_1.default {
|
|
59
|
-
/**
|
|
60
|
-
* @param {PlaywrightLaunchContext} launchContext
|
|
61
|
-
* All `PlaywrightLauncher` parameters are passed via this launchContext object.
|
|
62
|
-
*/
|
|
63
|
-
constructor(launchContext = {}) {
|
|
64
|
-
(0, ow_1.default)(launchContext, 'PlaywrightLauncherOptions', ow_1.default.object.exactShape(PlaywrightLauncher.optionsShape));
|
|
65
|
-
const { launcher = browser_launcher_1.default.requireLauncherOrThrow('playwright', 'apify/actor-node-playwright-*').chromium, } = launchContext;
|
|
66
|
-
const { launchOptions = {}, ...rest } = launchContext;
|
|
67
|
-
super({
|
|
68
|
-
...rest,
|
|
69
|
-
launchOptions: {
|
|
70
|
-
...launchOptions,
|
|
71
|
-
executablePath: getDefaultExecutablePath(launchContext),
|
|
72
|
-
},
|
|
73
|
-
launcher,
|
|
74
|
-
});
|
|
75
|
-
this.Plugin = browser_pool_1.PlaywrightPlugin;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
exports.PlaywrightLauncher = PlaywrightLauncher;
|
|
79
|
-
Object.defineProperty(PlaywrightLauncher, "optionsShape", {
|
|
80
|
-
enumerable: true,
|
|
81
|
-
configurable: true,
|
|
82
|
-
writable: true,
|
|
83
|
-
value: {
|
|
84
|
-
...browser_launcher_1.default.optionsShape,
|
|
85
|
-
launcher: ow_1.default.optional.object,
|
|
86
|
-
}
|
|
87
|
-
});
|
|
88
|
-
/**
|
|
89
|
-
* @param {PlaywrightLaunchContext} launchContext
|
|
90
|
-
* @returns {string|undefined} default path to browser.
|
|
91
|
-
* If actor-node-playwright-* image is used the APIFY_DEFAULT_BROWSER_PATH is considered as default.
|
|
92
|
-
* @ignore
|
|
93
|
-
*/
|
|
94
|
-
function getDefaultExecutablePath(launchContext) {
|
|
95
|
-
const pathFromPlaywrightImage = process.env.APIFY_DEFAULT_BROWSER_PATH;
|
|
96
|
-
const { launchOptions = {} } = launchContext;
|
|
97
|
-
if (launchOptions.executablePath) {
|
|
98
|
-
return launchOptions.executablePath;
|
|
99
|
-
}
|
|
100
|
-
if (launchContext.useChrome) {
|
|
101
|
-
return;
|
|
102
|
-
}
|
|
103
|
-
if (pathFromPlaywrightImage) {
|
|
104
|
-
return pathFromPlaywrightImage;
|
|
105
|
-
}
|
|
106
|
-
}
|
|
107
|
-
/**
|
|
108
|
-
* Launches headless browsers using Playwright pre-configured to work within the Apify platform.
|
|
109
|
-
* The function has the same return value as `browserType.launch()`.
|
|
110
|
-
* See <a href="https://playwright.dev/docs/api/class-browsertype" target="_blank">
|
|
111
|
-
* Playwright documentation</a> for more details.
|
|
112
|
-
*
|
|
113
|
-
* The `launchPlaywright()` function alters the following Playwright options:
|
|
114
|
-
*
|
|
115
|
-
* - Passes the setting from the `APIFY_HEADLESS` environment variable to the `headless` option,
|
|
116
|
-
* unless it was already defined by the caller or `APIFY_XVFB` environment variable is set to `1`.
|
|
117
|
-
* Note that Apify Actor cloud platform automatically sets `APIFY_HEADLESS=1` to all running actors.
|
|
118
|
-
* - Takes the `proxyUrl` option, validates it and adds it to `launchOptions` in a proper format.
|
|
119
|
-
* The proxy URL must define a port number and have one of the following schemes: `http://`,
|
|
120
|
-
* `https://`, `socks4://` or `socks5://`.
|
|
121
|
-
* If the proxy is HTTP (i.e. has the `http://` scheme) and contains username or password,
|
|
122
|
-
* the `launchPlaywright` functions sets up an anonymous proxy HTTP
|
|
123
|
-
* to make the proxy work with headless Chrome. For more information, read the
|
|
124
|
-
* <a href="https://blog.apify.com/how-to-make-headless-chrome-and-puppeteer-use-a-proxy-server-with-authentication-249a21a79212"
|
|
125
|
-
* target="_blank">blog post about proxy-chain library</a>.
|
|
126
|
-
*
|
|
127
|
-
* To use this function, you need to have the [Playwright](https://www.npmjs.com/package/playwright)
|
|
128
|
-
* NPM package installed in your project.
|
|
129
|
-
* When running on the Apify Platform, you can achieve that simply
|
|
130
|
-
* by using the `apify/actor-node-playwright-*` base Docker image for your actor - see
|
|
131
|
-
* [Apify Actor documentation](https://docs.apify.com/actor/build#base-images)
|
|
132
|
-
* for details.
|
|
133
|
-
*
|
|
134
|
-
*
|
|
135
|
-
* @param {PlaywrightLaunchContext} [launchContext]
|
|
136
|
-
* Optional settings passed to `browserType.launch()`. In addition to
|
|
137
|
-
* [Playwright's options](https://playwright.dev/docs/api/class-browsertype?_highlight=launch#browsertypelaunchoptions)
|
|
138
|
-
* the object may contain our own {@link PlaywrightLaunchContext} that enable additional features.
|
|
139
|
-
* @returns {Promise<*>}
|
|
140
|
-
* Promise that resolves to Playwright's `Browser` instance.
|
|
141
|
-
* @memberof module:Apify
|
|
142
|
-
* @name launchPlaywright
|
|
143
|
-
* @function
|
|
144
|
-
*/
|
|
145
|
-
const launchPlaywright = async (launchContext) => {
|
|
146
|
-
const playwrightLauncher = new PlaywrightLauncher(launchContext);
|
|
147
|
-
return playwrightLauncher.launch();
|
|
148
|
-
};
|
|
149
|
-
exports.launchPlaywright = launchPlaywright;
|
|
150
|
-
//# sourceMappingURL=playwright_launcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"playwright_launcher.js","sourceRoot":"","sources":["../../src/browser_launchers/playwright_launcher.js"],"names":[],"mappings":";;;;AAAA,yDAAoB;AAEpB,+CAAgD;AAChD,uFAAiD;AAEjD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6CG;AAEH;;;GAGG;AACH,MAAa,kBAAmB,SAAQ,0BAAe;IAMnD;;;MAGE;IACF,YAAY,aAAa,GAAG,EAAE;QAC1B,IAAA,YAAE,EAAC,aAAa,EAAE,2BAA2B,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,kBAAkB,CAAC,YAAY,CAAC,CAAC,CAAC;QAEtG,MAAM,EACF,QAAQ,GAAG,0BAAe,CAAC,sBAAsB,CAAC,YAAY,EAAE,+BAA+B,CAAC,CAAC,QAAQ,GAC5G,GAAG,aAAa,CAAC;QAElB,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,IAAI,EAAE,GAAG,aAAa,CAAC;QAEtD,KAAK,CAAC;YACF,GAAG,IAAI;YACP,aAAa,EAAE;gBACX,GAAG,aAAa;gBAChB,cAAc,EAAE,wBAAwB,CAAC,aAAa,CAAC;aAC1D;YACD,QAAQ;SACX,CAAC,CAAC;QAEH,IAAI,CAAC,MAAM,GAAG,+BAAgB,CAAC;IACnC,CAAC;;AA7BL,gDA8BC;AA7BU;;;;WAAe;QAClB,GAAG,0BAAe,CAAC,YAAY;QAC/B,QAAQ,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KAC/B;GAAC;AA4BN;;;;;GAKG;AACH,SAAS,wBAAwB,CAAC,aAAa;IAC3C,MAAM,uBAAuB,GAAG,OAAO,CAAC,GAAG,CAAC,0BAA0B,CAAC;IACvE,MAAM,EAAE,aAAa,GAAG,EAAE,EAAE,GAAG,aAAa,CAAC;IAE7C,IAAI,aAAa,CAAC,cAAc,EAAE;QAC9B,OAAO,aAAa,CAAC,cAAc,CAAC;KACvC;IAED,IAAI,aAAa,CAAC,SAAS,EAAE;QACzB,OAAO;KACV;IAED,IAAI,uBAAuB,EAAE;QACzB,OAAO,uBAAuB,CAAC;KAClC;AACL,CAAC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACI,MAAM,gBAAgB,GAAG,KAAK,EAAE,aAAa,EAAE,EAAE;IACpD,MAAM,kBAAkB,GAAG,IAAI,kBAAkB,CAAC,aAAa,CAAC,CAAC;IAEjE,OAAO,kBAAkB,CAAC,MAAM,EAAE,CAAC;AACvC,CAAC,CAAC;AAJW,QAAA,gBAAgB,oBAI3B"}
|
|
@@ -1,153 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Apify extends the launch options of Puppeteer.
|
|
3
|
-
* You can use any of the Puppeteer compatible
|
|
4
|
-
* [`LaunchOptions`](https://pptr.dev/#?product=Puppeteer&show=api-puppeteerlaunchoptions)
|
|
5
|
-
* options by providing the `launchOptions` property.
|
|
6
|
-
*
|
|
7
|
-
* **Example:**
|
|
8
|
-
* ```js
|
|
9
|
-
* // launch a headless Chrome (not Chromium)
|
|
10
|
-
* const launchContext = {
|
|
11
|
-
* // Apify helpers
|
|
12
|
-
* useChrome: true,
|
|
13
|
-
* proxyUrl: 'http://user:password@some.proxy.com'
|
|
14
|
-
* // Native Puppeteer options
|
|
15
|
-
* launchOptions: {
|
|
16
|
-
* headless: true,
|
|
17
|
-
* args: ['--some-flag'],
|
|
18
|
-
* }
|
|
19
|
-
* }
|
|
20
|
-
* ```
|
|
21
|
-
*
|
|
22
|
-
* @typedef PuppeteerLaunchContext
|
|
23
|
-
* @property {Parameters<PuppeteerNode['launch']>[0]} [launchOptions]
|
|
24
|
-
* `puppeteer.launch` [options](https://pptr.dev/#?product=Puppeteer&version=v13.5.1&show=api-puppeteerlaunchoptions)
|
|
25
|
-
* @property {string} [proxyUrl]
|
|
26
|
-
* URL to a HTTP proxy server. It must define the port number,
|
|
27
|
-
* and it may also contain proxy username and password.
|
|
28
|
-
*
|
|
29
|
-
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
30
|
-
* @property {string} [userAgent]
|
|
31
|
-
* The `User-Agent` HTTP header used by the browser.
|
|
32
|
-
* If not provided, the function sets `User-Agent` to a reasonable default
|
|
33
|
-
* to reduce the chance of detection of the crawler.
|
|
34
|
-
* @property {boolean} [useChrome=false]
|
|
35
|
-
* If `true` and `executablePath` is not set,
|
|
36
|
-
* Puppeteer will launch full Google Chrome browser available on the machine
|
|
37
|
-
* rather than the bundled Chromium. The path to Chrome executable
|
|
38
|
-
* is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
|
|
39
|
-
* or defaults to the typical Google Chrome executable location specific for the operating system.
|
|
40
|
-
* By default, this option is `false`.
|
|
41
|
-
* @property {*} [launcher]
|
|
42
|
-
* Already required module (`Object`). This enables usage of various Puppeteer
|
|
43
|
-
* wrappers such as `puppeteer-extra`.
|
|
44
|
-
*
|
|
45
|
-
* Take caution, because it can cause all kinds of unexpected errors and weird behavior.
|
|
46
|
-
* Apify SDK is not tested with any other library besides `puppeteer` itself.
|
|
47
|
-
* @property {boolean} [useIncognitoPages=false]
|
|
48
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
49
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
50
|
-
* @property {boolean} [stealth]
|
|
51
|
-
* @deprecated
|
|
52
|
-
* This setting hides most of the known properties that identify headless Chrome and makes it nearly undetectable.
|
|
53
|
-
* It is recommended to use it together with the `useChrome` set to `true`.
|
|
54
|
-
* @property {StealthOptions} [stealthOptions]
|
|
55
|
-
* @deprecated
|
|
56
|
-
* Using this configuration, you can disable some of the hiding tricks.
|
|
57
|
-
* For these settings to take effect `stealth` must be set to true
|
|
58
|
-
*/
|
|
59
|
-
/**
|
|
60
|
-
* `PuppeteerLauncher` is based on the `BrowserLauncher`. It launches `puppeteer` browser instance.
|
|
61
|
-
* @ignore
|
|
62
|
-
*/
|
|
63
|
-
export class PuppeteerLauncher extends BrowserLauncher {
|
|
64
|
-
static optionsShape: {
|
|
65
|
-
launcher: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
66
|
-
userAgent: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
67
|
-
stealth: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
68
|
-
stealthOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
69
|
-
proxyUrl: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
70
|
-
useChrome: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
71
|
-
useIncognitoPages: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
|
72
|
-
userDataDir: import("ow").StringPredicate & import("ow").BasePredicate<string | undefined>;
|
|
73
|
-
launchOptions: import("ow").ObjectPredicate<object> & import("ow").BasePredicate<object | undefined>;
|
|
74
|
-
};
|
|
75
|
-
/**
|
|
76
|
-
* @param {PuppeteerLaunchContext} launchContext
|
|
77
|
-
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
78
|
-
*/
|
|
79
|
-
constructor(launchContext?: PuppeteerLaunchContext);
|
|
80
|
-
userAgent: string | undefined;
|
|
81
|
-
stealth: boolean;
|
|
82
|
-
/** @type {StealthOptions} */
|
|
83
|
-
stealthOptions: StealthOptions;
|
|
84
|
-
}
|
|
85
|
-
export function launchPuppeteer(launchContext?: PuppeteerLaunchContext | undefined): Promise<any>;
|
|
86
|
-
/**
|
|
87
|
-
* Apify extends the launch options of Puppeteer.
|
|
88
|
-
* You can use any of the Puppeteer compatible
|
|
89
|
-
* [`LaunchOptions`](https://pptr.dev/#?product=Puppeteer&show=api-puppeteerlaunchoptions)
|
|
90
|
-
* options by providing the `launchOptions` property.
|
|
91
|
-
*
|
|
92
|
-
* **Example:**
|
|
93
|
-
* ```js
|
|
94
|
-
* // launch a headless Chrome (not Chromium)
|
|
95
|
-
* const launchContext = {
|
|
96
|
-
* // Apify helpers
|
|
97
|
-
* useChrome: true,
|
|
98
|
-
* proxyUrl: 'http://user:password@some.proxy.com'
|
|
99
|
-
* // Native Puppeteer options
|
|
100
|
-
* launchOptions: {
|
|
101
|
-
* headless: true,
|
|
102
|
-
* args: ['--some-flag'],
|
|
103
|
-
* }
|
|
104
|
-
* }
|
|
105
|
-
* ```
|
|
106
|
-
*/
|
|
107
|
-
export type PuppeteerLaunchContext = {
|
|
108
|
-
/**
|
|
109
|
-
* `puppeteer.launch` [options](https://pptr.dev/#?product=Puppeteer&version=v13.5.1&show=api-puppeteerlaunchoptions)
|
|
110
|
-
*/
|
|
111
|
-
launchOptions?: Parameters<PuppeteerNode['launch']>[0];
|
|
112
|
-
/**
|
|
113
|
-
* URL to a HTTP proxy server. It must define the port number,
|
|
114
|
-
* and it may also contain proxy username and password.
|
|
115
|
-
*
|
|
116
|
-
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
117
|
-
*/
|
|
118
|
-
proxyUrl?: string | undefined;
|
|
119
|
-
/**
|
|
120
|
-
* The `User-Agent` HTTP header used by the browser.
|
|
121
|
-
* If not provided, the function sets `User-Agent` to a reasonable default
|
|
122
|
-
* to reduce the chance of detection of the crawler.
|
|
123
|
-
*/
|
|
124
|
-
userAgent?: string | undefined;
|
|
125
|
-
/**
|
|
126
|
-
* If `true` and `executablePath` is not set,
|
|
127
|
-
* Puppeteer will launch full Google Chrome browser available on the machine
|
|
128
|
-
* rather than the bundled Chromium. The path to Chrome executable
|
|
129
|
-
* is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
|
|
130
|
-
* or defaults to the typical Google Chrome executable location specific for the operating system.
|
|
131
|
-
* By default, this option is `false`.
|
|
132
|
-
*/
|
|
133
|
-
useChrome?: boolean | undefined;
|
|
134
|
-
/**
|
|
135
|
-
* Already required module (`Object`). This enables usage of various Puppeteer
|
|
136
|
-
* wrappers such as `puppeteer-extra`.
|
|
137
|
-
*
|
|
138
|
-
* Take caution, because it can cause all kinds of unexpected errors and weird behavior.
|
|
139
|
-
* Apify SDK is not tested with any other library besides `puppeteer` itself.
|
|
140
|
-
*/
|
|
141
|
-
launcher?: any;
|
|
142
|
-
/**
|
|
143
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
144
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
145
|
-
*/
|
|
146
|
-
useIncognitoPages?: boolean | undefined;
|
|
147
|
-
stealth?: boolean | undefined;
|
|
148
|
-
};
|
|
149
|
-
import BrowserLauncher from "./browser_launcher";
|
|
150
|
-
import { StealthOptions } from "../stealth/stealth";
|
|
151
|
-
// @ts-ignore optional peer dependency
|
|
152
|
-
import { PuppeteerNode } from "puppeteer";
|
|
153
|
-
//# sourceMappingURL=puppeteer_launcher.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer_launcher.d.ts","sourceRoot":"","sources":["../../src/browser_launchers/puppeteer_launcher.js"],"names":[],"mappings":"AAeA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAyDG;AAEH;;;GAGG;AACH;IACI;;;;;;;;;;MAME;IAEF;;;MAGE;IACF,4BAHU,sBAAsB,EA2B/B;IATG,8BAA0B;IAC1B,iBAAsB;IACtB,6BAA6B;IAC7B,gBADW,cAAc,CAIxB;CAsDR;AAyCM,qFANM,YAAU,CAUtB;;;;;;;;;;;;;;;;;;;;;;;;;;oBA9Ka,WAAW,aAAa,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC"}
|
|
@@ -1,197 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.launchPuppeteer = exports.PuppeteerLauncher = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const ow_1 = (0, tslib_1.__importDefault)(require("ow"));
|
|
6
|
-
const browser_pool_1 = require("browser-pool");
|
|
7
|
-
const browser_launcher_1 = (0, tslib_1.__importDefault)(require("./browser_launcher"));
|
|
8
|
-
const utils_1 = require("../utils");
|
|
9
|
-
const utils_log_1 = (0, tslib_1.__importDefault)(require("../utils_log"));
|
|
10
|
-
const constants_1 = require("../constants");
|
|
11
|
-
const stealth_1 = (0, tslib_1.__importDefault)(require("../stealth/stealth")); // eslint-disable-line no-unused-vars,import/named
|
|
12
|
-
const LAUNCH_PUPPETEER_DEFAULT_VIEWPORT = {
|
|
13
|
-
width: 1366,
|
|
14
|
-
height: 768,
|
|
15
|
-
};
|
|
16
|
-
/**
|
|
17
|
-
* Apify extends the launch options of Puppeteer.
|
|
18
|
-
* You can use any of the Puppeteer compatible
|
|
19
|
-
* [`LaunchOptions`](https://pptr.dev/#?product=Puppeteer&show=api-puppeteerlaunchoptions)
|
|
20
|
-
* options by providing the `launchOptions` property.
|
|
21
|
-
*
|
|
22
|
-
* **Example:**
|
|
23
|
-
* ```js
|
|
24
|
-
* // launch a headless Chrome (not Chromium)
|
|
25
|
-
* const launchContext = {
|
|
26
|
-
* // Apify helpers
|
|
27
|
-
* useChrome: true,
|
|
28
|
-
* proxyUrl: 'http://user:password@some.proxy.com'
|
|
29
|
-
* // Native Puppeteer options
|
|
30
|
-
* launchOptions: {
|
|
31
|
-
* headless: true,
|
|
32
|
-
* args: ['--some-flag'],
|
|
33
|
-
* }
|
|
34
|
-
* }
|
|
35
|
-
* ```
|
|
36
|
-
*
|
|
37
|
-
* @typedef PuppeteerLaunchContext
|
|
38
|
-
* @property {Parameters<PuppeteerNode['launch']>[0]} [launchOptions]
|
|
39
|
-
* `puppeteer.launch` [options](https://pptr.dev/#?product=Puppeteer&version=v13.5.1&show=api-puppeteerlaunchoptions)
|
|
40
|
-
* @property {string} [proxyUrl]
|
|
41
|
-
* URL to a HTTP proxy server. It must define the port number,
|
|
42
|
-
* and it may also contain proxy username and password.
|
|
43
|
-
*
|
|
44
|
-
* Example: `http://bob:pass123@proxy.example.com:1234`.
|
|
45
|
-
* @property {string} [userAgent]
|
|
46
|
-
* The `User-Agent` HTTP header used by the browser.
|
|
47
|
-
* If not provided, the function sets `User-Agent` to a reasonable default
|
|
48
|
-
* to reduce the chance of detection of the crawler.
|
|
49
|
-
* @property {boolean} [useChrome=false]
|
|
50
|
-
* If `true` and `executablePath` is not set,
|
|
51
|
-
* Puppeteer will launch full Google Chrome browser available on the machine
|
|
52
|
-
* rather than the bundled Chromium. The path to Chrome executable
|
|
53
|
-
* is taken from the `APIFY_CHROME_EXECUTABLE_PATH` environment variable if provided,
|
|
54
|
-
* or defaults to the typical Google Chrome executable location specific for the operating system.
|
|
55
|
-
* By default, this option is `false`.
|
|
56
|
-
* @property {*} [launcher]
|
|
57
|
-
* Already required module (`Object`). This enables usage of various Puppeteer
|
|
58
|
-
* wrappers such as `puppeteer-extra`.
|
|
59
|
-
*
|
|
60
|
-
* Take caution, because it can cause all kinds of unexpected errors and weird behavior.
|
|
61
|
-
* Apify SDK is not tested with any other library besides `puppeteer` itself.
|
|
62
|
-
* @property {boolean} [useIncognitoPages=false]
|
|
63
|
-
* With this option selected, all pages will be opened in a new incognito browser context.
|
|
64
|
-
* This means they will not share cookies nor cache and their resources will not be throttled by one another.
|
|
65
|
-
* @property {boolean} [stealth]
|
|
66
|
-
* @deprecated
|
|
67
|
-
* This setting hides most of the known properties that identify headless Chrome and makes it nearly undetectable.
|
|
68
|
-
* It is recommended to use it together with the `useChrome` set to `true`.
|
|
69
|
-
* @property {StealthOptions} [stealthOptions]
|
|
70
|
-
* @deprecated
|
|
71
|
-
* Using this configuration, you can disable some of the hiding tricks.
|
|
72
|
-
* For these settings to take effect `stealth` must be set to true
|
|
73
|
-
*/
|
|
74
|
-
/**
|
|
75
|
-
* `PuppeteerLauncher` is based on the `BrowserLauncher`. It launches `puppeteer` browser instance.
|
|
76
|
-
* @ignore
|
|
77
|
-
*/
|
|
78
|
-
class PuppeteerLauncher extends browser_launcher_1.default {
|
|
79
|
-
/**
|
|
80
|
-
* @param {PuppeteerLaunchContext} launchContext
|
|
81
|
-
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
82
|
-
*/
|
|
83
|
-
constructor(launchContext = {}) {
|
|
84
|
-
(0, ow_1.default)(launchContext, 'PuppeteerLauncher', ow_1.default.object.exactShape(PuppeteerLauncher.optionsShape));
|
|
85
|
-
const { launcher = browser_launcher_1.default.requireLauncherOrThrow('puppeteer', 'apify/actor-node-puppeteer-chrome'), userAgent, stealth = false, stealthOptions = {}, ...browserLauncherOptions } = launchContext;
|
|
86
|
-
super({
|
|
87
|
-
...browserLauncherOptions,
|
|
88
|
-
launcher,
|
|
89
|
-
});
|
|
90
|
-
this.userAgent = userAgent;
|
|
91
|
-
this.stealth = stealth;
|
|
92
|
-
/** @type {StealthOptions} */
|
|
93
|
-
this.stealthOptions = {
|
|
94
|
-
hideWebDriver: true,
|
|
95
|
-
...stealthOptions,
|
|
96
|
-
};
|
|
97
|
-
this.Plugin = browser_pool_1.PuppeteerPlugin;
|
|
98
|
-
}
|
|
99
|
-
async launch() {
|
|
100
|
-
const browser = await super.launch();
|
|
101
|
-
if (this.stealth) {
|
|
102
|
-
const { hideWebDriver, ...newStealthOptions } = this.stealthOptions;
|
|
103
|
-
utils_log_1.default.deprecated('Puppeteer "stealth" and "stealthOptions" are deprecated.'
|
|
104
|
-
+ ' You should use fingerprints instead.'
|
|
105
|
-
+ ' Checkout the fingerprints guide: https://sdk.apify.com/docs/guides/avoid-blocking');
|
|
106
|
-
(0, stealth_1.default)(browser, newStealthOptions);
|
|
107
|
-
}
|
|
108
|
-
return browser;
|
|
109
|
-
}
|
|
110
|
-
createLaunchOptions() {
|
|
111
|
-
const launchOptions = super.createLaunchOptions();
|
|
112
|
-
launchOptions.args = launchOptions.args || [];
|
|
113
|
-
if ((0, utils_1.isAtHome)())
|
|
114
|
-
launchOptions.args.push('--no-sandbox');
|
|
115
|
-
if (launchOptions.defaultViewport === undefined) {
|
|
116
|
-
launchOptions.defaultViewport = LAUNCH_PUPPETEER_DEFAULT_VIEWPORT;
|
|
117
|
-
}
|
|
118
|
-
// When User-Agent is not set and we're using Chromium or headless mode,
|
|
119
|
-
// it is better to use DEFAULT_USER_AGENT to reduce chance of detection
|
|
120
|
-
let { userAgent } = this;
|
|
121
|
-
if (!userAgent && (!launchOptions.executablePath || launchOptions.headless)) {
|
|
122
|
-
userAgent = constants_1.DEFAULT_USER_AGENT;
|
|
123
|
-
}
|
|
124
|
-
if (userAgent) {
|
|
125
|
-
launchOptions.args.push(`--user-agent=${userAgent}`);
|
|
126
|
-
}
|
|
127
|
-
if (this.stealthOptions && this.stealthOptions.hideWebDriver) {
|
|
128
|
-
const idx = launchOptions.args.findIndex((arg) => arg.startsWith('--disable-blink-features='));
|
|
129
|
-
if (idx !== -1) {
|
|
130
|
-
const arg = launchOptions.args[idx];
|
|
131
|
-
launchOptions.args[idx] = `${arg},AutomationControlled`;
|
|
132
|
-
}
|
|
133
|
-
else {
|
|
134
|
-
launchOptions.args.push('--disable-blink-features=AutomationControlled');
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
return launchOptions;
|
|
138
|
-
}
|
|
139
|
-
}
|
|
140
|
-
exports.PuppeteerLauncher = PuppeteerLauncher;
|
|
141
|
-
Object.defineProperty(PuppeteerLauncher, "optionsShape", {
|
|
142
|
-
enumerable: true,
|
|
143
|
-
configurable: true,
|
|
144
|
-
writable: true,
|
|
145
|
-
value: {
|
|
146
|
-
...browser_launcher_1.default.optionsShape,
|
|
147
|
-
launcher: ow_1.default.optional.object,
|
|
148
|
-
userAgent: ow_1.default.optional.string,
|
|
149
|
-
stealth: ow_1.default.optional.boolean,
|
|
150
|
-
stealthOptions: ow_1.default.optional.object,
|
|
151
|
-
}
|
|
152
|
-
});
|
|
153
|
-
/**
|
|
154
|
-
* Launches headless Chrome using Puppeteer pre-configured to work within the Apify platform.
|
|
155
|
-
* The function has the same argument and the return value as `puppeteer.launch()`.
|
|
156
|
-
* See <a href="https://github.com/puppeteer/puppeteer/blob/master/docs/api.md#puppeteerlaunchoptions" target="_blank">
|
|
157
|
-
* Puppeteer documentation</a> for more details.
|
|
158
|
-
*
|
|
159
|
-
* The `launchPuppeteer()` function alters the following Puppeteer options:
|
|
160
|
-
*
|
|
161
|
-
* - Passes the setting from the `APIFY_HEADLESS` environment variable to the `headless` option,
|
|
162
|
-
* unless it was already defined by the caller or `APIFY_XVFB` environment variable is set to `1`.
|
|
163
|
-
* Note that Apify Actor cloud platform automatically sets `APIFY_HEADLESS=1` to all running actors.
|
|
164
|
-
* - Takes the `proxyUrl` option, validates it and adds it to `args` as `--proxy-server=XXX`.
|
|
165
|
-
* The proxy URL must define a port number and have one of the following schemes: `http://`,
|
|
166
|
-
* `https://`, `socks4://` or `socks5://`.
|
|
167
|
-
* If the proxy is HTTP (i.e. has the `http://` scheme) and contains username or password,
|
|
168
|
-
* the `launchPuppeteer` functions sets up an anonymous proxy HTTP
|
|
169
|
-
* to make the proxy work with headless Chrome. For more information, read the
|
|
170
|
-
* <a href="https://blog.apify.com/how-to-make-headless-chrome-and-puppeteer-use-a-proxy-server-with-authentication-249a21a79212"
|
|
171
|
-
* target="_blank">blog post about proxy-chain library</a>.
|
|
172
|
-
*
|
|
173
|
-
* To use this function, you need to have the [puppeteer](https://www.npmjs.com/package/puppeteer)
|
|
174
|
-
* NPM package installed in your project.
|
|
175
|
-
* When running on the Apify cloud, you can achieve that simply
|
|
176
|
-
* by using the `apify/actor-node-chrome` base Docker image for your actor - see
|
|
177
|
-
* [Apify Actor documentation](https://docs.apify.com/actor/build#base-images)
|
|
178
|
-
* for details.
|
|
179
|
-
*
|
|
180
|
-
* For an example of usage, see the [Synchronous run Example](../examples/synchronous-run)
|
|
181
|
-
* or the [Puppeteer proxy Example](../examples/puppeteer-with-proxy)
|
|
182
|
-
*
|
|
183
|
-
* @param {PuppeteerLaunchContext} [launchContext]
|
|
184
|
-
* All `PuppeteerLauncher` parameters are passed via an launchContext object.
|
|
185
|
-
* If you want to pass custom `puppeteer.launch(options)` options you can use the `PuppeteerLaunchContext.launchOptions` property.
|
|
186
|
-
* @returns {Promise<*>}
|
|
187
|
-
* Promise that resolves to Puppeteer's `Browser` instance.
|
|
188
|
-
* @memberof module:Apify
|
|
189
|
-
* @name launchPuppeteer
|
|
190
|
-
* @function
|
|
191
|
-
*/
|
|
192
|
-
const launchPuppeteer = async (launchContext) => {
|
|
193
|
-
const puppeteerLauncher = new PuppeteerLauncher(launchContext);
|
|
194
|
-
return puppeteerLauncher.launch();
|
|
195
|
-
};
|
|
196
|
-
exports.launchPuppeteer = launchPuppeteer;
|
|
197
|
-
//# sourceMappingURL=puppeteer_launcher.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"puppeteer_launcher.js","sourceRoot":"","sources":["../../src/browser_launchers/puppeteer_launcher.js"],"names":[],"mappings":"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"}
|