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,425 +0,0 @@
1
- export default PuppeteerCrawler;
2
- export type PuppeteerHook = (crawlingContext: {
3
- page: Page;
4
- crawler: PuppeteerCrawler;
5
- } & BrowserCrawlingContext & CrawlingContext, gotoOptions: DirectNavigationOptions) => Promise<void>;
6
- export type PuppeteerHandlePageFunctionParam = {
7
- page: Page;
8
- crawler: PuppeteerCrawler;
9
- };
10
- export type PuppeteerHandlePage = (context: CrawlingContext & BrowserCrawlingContext & {
11
- page: Page;
12
- crawler: PuppeteerCrawler;
13
- }) => Promise<void>;
14
- export type PuppeteerCrawlerOptions = {
15
- /**
16
- * Function that is called to process each request.
17
- * It is passed an object with the following fields:
18
- *
19
- * ```
20
- * {
21
- * request: Request,
22
- * response: Response,
23
- * page: Page,
24
- * session: Session,
25
- * browserController: BrowserController,
26
- * proxyInfo: ProxyInfo,
27
- * crawler: PuppeteerCrawler,
28
- * }
29
- * ```
30
- *
31
- * `request` is an instance of the {@link Request } object with details about the URL to open, HTTP method etc.
32
- * `page` is an instance of the `Puppeteer`
33
- * [`Page`](https://pptr.dev/#?product=Puppeteer&show=api-class-page)
34
- * `browserPool` is an instance of the
35
- * [`BrowserPool`](https://github.com/apify/browser-pool#BrowserPool),
36
- * `browserController` is an instance of the
37
- * [`BrowserController`](https://github.com/apify/browser-pool#browsercontroller),
38
- * `response` is an instance of the `Puppeteer`
39
- * [`Response`](https://pptr.dev/#?product=Puppeteer&show=api-class-response),
40
- * which is the main resource response as returned by `page.goto(request.url)`.
41
- * The function must return a promise, which is then awaited by the crawler.
42
- *
43
- * If the function throws an exception, the crawler will try to re-crawl the
44
- * request later, up to `option.maxRequestRetries` times.
45
- * If all the retries fail, the crawler calls the function
46
- * provided to the `handleFailedRequestFunction` parameter.
47
- * To make this work, you should **always**
48
- * let your function throw exceptions rather than catch them.
49
- * The exceptions are logged to the request using the
50
- * {@link RequestpushErrorMessage } function.
51
- */
52
- handlePageFunction: PuppeteerHandlePage;
53
- /**
54
- * Timeout in which page navigation needs to finish, in seconds.
55
- */
56
- navigationTimeoutSecs?: number | undefined;
57
- /**
58
- * A function to handle requests that failed more than `option.maxRequestRetries` times.
59
- *
60
- * The function receives the following object as an argument:
61
- * ```
62
- * {
63
- * request: Request,
64
- * response: Response,
65
- * page: Page,
66
- * session: Session,
67
- * browserController: BrowserController,
68
- * proxyInfo: ProxyInfo,
69
- * crawler: PuppeteerCrawler,
70
- * }
71
- * ```
72
- * Where the {@link Request } instance corresponds to the failed request, and the `Error` instance
73
- * represents the last error thrown during processing of the request.
74
- */
75
- handleFailedRequestFunction?: HandleFailedRequest | undefined;
76
- /**
77
- * Options used by {@link ApifylaunchPuppeteer } to start new Puppeteer instances.
78
- */
79
- launchContext?: PuppeteerLaunchContext | undefined;
80
- /**
81
- * Timeout in which the function passed as `handlePageFunction` needs to finish, in seconds.
82
- */
83
- handlePageTimeoutSecs?: number | undefined;
84
- /**
85
- * Custom options passed to the underlying [`BrowserPool`](https://github.com/apify/browser-pool#BrowserPool) constructor.
86
- * You can tweak those to fine-tune browser management.
87
- */
88
- browserPoolOptions?: BrowserPoolOptions<import("browser-pool").BrowserPlugin<import("browser-pool/dist/abstract-classes/browser-plugin").CommonLibrary, unknown, import("browser-pool/dist/abstract-classes/browser-plugin").CommonBrowser, unknown, import("browser-pool").CommonPage>> | undefined;
89
- /**
90
- * Automatically saves cookies to Session. Works only if Session Pool is used.
91
- */
92
- persistCookiesPerSession?: boolean | undefined;
93
- /**
94
- * If set, `PuppeteerCrawler` will be configured for all connections to use
95
- * [Apify Proxy](https://console.apify.com/proxy) or your own Proxy URLs provided and rotated according to the configuration.
96
- * For more information, see the [documentation](https://docs.apify.com/proxy).
97
- */
98
- proxyConfiguration?: ProxyConfiguration | undefined;
99
- /**
100
- * Async functions that are sequentially evaluated before the navigation. Good for setting additional cookies
101
- * or browser properties before navigation. The function accepts two parameters, `crawlingContext` and `gotoOptions`,
102
- * which are passed to the `page.goto()` function the crawler calls to navigate.
103
- * Example:
104
- * ```
105
- * preNavigationHooks: [
106
- * async (crawlingContext, gotoOptions) => {
107
- * const { page } = crawlingContext;
108
- * await page.evaluate((attr) => { window.foo = attr; }, 'bar');
109
- * },
110
- * ]
111
- * ```
112
- */
113
- preNavigationHooks?: PuppeteerHook[] | undefined;
114
- /**
115
- * Async functions that are sequentially evaluated after the navigation. Good for checking if the navigation was successful.
116
- * The function accepts `crawlingContext` as the only parameter.
117
- * Example:
118
- * ```
119
- * postNavigationHooks: [
120
- * async (crawlingContext) => {
121
- * const { page } = crawlingContext;
122
- * if (hasCaptcha(page)) {
123
- * await solveCaptcha (page);
124
- * }
125
- * },
126
- * ]
127
- * ```
128
- */
129
- postNavigationHooks?: PuppeteerHook[] | undefined;
130
- /**
131
- * Static list of URLs to be processed.
132
- * Either `requestList` or `requestQueue` option must be provided (or both).
133
- */
134
- requestList?: RequestList | undefined;
135
- /**
136
- * Dynamic queue of URLs to be processed. This is useful for recursive crawling of websites.
137
- * Either `requestList` or `requestQueue` option must be provided (or both).
138
- */
139
- requestQueue?: RequestQueue | undefined;
140
- /**
141
- * Indicates how many times the request is retried if {@link PuppeteerCrawlerOptions.handlePageFunction } fails.
142
- */
143
- maxRequestRetries?: number | undefined;
144
- /**
145
- * Maximum number of pages that the crawler will open. The crawl will stop when this limit is reached.
146
- * Always set this value in order to prevent infinite loops in misconfigured crawlers.
147
- * Note that in cases of parallel crawling, the actual number of pages visited might be slightly higher than this value.
148
- */
149
- maxRequestsPerCrawl?: number | undefined;
150
- /**
151
- * Custom options passed to the underlying {@link AutoscaledPool } constructor.
152
- * Note that the `runTaskFunction` and `isTaskReadyFunction` options
153
- * are provided by the crawler and cannot be overridden.
154
- * However, you can provide a custom implementation of `isFinishedFunction`.
155
- */
156
- autoscaledPoolOptions?: AutoscaledPoolOptions | undefined;
157
- /**
158
- * Sets the minimum concurrency (parallelism) for the crawl. Shortcut to the corresponding {@link AutoscaledPool } option.
159
- *
160
- * *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.
161
- * If you're not sure, just keep the default value and the concurrency will scale up automatically.
162
- */
163
- minConcurrency?: number | undefined;
164
- /**
165
- * Sets the maximum concurrency (parallelism) for the crawl. Shortcut to the corresponding {@link AutoscaledPool } option.
166
- */
167
- maxConcurrency?: number | undefined;
168
- /**
169
- * Puppeteer crawler will initialize the {@link SessionPool } with the corresponding `sessionPoolOptions`.
170
- * The session instance will be than available in the `handleRequestFunction`.
171
- */
172
- useSessionPool?: boolean | undefined;
173
- /**
174
- * The configuration options for {@link SessionPool } to use.
175
- */
176
- sessionPoolOptions?: SessionPoolOptions | undefined;
177
- };
178
- /**
179
- * @callback PuppeteerHook
180
- * @param {{ page: Page, crawler: PuppeteerCrawler } & BrowserCrawlingContext & CrawlingContext} crawlingContext
181
- * @param {DirectNavigationOptions} gotoOptions
182
- * @returns {Promise<void>}
183
- */
184
- /**
185
- * @typedef PuppeteerHandlePageFunctionParam
186
- * @property {Page} page
187
- * @property {PuppeteerCrawler} crawler
188
- */
189
- /**
190
- * @callback PuppeteerHandlePage
191
- * @param {CrawlingContext & BrowserCrawlingContext & { page: Page, crawler: PuppeteerCrawler }} context
192
- * @returns {Promise<void>}
193
- */
194
- /**
195
- * @typedef PuppeteerCrawlerOptions
196
- * @property {PuppeteerHandlePage} handlePageFunction
197
- * Function that is called to process each request.
198
- * It is passed an object with the following fields:
199
- *
200
- * ```
201
- * {
202
- * request: Request,
203
- * response: Response,
204
- * page: Page,
205
- * session: Session,
206
- * browserController: BrowserController,
207
- * proxyInfo: ProxyInfo,
208
- * crawler: PuppeteerCrawler,
209
- * }
210
- * ```
211
- *
212
- * `request` is an instance of the {@link Request} object with details about the URL to open, HTTP method etc.
213
- * `page` is an instance of the `Puppeteer`
214
- * [`Page`](https://pptr.dev/#?product=Puppeteer&show=api-class-page)
215
- * `browserPool` is an instance of the
216
- * [`BrowserPool`](https://github.com/apify/browser-pool#BrowserPool),
217
- * `browserController` is an instance of the
218
- * [`BrowserController`](https://github.com/apify/browser-pool#browsercontroller),
219
- * `response` is an instance of the `Puppeteer`
220
- * [`Response`](https://pptr.dev/#?product=Puppeteer&show=api-class-response),
221
- * which is the main resource response as returned by `page.goto(request.url)`.
222
- * The function must return a promise, which is then awaited by the crawler.
223
- *
224
- * If the function throws an exception, the crawler will try to re-crawl the
225
- * request later, up to `option.maxRequestRetries` times.
226
- * If all the retries fail, the crawler calls the function
227
- * provided to the `handleFailedRequestFunction` parameter.
228
- * To make this work, you should **always**
229
- * let your function throw exceptions rather than catch them.
230
- * The exceptions are logged to the request using the
231
- * {@link Request#pushErrorMessage} function.
232
- * @property {number} [navigationTimeoutSecs=60]
233
- * Timeout in which page navigation needs to finish, in seconds.
234
- * @property {HandleFailedRequest} [handleFailedRequestFunction]
235
- * A function to handle requests that failed more than `option.maxRequestRetries` times.
236
- *
237
- * The function receives the following object as an argument:
238
- * ```
239
- * {
240
- * request: Request,
241
- * response: Response,
242
- * page: Page,
243
- * session: Session,
244
- * browserController: BrowserController,
245
- * proxyInfo: ProxyInfo,
246
- * crawler: PuppeteerCrawler,
247
- * }
248
- * ```
249
- * Where the {@link Request} instance corresponds to the failed request, and the `Error` instance
250
- * represents the last error thrown during processing of the request.
251
- * @property {PuppeteerLaunchContext} [launchContext]
252
- * Options used by {@link Apify#launchPuppeteer} to start new Puppeteer instances.
253
- * @property {number} [handlePageTimeoutSecs=60]
254
- * Timeout in which the function passed as `handlePageFunction` needs to finish, in seconds.
255
- * @property {BrowserPoolOptions} [browserPoolOptions]
256
- * Custom options passed to the underlying [`BrowserPool`](https://github.com/apify/browser-pool#BrowserPool) constructor.
257
- * You can tweak those to fine-tune browser management.
258
- * @property {boolean} [persistCookiesPerSession=true]
259
- * Automatically saves cookies to Session. Works only if Session Pool is used.
260
- * @property {ProxyConfiguration} [proxyConfiguration]
261
- * If set, `PuppeteerCrawler` will be configured for all connections to use
262
- * [Apify Proxy](https://console.apify.com/proxy) or your own Proxy URLs provided and rotated according to the configuration.
263
- * For more information, see the [documentation](https://docs.apify.com/proxy).
264
- * @property {Array<PuppeteerHook>} [preNavigationHooks]
265
- * Async functions that are sequentially evaluated before the navigation. Good for setting additional cookies
266
- * or browser properties before navigation. The function accepts two parameters, `crawlingContext` and `gotoOptions`,
267
- * which are passed to the `page.goto()` function the crawler calls to navigate.
268
- * Example:
269
- * ```
270
- * preNavigationHooks: [
271
- * async (crawlingContext, gotoOptions) => {
272
- * const { page } = crawlingContext;
273
- * await page.evaluate((attr) => { window.foo = attr; }, 'bar');
274
- * },
275
- * ]
276
- * ```
277
- * @property {Array<PuppeteerHook>} [postNavigationHooks]
278
- * Async functions that are sequentially evaluated after the navigation. Good for checking if the navigation was successful.
279
- * The function accepts `crawlingContext` as the only parameter.
280
- * Example:
281
- * ```
282
- * postNavigationHooks: [
283
- * async (crawlingContext) => {
284
- * const { page } = crawlingContext;
285
- * if (hasCaptcha(page)) {
286
- * await solveCaptcha (page);
287
- * }
288
- * },
289
- * ]
290
- * ```
291
- * @property {RequestList} [requestList]
292
- * Static list of URLs to be processed.
293
- * Either `requestList` or `requestQueue` option must be provided (or both).
294
- * @property {RequestQueue} [requestQueue]
295
- * Dynamic queue of URLs to be processed. This is useful for recursive crawling of websites.
296
- * Either `requestList` or `requestQueue` option must be provided (or both).
297
- * @property {number} [maxRequestRetries=3]
298
- * Indicates how many times the request is retried if {@link PuppeteerCrawlerOptions.handlePageFunction} fails.
299
- * @property {number} [maxRequestsPerCrawl]
300
- * Maximum number of pages that the crawler will open. The crawl will stop when this limit is reached.
301
- * Always set this value in order to prevent infinite loops in misconfigured crawlers.
302
- * Note that in cases of parallel crawling, the actual number of pages visited might be slightly higher than this value.
303
- * @property {AutoscaledPoolOptions} [autoscaledPoolOptions]
304
- * Custom options passed to the underlying {@link AutoscaledPool} constructor.
305
- * Note that the `runTaskFunction` and `isTaskReadyFunction` options
306
- * are provided by the crawler and cannot be overridden.
307
- * However, you can provide a custom implementation of `isFinishedFunction`.
308
- * @property {number} [minConcurrency=1]
309
- * Sets the minimum concurrency (parallelism) for the crawl. Shortcut to the corresponding {@link AutoscaledPool} option.
310
- *
311
- * *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.
312
- * If you're not sure, just keep the default value and the concurrency will scale up automatically.
313
- * @property {number} [maxConcurrency=1000]
314
- * Sets the maximum concurrency (parallelism) for the crawl. Shortcut to the corresponding {@link AutoscaledPool} option.
315
- * @property {boolean} [useSessionPool=true]
316
- * Puppeteer crawler will initialize the {@link SessionPool} with the corresponding `sessionPoolOptions`.
317
- * The session instance will be than available in the `handleRequestFunction`.
318
- * @property {SessionPoolOptions} [sessionPoolOptions] The configuration options for {@link SessionPool} to use.
319
- */
320
- /**
321
- * Provides a simple framework for parallel crawling of web pages
322
- * using headless Chrome with [Puppeteer](https://github.com/puppeteer/puppeteer).
323
- * The URLs to crawl are fed either from a static list of URLs
324
- * or from a dynamic queue of URLs enabling recursive crawling of websites.
325
- *
326
- * Since `PuppeteerCrawler` uses headless Chrome to download web pages and extract data,
327
- * it is useful for crawling of websites that require to execute JavaScript.
328
- * If the target website doesn't need JavaScript, consider using {@link CheerioCrawler},
329
- * which downloads the pages using raw HTTP requests and is about 10x faster.
330
- *
331
- * The source URLs are represented using {@link Request} objects that are fed from
332
- * {@link RequestList} or {@link RequestQueue} instances provided by the {@link PuppeteerCrawlerOptions.requestList}
333
- * or {@link PuppeteerCrawlerOptions.requestQueue} constructor options, respectively.
334
- *
335
- * If both {@link PuppeteerCrawlerOptions.requestList} and {@link PuppeteerCrawlerOptions.requestQueue} are used,
336
- * the instance first processes URLs from the {@link RequestList} and automatically enqueues all of them
337
- * to {@link RequestQueue} before it starts their processing. This ensures that a single URL is not crawled multiple times.
338
- *
339
- * The crawler finishes when there are no more {@link Request} objects to crawl.
340
- *
341
- * `PuppeteerCrawler` opens a new Chrome page (i.e. tab) for each {@link Request} object to crawl
342
- * and then calls the function provided by user as the {@link PuppeteerCrawlerOptions.handlePageFunction} option.
343
- *
344
- * New pages are only opened when there is enough free CPU and memory available,
345
- * using the functionality provided by the {@link AutoscaledPool} class.
346
- * All {@link AutoscaledPool} configuration options can be passed to the {@link PuppeteerCrawlerOptions.autoscaledPoolOptions}
347
- * parameter of the `PuppeteerCrawler` constructor. For user convenience, the `minConcurrency` and `maxConcurrency`
348
- * {@link AutoscaledPoolOptions} are available directly in the `PuppeteerCrawler` constructor.
349
- *
350
- * Note that the pool of Puppeteer instances is internally managed by the {@link BrowserPool} class.
351
- *
352
- * **Example usage:**
353
- *
354
- * ```javascript
355
- * const crawler = new Apify.PuppeteerCrawler({
356
- * requestList,
357
- * handlePageFunction: async ({ page, request }) => {
358
- * // This function is called to extract data from a single web page
359
- * // 'page' is an instance of Puppeteer.Page with page.goto(request.url) already called
360
- * // 'request' is an instance of Request class with information about the page to load
361
- * await Apify.pushData({
362
- * title: await page.title(),
363
- * url: request.url,
364
- * succeeded: true,
365
- * })
366
- * },
367
- * handleFailedRequestFunction: async ({ request }) => {
368
- * // This function is called when the crawling of a request failed too many times
369
- * await Apify.pushData({
370
- * url: request.url,
371
- * succeeded: false,
372
- * errors: request.errorMessages,
373
- * })
374
- * },
375
- * });
376
- *
377
- * await crawler.run();
378
- * ```
379
- * @property {Statistics} stats
380
- * Contains statistics about the current run.
381
- * @property {RequestList} [requestList]
382
- * A reference to the underlying {@link RequestList} class that manages the crawler's {@link Request}s.
383
- * Only available if used by the crawler.
384
- * @property {RequestQueue} [requestQueue]
385
- * A reference to the underlying {@link RequestQueue} class that manages the crawler's {@link Request}s.
386
- * Only available if used by the crawler.
387
- * @property {SessionPool} [sessionPool]
388
- * A reference to the underlying {@link SessionPool} class that manages the crawler's {@link Session}s.
389
- * Only available if used by the crawler.
390
- * @property {ProxyConfiguration} proxyConfiguration
391
- * A reference to the underlying {@link ProxyConfiguration} class that manages the crawler's proxies.
392
- * Only available if used by the crawler.
393
- * @property {BrowserPool} browserPool
394
- * A reference to the underlying `BrowserPool` class that manages the crawler's browsers.
395
- * For more information about it, see the [`browser-pool` module](https://github.com/apify/browser-pool).
396
- * @property {AutoscaledPool} autoscaledPool
397
- * A reference to the underlying {@link AutoscaledPool} class that manages the concurrency of the crawler.
398
- * Note that this property is only initialized after calling the {@link CheerioCrawler#run} function.
399
- * You can use it to change the concurrency settings on the fly,
400
- * to pause the crawler by calling {@link AutoscaledPool#pause}
401
- * or to abort it by calling {@link AutoscaledPool#abort}.
402
- */
403
- declare class PuppeteerCrawler extends BrowserCrawler {
404
- /**
405
- * @param {PuppeteerCrawlerOptions} options
406
- * All `PuppeteerCrawler` parameters are passed via an options object.
407
- */
408
- constructor(options?: PuppeteerCrawlerOptions);
409
- launchContext: PuppeteerLaunchContext;
410
- }
411
- // @ts-ignore optional peer dependency
412
- import { Page } from "puppeteer";
413
- import { BrowserCrawlingContext } from "./browser_crawler";
414
- import { CrawlingContext } from "./basic_crawler";
415
- import { DirectNavigationOptions } from "../typedefs";
416
- import { HandleFailedRequest } from "./basic_crawler";
417
- import { PuppeteerLaunchContext } from "../browser_launchers/puppeteer_launcher";
418
- import { BrowserPoolOptions } from "browser-pool/dist/browser-pool";
419
- import { ProxyConfiguration } from "../proxy_configuration";
420
- import { RequestList } from "../request_list";
421
- import { RequestQueue } from "../storages/request_queue";
422
- import { AutoscaledPoolOptions } from "../autoscaling/autoscaled_pool";
423
- import { SessionPoolOptions } from "../session_pool/session_pool";
424
- import BrowserCrawler from "./browser_crawler";
425
- //# sourceMappingURL=puppeteer_crawler.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"puppeteer_crawler.d.ts","sourceRoot":"","sources":["../../src/crawlers/puppeteer_crawler.js"],"names":[],"mappings":";8CAsBW;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,GAAG,sBAAsB,GAAG,eAAe,eACpF,uBAAuB,KACrB,QAAQ,IAAI,CAAC;;UAIZ,IAAI;aACJ,gBAAgB;;4CAInB,eAAe,GAAG,sBAAsB,GAAG;IAAE,IAAI,EAAE,IAAI,CAAC;IAAC,OAAO,EAAE,gBAAgB,CAAA;CAAE,KAClF,QAAQ,IAAI,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;wBAIZ,mBAAmB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAlBjC;;;;;GAKG;AACH;;;;GAIG;AACH;;;;GAIG;AACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6HG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkFG;AACH;IAWI;;;MAGE;IACF,sBAHU,uBAAuB,EA2ChC;IADG,sCAAkC;CAkBzC"}