apify 2.3.1-beta.4 → 3.0.0-alpha.10

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 (233) hide show
  1. package/README.md +6 -5
  2. package/actor.d.ts +1092 -0
  3. package/actor.d.ts.map +1 -0
  4. package/actor.js +1221 -0
  5. package/actor.js.map +1 -0
  6. package/index.d.ts +4 -0
  7. package/index.d.ts.map +1 -0
  8. package/index.js +7 -0
  9. package/index.js.map +1 -0
  10. package/index.mjs +7 -0
  11. package/package.json +54 -128
  12. package/platform_event_manager.d.ts +55 -0
  13. package/platform_event_manager.d.ts.map +1 -0
  14. package/platform_event_manager.js +116 -0
  15. package/platform_event_manager.js.map +1 -0
  16. package/proxy_configuration.d.ts +210 -0
  17. package/proxy_configuration.d.ts.map +1 -0
  18. package/proxy_configuration.js +297 -0
  19. package/proxy_configuration.js.map +1 -0
  20. package/tsconfig.build.tsbuildinfo +1 -0
  21. package/utils.d.ts +11 -0
  22. package/utils.d.ts.map +1 -0
  23. package/utils.js +40 -0
  24. package/utils.js.map +1 -0
  25. package/build/actor.d.ts +0 -113
  26. package/build/actor.d.ts.map +0 -1
  27. package/build/actor.js +0 -582
  28. package/build/actor.js.map +0 -1
  29. package/build/apify.d.ts +0 -752
  30. package/build/apify.d.ts.map +0 -1
  31. package/build/apify.js +0 -877
  32. package/build/apify.js.map +0 -1
  33. package/build/autoscaling/autoscaled_pool.d.ts +0 -384
  34. package/build/autoscaling/autoscaled_pool.d.ts.map +0 -1
  35. package/build/autoscaling/autoscaled_pool.js +0 -557
  36. package/build/autoscaling/autoscaled_pool.js.map +0 -1
  37. package/build/autoscaling/snapshotter.d.ts +0 -278
  38. package/build/autoscaling/snapshotter.d.ts.map +0 -1
  39. package/build/autoscaling/snapshotter.js +0 -447
  40. package/build/autoscaling/snapshotter.js.map +0 -1
  41. package/build/autoscaling/system_status.d.ts +0 -224
  42. package/build/autoscaling/system_status.d.ts.map +0 -1
  43. package/build/autoscaling/system_status.js +0 -228
  44. package/build/autoscaling/system_status.js.map +0 -1
  45. package/build/browser_launchers/browser_launcher.d.ts +0 -154
  46. package/build/browser_launchers/browser_launcher.d.ts.map +0 -1
  47. package/build/browser_launchers/browser_launcher.js +0 -160
  48. package/build/browser_launchers/browser_launcher.js.map +0 -1
  49. package/build/browser_launchers/browser_plugin.d.ts +0 -23
  50. package/build/browser_launchers/browser_plugin.d.ts.map +0 -1
  51. package/build/browser_launchers/browser_plugin.js +0 -25
  52. package/build/browser_launchers/browser_plugin.js.map +0 -1
  53. package/build/browser_launchers/playwright_launcher.d.ts +0 -131
  54. package/build/browser_launchers/playwright_launcher.d.ts.map +0 -1
  55. package/build/browser_launchers/playwright_launcher.js +0 -150
  56. package/build/browser_launchers/playwright_launcher.js.map +0 -1
  57. package/build/browser_launchers/puppeteer_launcher.d.ts +0 -153
  58. package/build/browser_launchers/puppeteer_launcher.d.ts.map +0 -1
  59. package/build/browser_launchers/puppeteer_launcher.js +0 -197
  60. package/build/browser_launchers/puppeteer_launcher.js.map +0 -1
  61. package/build/cache_container.d.ts +0 -31
  62. package/build/cache_container.d.ts.map +0 -1
  63. package/build/cache_container.js +0 -48
  64. package/build/cache_container.js.map +0 -1
  65. package/build/configuration.d.ts +0 -226
  66. package/build/configuration.d.ts.map +0 -1
  67. package/build/configuration.js +0 -325
  68. package/build/configuration.js.map +0 -1
  69. package/build/constants.d.ts +0 -37
  70. package/build/constants.d.ts.map +0 -1
  71. package/build/constants.js +0 -41
  72. package/build/constants.js.map +0 -1
  73. package/build/crawlers/basic_crawler.d.ts +0 -443
  74. package/build/crawlers/basic_crawler.d.ts.map +0 -1
  75. package/build/crawlers/basic_crawler.js +0 -664
  76. package/build/crawlers/basic_crawler.js.map +0 -1
  77. package/build/crawlers/browser_crawler.d.ts +0 -512
  78. package/build/crawlers/browser_crawler.d.ts.map +0 -1
  79. package/build/crawlers/browser_crawler.js +0 -540
  80. package/build/crawlers/browser_crawler.js.map +0 -1
  81. package/build/crawlers/cheerio_crawler.d.ts +0 -931
  82. package/build/crawlers/cheerio_crawler.d.ts.map +0 -1
  83. package/build/crawlers/cheerio_crawler.js +0 -913
  84. package/build/crawlers/cheerio_crawler.js.map +0 -1
  85. package/build/crawlers/crawler_extension.d.ts +0 -10
  86. package/build/crawlers/crawler_extension.d.ts.map +0 -1
  87. package/build/crawlers/crawler_extension.js +0 -19
  88. package/build/crawlers/crawler_extension.js.map +0 -1
  89. package/build/crawlers/crawler_utils.d.ts +0 -34
  90. package/build/crawlers/crawler_utils.d.ts.map +0 -1
  91. package/build/crawlers/crawler_utils.js +0 -87
  92. package/build/crawlers/crawler_utils.js.map +0 -1
  93. package/build/crawlers/playwright_crawler.d.ts +0 -448
  94. package/build/crawlers/playwright_crawler.d.ts.map +0 -1
  95. package/build/crawlers/playwright_crawler.js +0 -299
  96. package/build/crawlers/playwright_crawler.js.map +0 -1
  97. package/build/crawlers/puppeteer_crawler.d.ts +0 -425
  98. package/build/crawlers/puppeteer_crawler.d.ts.map +0 -1
  99. package/build/crawlers/puppeteer_crawler.js +0 -299
  100. package/build/crawlers/puppeteer_crawler.js.map +0 -1
  101. package/build/crawlers/statistics.d.ts +0 -185
  102. package/build/crawlers/statistics.d.ts.map +0 -1
  103. package/build/crawlers/statistics.js +0 -331
  104. package/build/crawlers/statistics.js.map +0 -1
  105. package/build/enqueue_links/click_elements.d.ts +0 -179
  106. package/build/enqueue_links/click_elements.d.ts.map +0 -1
  107. package/build/enqueue_links/click_elements.js +0 -434
  108. package/build/enqueue_links/click_elements.js.map +0 -1
  109. package/build/enqueue_links/enqueue_links.d.ts +0 -117
  110. package/build/enqueue_links/enqueue_links.d.ts.map +0 -1
  111. package/build/enqueue_links/enqueue_links.js +0 -163
  112. package/build/enqueue_links/enqueue_links.js.map +0 -1
  113. package/build/enqueue_links/shared.d.ts +0 -42
  114. package/build/enqueue_links/shared.d.ts.map +0 -1
  115. package/build/enqueue_links/shared.js +0 -121
  116. package/build/enqueue_links/shared.js.map +0 -1
  117. package/build/errors.d.ts +0 -29
  118. package/build/errors.d.ts.map +0 -1
  119. package/build/errors.js +0 -38
  120. package/build/errors.js.map +0 -1
  121. package/build/events.d.ts +0 -11
  122. package/build/events.d.ts.map +0 -1
  123. package/build/events.js +0 -147
  124. package/build/events.js.map +0 -1
  125. package/build/index.d.ts +0 -4
  126. package/build/index.d.ts.map +0 -1
  127. package/build/index.js +0 -7
  128. package/build/index.js.map +0 -1
  129. package/build/main.d.ts +0 -179
  130. package/build/main.d.ts.map +0 -1
  131. package/build/main.js +0 -81
  132. package/build/main.js.map +0 -1
  133. package/build/playwright_utils.d.ts +0 -9
  134. package/build/playwright_utils.d.ts.map +0 -1
  135. package/build/playwright_utils.js +0 -90
  136. package/build/playwright_utils.js.map +0 -1
  137. package/build/proxy_configuration.d.ts +0 -411
  138. package/build/proxy_configuration.d.ts.map +0 -1
  139. package/build/proxy_configuration.js +0 -517
  140. package/build/proxy_configuration.js.map +0 -1
  141. package/build/pseudo_url.d.ts +0 -86
  142. package/build/pseudo_url.d.ts.map +0 -1
  143. package/build/pseudo_url.js +0 -153
  144. package/build/pseudo_url.js.map +0 -1
  145. package/build/puppeteer_request_interception.d.ts +0 -8
  146. package/build/puppeteer_request_interception.d.ts.map +0 -1
  147. package/build/puppeteer_request_interception.js +0 -235
  148. package/build/puppeteer_request_interception.js.map +0 -1
  149. package/build/puppeteer_utils.d.ts +0 -250
  150. package/build/puppeteer_utils.d.ts.map +0 -1
  151. package/build/puppeteer_utils.js +0 -551
  152. package/build/puppeteer_utils.js.map +0 -1
  153. package/build/request.d.ts +0 -180
  154. package/build/request.d.ts.map +0 -1
  155. package/build/request.js +0 -261
  156. package/build/request.js.map +0 -1
  157. package/build/request_list.d.ts +0 -581
  158. package/build/request_list.d.ts.map +0 -1
  159. package/build/request_list.js +0 -826
  160. package/build/request_list.js.map +0 -1
  161. package/build/serialization.d.ts +0 -5
  162. package/build/serialization.d.ts.map +0 -1
  163. package/build/serialization.js +0 -139
  164. package/build/serialization.js.map +0 -1
  165. package/build/session_pool/errors.d.ts +0 -11
  166. package/build/session_pool/errors.d.ts.map +0 -1
  167. package/build/session_pool/errors.js +0 -18
  168. package/build/session_pool/errors.js.map +0 -1
  169. package/build/session_pool/events.d.ts +0 -5
  170. package/build/session_pool/events.d.ts.map +0 -1
  171. package/build/session_pool/events.js +0 -6
  172. package/build/session_pool/events.js.map +0 -1
  173. package/build/session_pool/session.d.ts +0 -286
  174. package/build/session_pool/session.d.ts.map +0 -1
  175. package/build/session_pool/session.js +0 -355
  176. package/build/session_pool/session.js.map +0 -1
  177. package/build/session_pool/session_pool.d.ts +0 -280
  178. package/build/session_pool/session_pool.d.ts.map +0 -1
  179. package/build/session_pool/session_pool.js +0 -393
  180. package/build/session_pool/session_pool.js.map +0 -1
  181. package/build/session_pool/session_utils.d.ts +0 -4
  182. package/build/session_pool/session_utils.d.ts.map +0 -1
  183. package/build/session_pool/session_utils.js +0 -24
  184. package/build/session_pool/session_utils.js.map +0 -1
  185. package/build/stealth/hiding_tricks.d.ts +0 -22
  186. package/build/stealth/hiding_tricks.d.ts.map +0 -1
  187. package/build/stealth/hiding_tricks.js +0 -308
  188. package/build/stealth/hiding_tricks.js.map +0 -1
  189. package/build/stealth/stealth.d.ts +0 -56
  190. package/build/stealth/stealth.d.ts.map +0 -1
  191. package/build/stealth/stealth.js +0 -125
  192. package/build/stealth/stealth.js.map +0 -1
  193. package/build/storages/dataset.d.ts +0 -288
  194. package/build/storages/dataset.d.ts.map +0 -1
  195. package/build/storages/dataset.js +0 -480
  196. package/build/storages/dataset.js.map +0 -1
  197. package/build/storages/key_value_store.d.ts +0 -243
  198. package/build/storages/key_value_store.d.ts.map +0 -1
  199. package/build/storages/key_value_store.js +0 -462
  200. package/build/storages/key_value_store.js.map +0 -1
  201. package/build/storages/request_queue.d.ts +0 -318
  202. package/build/storages/request_queue.d.ts.map +0 -1
  203. package/build/storages/request_queue.js +0 -636
  204. package/build/storages/request_queue.js.map +0 -1
  205. package/build/storages/storage_manager.d.ts +0 -87
  206. package/build/storages/storage_manager.d.ts.map +0 -1
  207. package/build/storages/storage_manager.js +0 -150
  208. package/build/storages/storage_manager.js.map +0 -1
  209. package/build/tsconfig.tsbuildinfo +0 -1
  210. package/build/typedefs.d.ts +0 -146
  211. package/build/typedefs.d.ts.map +0 -1
  212. package/build/typedefs.js +0 -88
  213. package/build/typedefs.js.map +0 -1
  214. package/build/utils.d.ts +0 -175
  215. package/build/utils.d.ts.map +0 -1
  216. package/build/utils.js +0 -731
  217. package/build/utils.js.map +0 -1
  218. package/build/utils_log.d.ts +0 -41
  219. package/build/utils_log.d.ts.map +0 -1
  220. package/build/utils_log.js +0 -192
  221. package/build/utils_log.js.map +0 -1
  222. package/build/utils_request.d.ts +0 -77
  223. package/build/utils_request.d.ts.map +0 -1
  224. package/build/utils_request.js +0 -385
  225. package/build/utils_request.js.map +0 -1
  226. package/build/utils_social.d.ts +0 -210
  227. package/build/utils_social.d.ts.map +0 -1
  228. package/build/utils_social.js +0 -787
  229. package/build/utils_social.js.map +0 -1
  230. package/build/validators.d.ts +0 -23
  231. package/build/validators.d.ts.map +0 -1
  232. package/build/validators.js +0 -29
  233. 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"}