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.
Files changed (211) hide show
  1. package/README.md +6 -5
  2. package/package.json +69 -128
  3. package/build/actor.d.ts +0 -113
  4. package/build/actor.d.ts.map +0 -1
  5. package/build/actor.js +0 -582
  6. package/build/actor.js.map +0 -1
  7. package/build/apify.d.ts +0 -752
  8. package/build/apify.d.ts.map +0 -1
  9. package/build/apify.js +0 -877
  10. package/build/apify.js.map +0 -1
  11. package/build/autoscaling/autoscaled_pool.d.ts +0 -384
  12. package/build/autoscaling/autoscaled_pool.d.ts.map +0 -1
  13. package/build/autoscaling/autoscaled_pool.js +0 -557
  14. package/build/autoscaling/autoscaled_pool.js.map +0 -1
  15. package/build/autoscaling/snapshotter.d.ts +0 -278
  16. package/build/autoscaling/snapshotter.d.ts.map +0 -1
  17. package/build/autoscaling/snapshotter.js +0 -447
  18. package/build/autoscaling/snapshotter.js.map +0 -1
  19. package/build/autoscaling/system_status.d.ts +0 -224
  20. package/build/autoscaling/system_status.d.ts.map +0 -1
  21. package/build/autoscaling/system_status.js +0 -228
  22. package/build/autoscaling/system_status.js.map +0 -1
  23. package/build/browser_launchers/browser_launcher.d.ts +0 -154
  24. package/build/browser_launchers/browser_launcher.d.ts.map +0 -1
  25. package/build/browser_launchers/browser_launcher.js +0 -160
  26. package/build/browser_launchers/browser_launcher.js.map +0 -1
  27. package/build/browser_launchers/browser_plugin.d.ts +0 -23
  28. package/build/browser_launchers/browser_plugin.d.ts.map +0 -1
  29. package/build/browser_launchers/browser_plugin.js +0 -25
  30. package/build/browser_launchers/browser_plugin.js.map +0 -1
  31. package/build/browser_launchers/playwright_launcher.d.ts +0 -131
  32. package/build/browser_launchers/playwright_launcher.d.ts.map +0 -1
  33. package/build/browser_launchers/playwright_launcher.js +0 -150
  34. package/build/browser_launchers/playwright_launcher.js.map +0 -1
  35. package/build/browser_launchers/puppeteer_launcher.d.ts +0 -153
  36. package/build/browser_launchers/puppeteer_launcher.d.ts.map +0 -1
  37. package/build/browser_launchers/puppeteer_launcher.js +0 -197
  38. package/build/browser_launchers/puppeteer_launcher.js.map +0 -1
  39. package/build/cache_container.d.ts +0 -31
  40. package/build/cache_container.d.ts.map +0 -1
  41. package/build/cache_container.js +0 -48
  42. package/build/cache_container.js.map +0 -1
  43. package/build/configuration.d.ts +0 -226
  44. package/build/configuration.d.ts.map +0 -1
  45. package/build/configuration.js +0 -325
  46. package/build/configuration.js.map +0 -1
  47. package/build/constants.d.ts +0 -37
  48. package/build/constants.d.ts.map +0 -1
  49. package/build/constants.js +0 -41
  50. package/build/constants.js.map +0 -1
  51. package/build/crawlers/basic_crawler.d.ts +0 -443
  52. package/build/crawlers/basic_crawler.d.ts.map +0 -1
  53. package/build/crawlers/basic_crawler.js +0 -664
  54. package/build/crawlers/basic_crawler.js.map +0 -1
  55. package/build/crawlers/browser_crawler.d.ts +0 -512
  56. package/build/crawlers/browser_crawler.d.ts.map +0 -1
  57. package/build/crawlers/browser_crawler.js +0 -540
  58. package/build/crawlers/browser_crawler.js.map +0 -1
  59. package/build/crawlers/cheerio_crawler.d.ts +0 -931
  60. package/build/crawlers/cheerio_crawler.d.ts.map +0 -1
  61. package/build/crawlers/cheerio_crawler.js +0 -913
  62. package/build/crawlers/cheerio_crawler.js.map +0 -1
  63. package/build/crawlers/crawler_extension.d.ts +0 -10
  64. package/build/crawlers/crawler_extension.d.ts.map +0 -1
  65. package/build/crawlers/crawler_extension.js +0 -19
  66. package/build/crawlers/crawler_extension.js.map +0 -1
  67. package/build/crawlers/crawler_utils.d.ts +0 -34
  68. package/build/crawlers/crawler_utils.d.ts.map +0 -1
  69. package/build/crawlers/crawler_utils.js +0 -87
  70. package/build/crawlers/crawler_utils.js.map +0 -1
  71. package/build/crawlers/playwright_crawler.d.ts +0 -448
  72. package/build/crawlers/playwright_crawler.d.ts.map +0 -1
  73. package/build/crawlers/playwright_crawler.js +0 -299
  74. package/build/crawlers/playwright_crawler.js.map +0 -1
  75. package/build/crawlers/puppeteer_crawler.d.ts +0 -425
  76. package/build/crawlers/puppeteer_crawler.d.ts.map +0 -1
  77. package/build/crawlers/puppeteer_crawler.js +0 -299
  78. package/build/crawlers/puppeteer_crawler.js.map +0 -1
  79. package/build/crawlers/statistics.d.ts +0 -185
  80. package/build/crawlers/statistics.d.ts.map +0 -1
  81. package/build/crawlers/statistics.js +0 -331
  82. package/build/crawlers/statistics.js.map +0 -1
  83. package/build/enqueue_links/click_elements.d.ts +0 -179
  84. package/build/enqueue_links/click_elements.d.ts.map +0 -1
  85. package/build/enqueue_links/click_elements.js +0 -434
  86. package/build/enqueue_links/click_elements.js.map +0 -1
  87. package/build/enqueue_links/enqueue_links.d.ts +0 -117
  88. package/build/enqueue_links/enqueue_links.d.ts.map +0 -1
  89. package/build/enqueue_links/enqueue_links.js +0 -163
  90. package/build/enqueue_links/enqueue_links.js.map +0 -1
  91. package/build/enqueue_links/shared.d.ts +0 -42
  92. package/build/enqueue_links/shared.d.ts.map +0 -1
  93. package/build/enqueue_links/shared.js +0 -121
  94. package/build/enqueue_links/shared.js.map +0 -1
  95. package/build/errors.d.ts +0 -29
  96. package/build/errors.d.ts.map +0 -1
  97. package/build/errors.js +0 -38
  98. package/build/errors.js.map +0 -1
  99. package/build/events.d.ts +0 -11
  100. package/build/events.d.ts.map +0 -1
  101. package/build/events.js +0 -147
  102. package/build/events.js.map +0 -1
  103. package/build/index.d.ts +0 -4
  104. package/build/index.d.ts.map +0 -1
  105. package/build/index.js +0 -7
  106. package/build/index.js.map +0 -1
  107. package/build/main.d.ts +0 -179
  108. package/build/main.d.ts.map +0 -1
  109. package/build/main.js +0 -81
  110. package/build/main.js.map +0 -1
  111. package/build/playwright_utils.d.ts +0 -9
  112. package/build/playwright_utils.d.ts.map +0 -1
  113. package/build/playwright_utils.js +0 -90
  114. package/build/playwright_utils.js.map +0 -1
  115. package/build/proxy_configuration.d.ts +0 -411
  116. package/build/proxy_configuration.d.ts.map +0 -1
  117. package/build/proxy_configuration.js +0 -517
  118. package/build/proxy_configuration.js.map +0 -1
  119. package/build/pseudo_url.d.ts +0 -86
  120. package/build/pseudo_url.d.ts.map +0 -1
  121. package/build/pseudo_url.js +0 -153
  122. package/build/pseudo_url.js.map +0 -1
  123. package/build/puppeteer_request_interception.d.ts +0 -8
  124. package/build/puppeteer_request_interception.d.ts.map +0 -1
  125. package/build/puppeteer_request_interception.js +0 -235
  126. package/build/puppeteer_request_interception.js.map +0 -1
  127. package/build/puppeteer_utils.d.ts +0 -250
  128. package/build/puppeteer_utils.d.ts.map +0 -1
  129. package/build/puppeteer_utils.js +0 -551
  130. package/build/puppeteer_utils.js.map +0 -1
  131. package/build/request.d.ts +0 -180
  132. package/build/request.d.ts.map +0 -1
  133. package/build/request.js +0 -261
  134. package/build/request.js.map +0 -1
  135. package/build/request_list.d.ts +0 -581
  136. package/build/request_list.d.ts.map +0 -1
  137. package/build/request_list.js +0 -826
  138. package/build/request_list.js.map +0 -1
  139. package/build/serialization.d.ts +0 -5
  140. package/build/serialization.d.ts.map +0 -1
  141. package/build/serialization.js +0 -139
  142. package/build/serialization.js.map +0 -1
  143. package/build/session_pool/errors.d.ts +0 -11
  144. package/build/session_pool/errors.d.ts.map +0 -1
  145. package/build/session_pool/errors.js +0 -18
  146. package/build/session_pool/errors.js.map +0 -1
  147. package/build/session_pool/events.d.ts +0 -5
  148. package/build/session_pool/events.d.ts.map +0 -1
  149. package/build/session_pool/events.js +0 -6
  150. package/build/session_pool/events.js.map +0 -1
  151. package/build/session_pool/session.d.ts +0 -286
  152. package/build/session_pool/session.d.ts.map +0 -1
  153. package/build/session_pool/session.js +0 -355
  154. package/build/session_pool/session.js.map +0 -1
  155. package/build/session_pool/session_pool.d.ts +0 -280
  156. package/build/session_pool/session_pool.d.ts.map +0 -1
  157. package/build/session_pool/session_pool.js +0 -393
  158. package/build/session_pool/session_pool.js.map +0 -1
  159. package/build/session_pool/session_utils.d.ts +0 -4
  160. package/build/session_pool/session_utils.d.ts.map +0 -1
  161. package/build/session_pool/session_utils.js +0 -24
  162. package/build/session_pool/session_utils.js.map +0 -1
  163. package/build/stealth/hiding_tricks.d.ts +0 -22
  164. package/build/stealth/hiding_tricks.d.ts.map +0 -1
  165. package/build/stealth/hiding_tricks.js +0 -308
  166. package/build/stealth/hiding_tricks.js.map +0 -1
  167. package/build/stealth/stealth.d.ts +0 -56
  168. package/build/stealth/stealth.d.ts.map +0 -1
  169. package/build/stealth/stealth.js +0 -125
  170. package/build/stealth/stealth.js.map +0 -1
  171. package/build/storages/dataset.d.ts +0 -288
  172. package/build/storages/dataset.d.ts.map +0 -1
  173. package/build/storages/dataset.js +0 -480
  174. package/build/storages/dataset.js.map +0 -1
  175. package/build/storages/key_value_store.d.ts +0 -243
  176. package/build/storages/key_value_store.d.ts.map +0 -1
  177. package/build/storages/key_value_store.js +0 -462
  178. package/build/storages/key_value_store.js.map +0 -1
  179. package/build/storages/request_queue.d.ts +0 -318
  180. package/build/storages/request_queue.d.ts.map +0 -1
  181. package/build/storages/request_queue.js +0 -636
  182. package/build/storages/request_queue.js.map +0 -1
  183. package/build/storages/storage_manager.d.ts +0 -87
  184. package/build/storages/storage_manager.d.ts.map +0 -1
  185. package/build/storages/storage_manager.js +0 -150
  186. package/build/storages/storage_manager.js.map +0 -1
  187. package/build/tsconfig.tsbuildinfo +0 -1
  188. package/build/typedefs.d.ts +0 -146
  189. package/build/typedefs.d.ts.map +0 -1
  190. package/build/typedefs.js +0 -88
  191. package/build/typedefs.js.map +0 -1
  192. package/build/utils.d.ts +0 -175
  193. package/build/utils.d.ts.map +0 -1
  194. package/build/utils.js +0 -731
  195. package/build/utils.js.map +0 -1
  196. package/build/utils_log.d.ts +0 -41
  197. package/build/utils_log.d.ts.map +0 -1
  198. package/build/utils_log.js +0 -192
  199. package/build/utils_log.js.map +0 -1
  200. package/build/utils_request.d.ts +0 -77
  201. package/build/utils_request.d.ts.map +0 -1
  202. package/build/utils_request.js +0 -385
  203. package/build/utils_request.js.map +0 -1
  204. package/build/utils_social.d.ts +0 -210
  205. package/build/utils_social.d.ts.map +0 -1
  206. package/build/utils_social.js +0 -787
  207. package/build/utils_social.js.map +0 -1
  208. package/build/validators.d.ts +0 -23
  209. package/build/validators.d.ts.map +0 -1
  210. package/build/validators.js +0 -29
  211. package/build/validators.js.map +0 -1
@@ -1,299 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- const ow_1 = (0, tslib_1.__importDefault)(require("ow"));
5
- const playwright_launcher_1 = require("../browser_launchers/playwright_launcher");
6
- const browser_crawler_1 = (0, tslib_1.__importDefault)(require("./browser_crawler"));
7
- /* eslint-enable no-unused-vars,import/named,import/no-duplicates,import/order */
8
- const playwright_utils_1 = require("../playwright_utils");
9
- /**
10
- * @typedef PlaywrightGotoOptions
11
- * @property {number} [timeout]
12
- * Maximum operation time in milliseconds, defaults to 30 seconds, pass `0` to disable timeout.
13
- * The default value can be changed by using the browserContext.setDefaultNavigationTimeout(timeout),
14
- * browserContext.setDefaultTimeout(timeout), page.setDefaultNavigationTimeout(timeout) or page.setDefaultTimeout(timeout) methods.
15
- * @property {"domcontentloaded"|"load"|"networkidle"} [waitUntil]
16
- * When to consider operation succeeded, defaults to `load`. Events can be either:
17
- * - `'domcontentloaded'` - consider operation to be finished when the `DOMContentLoaded` event is fired.
18
- * - `'load'` - consider operation to be finished when the `load` event is fired.
19
- * - `'networkidle'` - consider operation to be finished when there are no network connections for at least `500` ms.
20
- * @property {string} [referer]
21
- * Referer header value. If provided it will take preference over the referer header value set by page.setExtraHTTPHeaders(headers).
22
- */
23
- /**
24
- * @callback PlaywrightHook
25
- * @param {{ page: Page, crawler: PlaywrightCrawler } & BrowserCrawlingContext & CrawlingContext} crawlingContext
26
- * @param {PlaywrightGotoOptions} gotoOptions
27
- * @returns {Promise<void>}
28
- */
29
- /**
30
- * @typedef PlaywrightHandlePageFunctionParam
31
- * @property {Page} page
32
- * @property {PlaywrightCrawler} crawler
33
- */
34
- /**
35
- * @callback PlaywrightHandlePageFunction
36
- * @param {PlaywrightHandlePageFunctionParam & BrowserCrawlingContext & CrawlingContext} context
37
- * @returns {Promise<void>}
38
- */
39
- /**
40
- * @typedef PlaywrightCrawlerOptions
41
- * @property {PlaywrightHandlePageFunction} handlePageFunction
42
- * Function that is called to process each request.
43
- * It is passed an object with the following fields:
44
- *
45
- * ```
46
- * {
47
- * request: Request,
48
- * response: Response,
49
- * page: Page,
50
- * session: Session,
51
- * browserController: BrowserController,
52
- * proxyInfo: ProxyInfo,
53
- * crawler: PlaywrightCrawler,
54
- * }
55
- * ```
56
- *
57
- * `request` is an instance of the {@link Request} object with details about the URL to open, HTTP method etc.
58
- * `page` is an instance of the `Playwright`
59
- * [`Page`](https://playwright.dev/docs/api/class-page)
60
- * `browserController` is an instance of the
61
- * [`BrowserController`](https://github.com/apify/browser-pool#browsercontroller),
62
- * `response` is an instance of the `Playwright`
63
- * [`Response`](https://playwright.dev/docs/api/class-response),
64
- * which is the main resource response as returned by `page.goto(request.url)`.
65
- * The function must return a promise, which is then awaited by the crawler.
66
- *
67
- * If the function throws an exception, the crawler will try to re-crawl the
68
- * request later, up to `option.maxRequestRetries` times.
69
- * If all the retries fail, the crawler calls the function
70
- * provided to the `handleFailedRequestFunction` parameter.
71
- * To make this work, you should **always**
72
- * let your function throw exceptions rather than catch them.
73
- * The exceptions are logged to the request using the
74
- * {@link Request#pushErrorMessage} function.
75
- * @property {number} [navigationTimeoutSecs=60]
76
- * Timeout in which page navigation needs to finish, in seconds.
77
- * @property {HandleFailedRequest} [handleFailedRequestFunction]
78
- * A function to handle requests that failed more than `option.maxRequestRetries` times.
79
- *
80
- * The function receives the following object as an argument:
81
- * ```
82
- * {
83
- * request: Request,
84
- * response: Response,
85
- * page: Page,
86
- * session: Session,
87
- * browserController: BrowserController,
88
- * proxyInfo: ProxyInfo,
89
- * crawler: PlaywrightCrawler,
90
- * }
91
- * ```
92
- * Where the {@link Request} instance corresponds to the failed request, and the `Error` instance
93
- * represents the last error thrown during processing of the request.
94
- * @property {Array<PlaywrightHook>} [preNavigationHooks]
95
- * Async functions that are sequentially evaluated before the navigation. Good for setting additional cookies
96
- * or browser properties before navigation. The function accepts two parameters, `crawlingContext` and `gotoOptions`,
97
- * which are passed to the `page.goto()` function the crawler calls to navigate.
98
- * Example:
99
- * ```
100
- * preNavigationHooks: [
101
- * async (crawlingContext, gotoOptions) => {
102
- * await page.evaluate((attr) => { window.foo = attr; }, 'bar');
103
- * },
104
- * ]
105
- * ```
106
- * @property {Array<PlaywrightHook>} [postNavigationHooks]
107
- * Async functions that are sequentially evaluated after the navigation. Good for checking if the navigation was successful.
108
- * The function accepts `crawlingContext` as the only parameter.
109
- * Example:
110
- * ```
111
- * postNavigationHooks: [
112
- * async (crawlingContext) => {
113
- * const { page } = crawlingContext;
114
- * if (hasCaptcha(page)) {
115
- * await solveCaptcha (page);
116
- * }
117
- * },
118
- * ]
119
- * ```
120
- * @property {PlaywrightLaunchContext} [launchContext]
121
- * The same options as used by {@link Apify#launchPlaywright}.
122
- * @property {number} [handlePageTimeoutSecs=60]
123
- * Timeout in which the function passed as `handlePageFunction` needs to finish, in seconds.
124
- * @property {BrowserPoolOptions} [browserPoolOptions]
125
- * Custom options passed to the underlying [`BrowserPool`](https://github.com/apify/browser-pool#BrowserPool) constructor.
126
- * You can tweak those to fine-tune browser management.
127
- * @property {boolean} [persistCookiesPerSession=true]
128
- * Automatically saves cookies to Session. Works only if Session Pool is used.
129
- * @property {ProxyConfiguration} [proxyConfiguration]
130
- * If set, `PlaywrightCrawler` will be configured for all connections to use
131
- * [Apify Proxy](https://console.apify.com/proxy) or your own Proxy URLs provided and rotated according to the configuration.
132
- * For more information, see the [documentation](https://docs.apify.com/proxy).
133
- * @property {RequestList} [requestList]
134
- * Static list of URLs to be processed.
135
- * Either `requestList` or `requestQueue` option must be provided (or both).
136
- * @property {RequestQueue} [requestQueue]
137
- * Dynamic queue of URLs to be processed. This is useful for recursive crawling of websites.
138
- * Either `requestList` or `requestQueue` option must be provided (or both).
139
- * @property {number} [maxRequestRetries=3]
140
- * Indicates how many times the request is retried if {@link PlaywrightCrawlerOptions.handlePageFunction} fails.
141
- * @property {number} [maxRequestsPerCrawl]
142
- * Maximum number of pages that the crawler will open. The crawl will stop when this limit is reached.
143
- * Always set this value in order to prevent infinite loops in misconfigured crawlers.
144
- * Note that in cases of parallel crawling, the actual number of pages visited might be slightly higher than this value.
145
- * @property {AutoscaledPoolOptions} [autoscaledPoolOptions]
146
- * Custom options passed to the underlying {@link AutoscaledPool} constructor.
147
- * Note that the `runTaskFunction` and `isTaskReadyFunction` options
148
- * are provided by `BasicCrawler` and cannot be overridden.
149
- * However, you can provide a custom implementation of `isFinishedFunction`.
150
- * @property {number} [minConcurrency=1]
151
- * Sets the minimum concurrency (parallelism) for the crawl. Shortcut to the corresponding {@link AutoscaledPool} option.
152
- *
153
- * *WARNING:* If you set this value too high with respect to the available system memory and CPU, your crawler will run extremely slow or crash.
154
- * If you're not sure, just keep the default value and the concurrency will scale up automatically.
155
- * @property {number} [maxConcurrency=1000]
156
- * Sets the maximum concurrency (parallelism) for the crawl. Shortcut to the corresponding {@link AutoscaledPool} option.
157
- * @property {boolean} [useSessionPool=true]
158
- * Playwright crawler will initialize the {@link SessionPool} with the corresponding `sessionPoolOptions`.
159
- * The session instance will be than available in the `handleRequestFunction`.
160
- * @property {SessionPoolOptions} [sessionPoolOptions] The configuration options for {@link SessionPool} to use.
161
- */
162
- /**
163
- * Provides a simple framework for parallel crawling of web pages
164
- * using headless Chromium, Firefox and Webkit browsers with [Playwright](https://github.com/microsoft/playwright).
165
- * The URLs to crawl are fed either from a static list of URLs
166
- * or from a dynamic queue of URLs enabling recursive crawling of websites.
167
- *
168
- * Since `Playwright` uses headless browser to download web pages and extract data,
169
- * it is useful for crawling of websites that require to execute JavaScript.
170
- * If the target website doesn't need JavaScript, consider using {@link CheerioCrawler},
171
- * which downloads the pages using raw HTTP requests and is about 10x faster.
172
- *
173
- * The source URLs are represented using {@link Request} objects that are fed from
174
- * {@link RequestList} or {@link RequestQueue} instances provided by the {@link PlaywrightCrawlerOptions.requestList}
175
- * or {@link PlaywrightCrawlerOptions.requestQueue} constructor options, respectively.
176
- *
177
- * If both {@link PlaywrightCrawlerOptions.requestList} and {@link PlaywrightCrawlerOptions.requestQueue} are used,
178
- * the instance first processes URLs from the {@link RequestList} and automatically enqueues all of them
179
- * to {@link RequestQueue} before it starts their processing. This ensures that a single URL is not crawled multiple times.
180
- *
181
- * The crawler finishes when there are no more {@link Request} objects to crawl.
182
- *
183
- * `PlaywrightCrawler` opens a new Chrome page (i.e. tab) for each {@link Request} object to crawl
184
- * and then calls the function provided by user as the {@link PlaywrightCrawlerOptions.handlePageFunction} option.
185
- *
186
- * New pages are only opened when there is enough free CPU and memory available,
187
- * using the functionality provided by the {@link AutoscaledPool} class.
188
- * All {@link AutoscaledPool} configuration options can be passed to the {@link PlaywrightCrawlerOptions.autoscaledPoolOptions}
189
- * parameter of the `PlaywrightCrawler` constructor. For user convenience, the `minConcurrency` and `maxConcurrency`
190
- * {@link AutoscaledPoolOptions} are available directly in the `PlaywrightCrawler` constructor.
191
- *
192
- * Note that the pool of Playwright instances is internally managed by the {@link BrowserPool} class.
193
- * Many constructor options such as {@link PlaywrightCrawlerOptions.maxOpenPagesPerInstance} or
194
- *
195
- * **Example usage:**
196
- *
197
- * ```javascript
198
- * const crawler = new Apify.PlaywrightCrawler({
199
- * requestList,
200
- * handlePageFunction: async ({ page, request }) => {
201
- * // This function is called to extract data from a single web page
202
- * // 'page' is an instance of Playwright.Page with page.goto(request.url) already called
203
- * // 'request' is an instance of Request class with information about the page to load
204
- * await Apify.pushData({
205
- * title: await page.title(),
206
- * url: request.url,
207
- * succeeded: true,
208
- * })
209
- * },
210
- * handleFailedRequestFunction: async ({ request }) => {
211
- * // This function is called when the crawling of a request failed too many times
212
- * await Apify.pushData({
213
- * url: request.url,
214
- * succeeded: false,
215
- * errors: request.errorMessages,
216
- * })
217
- * },
218
- * });
219
- *
220
- * await crawler.run();
221
- * ```
222
- * @property {Statistics} stats
223
- * Contains statistics about the current run.
224
- * @property {RequestList} requestList
225
- * A reference to the underlying {@link RequestList} class that manages the crawler's {@link Request}s.
226
- * Only available if used by the crawler.
227
- * @property {RequestQueue} requestQueue
228
- * A reference to the underlying {@link RequestQueue} class that manages the crawler's {@link Request}s.
229
- * Only available if used by the crawler.
230
- * @property {SessionPool} sessionPool
231
- * A reference to the underlying {@link SessionPool} class that manages the crawler's {@link Session}s.
232
- * Only available if used by the crawler.
233
- * @property {ProxyConfiguration} proxyConfiguration
234
- * A reference to the underlying {@link ProxyConfiguration} class that manages the crawler's proxies.
235
- * Only available if used by the crawler.
236
- * @property {BrowserPool} browserPool
237
- * A reference to the underlying `BrowserPool` class that manages the crawler's browsers.
238
- * For more information about it, see the [`browser-pool` module](https://github.com/apify/browser-pool).
239
- * @property {AutoscaledPool} autoscaledPool
240
- * A reference to the underlying {@link AutoscaledPool} class that manages the concurrency of the crawler.
241
- * Note that this property is only initialized after calling the {@link CheerioCrawler#run} function.
242
- * You can use it to change the concurrency settings on the fly,
243
- * to pause the crawler by calling {@link AutoscaledPool#pause}
244
- * or to abort it by calling {@link AutoscaledPool#abort}.
245
- */
246
- class PlaywrightCrawler extends browser_crawler_1.default {
247
- /**
248
- * @param {PlaywrightCrawlerOptions} options
249
- * All `PlaywrightCrawler` parameters are passed via an options object.
250
- */
251
- constructor(options) {
252
- (0, ow_1.default)(options, 'PlaywrightCrawlerOptions', ow_1.default.object.exactShape(PlaywrightCrawler.optionsShape));
253
- const { launchContext = {}, browserPoolOptions = {}, ...browserCrawlerOptions } = options;
254
- if (launchContext.proxyUrl) {
255
- throw new Error('PlaywrightCrawlerOptions.launchContext.proxyUrl is not allowed in PlaywrightCrawler.'
256
- + 'Use PlaywrightCrawlerOptions.proxyConfiguration');
257
- }
258
- const playwrightLauncher = new playwright_launcher_1.PlaywrightLauncher(launchContext);
259
- browserPoolOptions.browserPlugins = [
260
- playwrightLauncher.createBrowserPlugin(),
261
- ];
262
- super({
263
- ...browserCrawlerOptions,
264
- browserPoolOptions,
265
- });
266
- this.launchContext = launchContext;
267
- }
268
- /**
269
- * @param {*} crawlingContext
270
- * @param {*} gotoOptions
271
- * @ignore
272
- * @protected
273
- * @internal
274
- */
275
- async _navigationHandler(crawlingContext, gotoOptions) {
276
- if (this.gotoFunction) {
277
- this.log.deprecated('PlaywrightCrawler.gotoFunction is deprecated. Use "preNavigationHooks" and "postNavigationHooks" instead.');
278
- return this.gotoFunction(crawlingContext, gotoOptions);
279
- }
280
- return (0, playwright_utils_1.gotoExtended)(crawlingContext.page, crawlingContext.request, gotoOptions);
281
- }
282
- }
283
- /**
284
- * @internal
285
- * @type any
286
- */
287
- Object.defineProperty(PlaywrightCrawler, "optionsShape", {
288
- enumerable: true,
289
- configurable: true,
290
- writable: true,
291
- value: {
292
- ...browser_crawler_1.default.optionsShape,
293
- browserPoolOptions: ow_1.default.optional.object,
294
- launcher: ow_1.default.optional.object,
295
- launchContext: ow_1.default.optional.object,
296
- }
297
- });
298
- exports.default = PlaywrightCrawler;
299
- //# sourceMappingURL=playwright_crawler.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"playwright_crawler.js","sourceRoot":"","sources":["../../src/crawlers/playwright_crawler.js"],"names":[],"mappings":";;;AAAA,yDAAoB;AAKpB,kFAAuG;AACvG,qFAA2E;AAS3E,iFAAiF;AAEjF,0DAAmD;AAEnD;;;;;;;;;;;;;GAaG;AACH;;;;;GAKG;AACH;;;;GAIG;AACH;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0HG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmFG;AACH,MAAM,iBAAkB,SAAQ,yBAAc;IAY1C;;;OAGG;IACH,YAAY,OAAO;QACf,IAAA,YAAE,EAAC,OAAO,EAAE,0BAA0B,EAAE,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC,iBAAiB,CAAC,YAAY,CAAC,CAAC,CAAC;QAE9F,MAAM,EACF,aAAa,GAAG,EAAE,EAClB,kBAAkB,GAAG,EAAE,EACvB,GAAG,qBAAqB,EAC3B,GAAG,OAAO,CAAC;QAEZ,IAAI,aAAa,CAAC,QAAQ,EAAE;YACxB,MAAM,IAAI,KAAK,CAAC,sFAAsF;kBAChG,iDAAiD,CAAC,CAAC;SAC5D;QACD,MAAM,kBAAkB,GAAG,IAAI,wCAAkB,CAAC,aAAa,CAAC,CAAC;QAEjE,kBAAkB,CAAC,cAAc,GAAG;YAChC,kBAAkB,CAAC,mBAAmB,EAAE;SAC3C,CAAC;QAEF,KAAK,CAAC;YACF,GAAG,qBAAqB;YACxB,kBAAkB;SACrB,CAAC,CAAC;QAEH,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACvC,CAAC;IAED;;;;;;OAMG;IACH,KAAK,CAAC,kBAAkB,CAAC,eAAe,EAAE,WAAW;QACjD,IAAI,IAAI,CAAC,YAAY,EAAE;YACnB,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,2GAA2G,CAAC,CAAC;YACjI,OAAO,IAAI,CAAC,YAAY,CAAC,eAAe,EAAE,WAAW,CAAC,CAAC;SAC1D;QACD,OAAO,IAAA,+BAAY,EAAC,eAAe,CAAC,IAAI,EAAE,eAAe,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;IACpF,CAAC;;AAvDD;;;GAGG;AACI;;;;WAAe;QAClB,GAAG,yBAAc,CAAC,YAAY;QAC9B,kBAAkB,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;QACtC,QAAQ,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;QAC5B,aAAa,EAAE,YAAE,CAAC,QAAQ,CAAC,MAAM;KACpC;GAAC;AAiDN,kBAAe,iBAAiB,CAAC"}