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,331 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- /* eslint-disable max-classes-per-file */
5
- const ow_1 = (0, tslib_1.__importDefault)(require("ow"));
6
- const key_value_store_1 = require("../storages/key_value_store");
7
- const constants_1 = require("../constants");
8
- const utils_log_1 = (0, tslib_1.__importDefault)(require("../utils_log"));
9
- const events_1 = (0, tslib_1.__importDefault)(require("../events"));
10
- /**
11
- * @ignore
12
- */
13
- class Job {
14
- constructor() {
15
- this.lastRunAt = null;
16
- this.runs = 0;
17
- }
18
- run() {
19
- this.lastRunAt = Date.now();
20
- return ++this.runs;
21
- }
22
- finish() {
23
- this.durationMillis = Date.now() - this.lastRunAt;
24
- return this.durationMillis;
25
- }
26
- retryCount() {
27
- return Math.max(0, this.runs - 1);
28
- }
29
- }
30
- /**
31
- * The statistics class provides an interface to collecting and logging run
32
- * statistics for requests.
33
- *
34
- * All statistic information is saved on key value store
35
- * under the key SDK_CRAWLER_STATISTICS_*, persists between
36
- * migrations and abort/resurrect
37
- *
38
- * @property {StatisticState} state
39
- * Current statistic state used for doing calculations on {@link Statistics#calculate} calls
40
- * @property {number} id
41
- * Statistic instance id
42
- * @property {number[]} requestRetryHistogram
43
- * Contains the current retries histogram.
44
- * Index 0 means 0 retries, index 2, 2 retries,
45
- * and so on
46
- */
47
- class Statistics {
48
- /**
49
- * @param {StatisticsOptions} [options]
50
- * @hideconstructor
51
- */
52
- constructor(options = {}) {
53
- (0, ow_1.default)(options, ow_1.default.object.exactShape({
54
- logIntervalSecs: ow_1.default.optional.number,
55
- logMessage: ow_1.default.optional.string,
56
- }));
57
- const { logIntervalSecs = 60, logMessage = 'Statistics', } = options;
58
- this.log = utils_log_1.default.child({ prefix: 'Statistics' });
59
- this.logIntervalMillis = logIntervalSecs * 1000;
60
- this.logMessage = logMessage;
61
- this.keyValueStore = null;
62
- // assign an id while incrementing so it can be saved/restored from KV
63
- this.id = Statistics.id++;
64
- this.persistStateKey = `SDK_CRAWLER_STATISTICS_${this.id}`;
65
- this.listener = this.persistState.bind(this);
66
- this.requestRetryHistogram = [];
67
- /**
68
- * @private
69
- * @type {Object<string|number, Job>}
70
- */
71
- this.requestsInProgress = new Map();
72
- // initialize by "resetting"
73
- this.reset();
74
- }
75
- /**
76
- * Set the current statistic instance to pristine values
77
- */
78
- reset() {
79
- this.state = {
80
- requestsFinished: 0,
81
- requestsFailed: 0,
82
- requestsRetries: 0,
83
- requestsFailedPerMinute: 0,
84
- requestsFinishedPerMinute: 0,
85
- requestMinDurationMillis: Infinity,
86
- requestMaxDurationMillis: 0,
87
- requestTotalFailedDurationMillis: 0,
88
- requestTotalFinishedDurationMillis: 0,
89
- crawlerStartedAt: null,
90
- crawlerFinishedAt: null,
91
- statsPersistedAt: null,
92
- crawlerRuntimeMillis: 0,
93
- };
94
- this.requestRetryHistogram.length = 0;
95
- this.requestsInProgress.clear();
96
- this.instanceStart = Date.now();
97
- this._teardown();
98
- }
99
- /**
100
- * Starts a job
101
- *
102
- * @param {number|string} id
103
- * @ignore
104
- */
105
- startJob(id) {
106
- let job = this.requestsInProgress.get(id);
107
- if (!job)
108
- job = new Job();
109
- job.run();
110
- this.requestsInProgress.set(id, job);
111
- }
112
- /**
113
- * Mark job as finished and sets the state
114
- *
115
- * @param {number|string} id
116
- * @ignore
117
- */
118
- finishJob(id) {
119
- const job = this.requestsInProgress.get(id);
120
- if (!job)
121
- return;
122
- const jobDurationMillis = job.finish();
123
- this.state.requestsFinished++;
124
- this.state.requestTotalFinishedDurationMillis += jobDurationMillis;
125
- this._saveRetryCountForJob(job);
126
- if (jobDurationMillis < this.state.requestMinDurationMillis)
127
- this.state.requestMinDurationMillis = jobDurationMillis;
128
- if (jobDurationMillis > this.state.requestMaxDurationMillis)
129
- this.state.requestMaxDurationMillis = jobDurationMillis;
130
- this.requestsInProgress.delete(id);
131
- }
132
- /**
133
- * Mark job as failed and sets the state
134
- *
135
- * @param {number|string} id
136
- * @ignore
137
- */
138
- failJob(id) {
139
- const job = this.requestsInProgress.get(id);
140
- if (!job)
141
- return;
142
- this.state.requestTotalFailedDurationMillis += job.finish();
143
- this.state.requestsFailed++;
144
- this._saveRetryCountForJob(job);
145
- this.requestsInProgress.delete(id);
146
- }
147
- /**
148
- * Calculate the current statistics
149
- */
150
- calculate() {
151
- const { requestsFailed, requestsFinished, requestTotalFailedDurationMillis, requestTotalFinishedDurationMillis, } = this.state;
152
- const totalMillis = Date.now() - this.instanceStart;
153
- const totalMinutes = totalMillis / 1000 / 60;
154
- return {
155
- requestAvgFailedDurationMillis: Math.round(requestTotalFailedDurationMillis / requestsFailed) || Infinity,
156
- requestAvgFinishedDurationMillis: Math.round(requestTotalFinishedDurationMillis / requestsFinished) || Infinity,
157
- requestsFinishedPerMinute: Math.round(requestsFinished / totalMinutes) || 0,
158
- requestsFailedPerMinute: Math.floor(requestsFailed / totalMinutes) || 0,
159
- requestTotalDurationMillis: requestTotalFinishedDurationMillis + requestTotalFailedDurationMillis,
160
- requestsTotal: requestsFailed + requestsFinished,
161
- crawlerRuntimeMillis: totalMillis,
162
- };
163
- }
164
- /**
165
- * Initializes the key value store for persisting the statistics,
166
- * displaying the current state in predefined intervals
167
- */
168
- async startCapturing() {
169
- this.keyValueStore = await (0, key_value_store_1.openKeyValueStore)();
170
- await this._maybeLoadStatistics();
171
- if (this.state.crawlerStartedAt === null) {
172
- this.state.crawlerStartedAt = new Date();
173
- }
174
- events_1.default.on(constants_1.ACTOR_EVENT_NAMES_EX.PERSIST_STATE, this.listener);
175
- this.logInterval = setInterval(() => {
176
- this.log.info(this.logMessage, {
177
- ...this.calculate(),
178
- retryHistogram: this.requestRetryHistogram,
179
- });
180
- }, this.logIntervalMillis);
181
- }
182
- /**
183
- * Stops logging and remove event listeners, then persist
184
- */
185
- async stopCapturing() {
186
- this._teardown();
187
- this.state.crawlerFinishedAt = new Date();
188
- await this.persistState();
189
- }
190
- /**
191
- * @param {Job} job
192
- * @ignore
193
- * @protected
194
- * @internal
195
- */
196
- _saveRetryCountForJob(job) {
197
- const retryCount = job.retryCount();
198
- if (retryCount > 0)
199
- this.state.requestsRetries++;
200
- this.requestRetryHistogram[retryCount] = this.requestRetryHistogram[retryCount]
201
- ? this.requestRetryHistogram[retryCount] + 1
202
- : 1;
203
- }
204
- /**
205
- * Persist internal state to the key value store
206
- */
207
- async persistState() {
208
- // this might be called before startCapturing was called without using await, should not crash
209
- if (!this.keyValueStore) {
210
- return;
211
- }
212
- this.log.debug('Persisting state', { persistStateKey: this.persistStateKey });
213
- await this.keyValueStore.setValue(this.persistStateKey, this.toJSON());
214
- }
215
- /**
216
- * Loads the current statistic from the key value store if any
217
- * @ignore
218
- * @protected
219
- * @internal
220
- */
221
- async _maybeLoadStatistics() {
222
- // this might be called before startCapturing was called without using await, should not crash
223
- if (!this.keyValueStore) {
224
- return;
225
- }
226
- const savedState = await this.keyValueStore.getValue(this.persistStateKey);
227
- if (!savedState)
228
- return;
229
- // We saw a run where the requestRetryHistogram was not iterable and crashed
230
- // the actor. Adding some logging to monitor this problem in the future.
231
- if (!Array.isArray(savedState.requestRetryHistogram)) {
232
- this.log.warning('Received invalid state from Key-value store.', {
233
- persistStateKey: this.persistStateKey,
234
- state: savedState,
235
- });
236
- }
237
- this.log.debug('Recreating state from KeyValueStore', { persistStateKey: this.persistStateKey });
238
- this.requestRetryHistogram.push(...savedState.requestRetryHistogram);
239
- this.state.requestsFinished = savedState.requestsFinished;
240
- this.state.requestsFailed = savedState.requestsFailed;
241
- this.state.requestsRetries = savedState.requestsRetries;
242
- this.state.requestTotalFailedDurationMillis = savedState.requestTotalFailedDurationMillis;
243
- this.state.requestTotalFinishedDurationMillis = savedState.requestTotalFinishedDurationMillis;
244
- this.state.requestMinDurationMillis = savedState.requestMinDurationMillis;
245
- this.state.requestMaxDurationMillis = savedState.requestMaxDurationMillis;
246
- // persisted state uses ISO date strings
247
- this.state.crawlerFinishedAt = savedState.crawlerFinishedAt ? new Date(savedState.crawlerFinishedAt) : null;
248
- this.state.crawlerStartedAt = savedState.crawlerStartedAt ? new Date(savedState.crawlerStartedAt) : null;
249
- this.state.statsPersistedAt = savedState.statsPersistedAt ? new Date(savedState.statsPersistedAt) : null;
250
- this.state.crawlerRuntimeMillis = savedState.crawlerRuntimeMillis;
251
- this.instanceStart = Date.now() - (this.state.statsPersistedAt - savedState.crawlerLastStartTimestamp);
252
- this.log.debug('Loaded from KeyValueStore');
253
- }
254
- /**
255
- * @ignore
256
- * @protected
257
- * @internal
258
- */
259
- _teardown() {
260
- // this can be called before a call to startCapturing happens (or in a 'finally' block)
261
- events_1.default.removeListener(constants_1.ACTOR_EVENT_NAMES_EX.PERSIST_STATE, this.listener);
262
- if (this.logInterval) {
263
- clearInterval(this.logInterval);
264
- this.logInterval = null;
265
- }
266
- }
267
- /**
268
- * Make this class serializable when called with `JSON.stringify(statsInstance)` directly
269
- * or through `keyValueStore.setValue('KEY', statsInstance)`
270
- *
271
- * @returns {StatisticPersistedState & StatisticState}
272
- */
273
- toJSON() {
274
- // merge all the current state information that can be used from the outside
275
- // without the need to reconstruct for the sake of stats.calculate()
276
- // omit duplicated information
277
- return {
278
- ...this.state,
279
- crawlerLastStartTimestamp: this.instanceStart,
280
- crawlerFinishedAt: this.state.crawlerFinishedAt ? new Date(this.state.crawlerFinishedAt).toISOString() : null,
281
- crawlerStartedAt: this.state.crawlerStartedAt ? new Date(this.state.crawlerStartedAt).toISOString() : null,
282
- requestRetryHistogram: this.requestRetryHistogram,
283
- statsId: this.id,
284
- statsPersistedAt: new Date().toISOString(),
285
- ...this.calculate(),
286
- };
287
- }
288
- }
289
- Statistics.id = 0;
290
- exports.default = Statistics;
291
- /**
292
- * @ignore
293
- * @typedef StatisticsOptions
294
- * @property {number} [logIntervalSecs]
295
- * @property {string} [logMessage]
296
- */
297
- /**
298
- * Format of the persisted stats
299
- *
300
- * @typedef StatisticPersistedState
301
- * @property {number[]} requestRetryHistogram
302
- * @property {number} statsId
303
- * @property {number} requestAvgFailedDurationMillis
304
- * @property {number} requestAvgFinishedDurationMillis
305
- * @property {number} requestsFinishedPerMinute
306
- * @property {number} requestsFailedPerMinute
307
- * @property {number} requestTotalDurationMillis
308
- * @property {number} requestsTotal
309
- * @property {number} crawlerRuntimeMillis
310
- * @property {number} crawlerLastStartTimestamp
311
- * @property {string} statsPersistedAt
312
- */
313
- /**
314
- * Contains the statistics state
315
- *
316
- * @typedef StatisticState
317
- * @property {number} requestsFinished
318
- * @property {number} requestsFailed
319
- * @property {number} requestsRetries
320
- * @property {number} requestsFailedPerMinute
321
- * @property {number} requestsFinishedPerMinute
322
- * @property {number} requestMinDurationMillis
323
- * @property {number} requestMaxDurationMillis
324
- * @property {number} requestTotalFailedDurationMillis
325
- * @property {number} requestTotalFinishedDurationMillis
326
- * @property {Date|string|null} crawlerStartedAt
327
- * @property {Date|string|null} crawlerFinishedAt
328
- * @property {number} crawlerRuntimeMillis
329
- * @property {Date|string|null} statsPersistedAt
330
- */
331
- //# sourceMappingURL=statistics.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"statistics.js","sourceRoot":"","sources":["../../src/crawlers/statistics.js"],"names":[],"mappings":";;;AAAA,yCAAyC;AACzC,yDAAoB;AACpB,iEAAgE;AAChE,4CAAoD;AACpD,0EAAsC;AACtC,oEAA+B;AAE/B;;GAEG;AACH,MAAM,GAAG;IACL;QACI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;QACtB,IAAI,CAAC,IAAI,GAAG,CAAC,CAAC;IAClB,CAAC;IAED,GAAG;QACC,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC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AC,EAAE,GAAG,CAAC,CAAC;AAElB,kBAAe,UAAU,CAAC;AAE1B;;;;;GAKG;AAEH;;;;;;;;;;;;;;;GAeG;AAEH;;;;;;;;;;;;;;;;;GAiBG"}
@@ -1,179 +0,0 @@
1
- /**
2
- * The function finds elements matching a specific CSS selector in a Puppeteer page,
3
- * clicks all those elements using a mouse move and a left mouse button click and intercepts
4
- * all the navigation requests that are subsequently produced by the page. The intercepted
5
- * requests, including their methods, headers and payloads are then enqueued to a provided
6
- * {@link RequestQueue}. This is useful to crawl JavaScript heavy pages where links are not available
7
- * in `href` elements, but rather navigations are triggered in click handlers.
8
- * If you're looking to find URLs in `href` attributes of the page, see {@link utils#enqueueLinks}.
9
- *
10
- * Optionally, the function allows you to filter the target links' URLs using an array of {@link PseudoUrl} objects
11
- * and override settings of the enqueued {@link Request} objects.
12
- *
13
- * **IMPORTANT**: To be able to do this, this function uses various mutations on the page,
14
- * such as changing the Z-index of elements being clicked and their visibility. Therefore,
15
- * it is recommended to only use this function as the last operation in the page.
16
- *
17
- * **USING HEADFUL BROWSER**: When using a headful browser, this function will only be able to click elements
18
- * in the focused tab, effectively limiting concurrency to 1. In headless mode, full concurrency can be achieved.
19
- *
20
- * **PERFORMANCE**: Clicking elements with a mouse and intercepting requests is not a low level operation
21
- * that takes nanoseconds. It's not very CPU intensive, but it takes time. We strongly recommend limiting
22
- * the scope of the clicking as much as possible by using a specific selector that targets only the elements
23
- * that you assume or know will produce a navigation. You can certainly click everything by using
24
- * the `*` selector, but be prepared to wait minutes to get results on a large and complex page.
25
- *
26
- * **Example usage**
27
- *
28
- * ```javascript
29
- * await Apify.utils.puppeteer.enqueueLinksByClickingElements({
30
- * page,
31
- * requestQueue,
32
- * selector: 'a.product-detail',
33
- * pseudoUrls: [
34
- * 'https://www.example.com/handbags/[.*]'
35
- * 'https://www.example.com/purses/[.*]'
36
- * ],
37
- * });
38
- * ```
39
- * @param {object} options
40
- * All `enqueueLinksByClickingElements()` parameters are passed
41
- * via an options object with the following keys:
42
- * @param {Page} options.page
43
- * Puppeteer [`Page`](https://pptr.dev/#?product=Puppeteer&show=api-class-page) object.
44
- * @param {RequestQueue} options.requestQueue
45
- * A request queue to which the URLs will be enqueued.
46
- * @param {string} options.selector
47
- * A CSS selector matching elements to be clicked on. Unlike in {@link utils#enqueueLinks}, there is no default
48
- * value. This is to prevent suboptimal use of this function by using it too broadly.
49
- * @param {Array<(string|RegExp|Object<string, *>)>} [options.pseudoUrls]
50
- * An array of {@link PseudoUrl}s matching the URLs to be enqueued,
51
- * or an array of strings or RegExps or plain Objects from which the {@link PseudoUrl}s can be constructed.
52
- *
53
- * The plain objects must include at least the `purl` property, which holds the pseudo-URL string or RegExp.
54
- * All remaining keys will be used as the `requestTemplate` argument of the {@link PseudoUrl} constructor,
55
- * which lets you specify special properties for the enqueued {@link Request} objects.
56
- *
57
- * If `pseudoUrls` is an empty array, `null` or `undefined`, then the function
58
- * enqueues all links found on the page.
59
- * @param {object} [options.clickOptions]
60
- * click options for use in Puppeteer's click handler
61
- * @param {number} [options.clickOptions.clickCount]
62
- * Number of clicks to be executed. Defaults to 1
63
- * @param {number} [options.clickOptions.delay]
64
- * Time to wait between mousedown and mouseup in milliseconds. Defaults to 0
65
- * @param {RequestTransform} [options.transformRequestFunction]
66
- * Just before a new {@link Request} is constructed and enqueued to the {@link RequestQueue}, this function can be used
67
- * to remove it or modify its contents such as `userData`, `payload` or, most importantly `uniqueKey`. This is useful
68
- * when you need to enqueue multiple `Requests` to the queue that share the same URL, but differ in methods or payloads,
69
- * or to dynamically update or create `userData`.
70
- *
71
- * For example: by adding `useExtendedUniqueKey: true` to the `request` object, `uniqueKey` will be computed from
72
- * a combination of `url`, `method` and `payload` which enables crawling of websites that navigate using form submits
73
- * (POST requests).
74
- *
75
- * **Example:**
76
- * ```javascript
77
- * {
78
- * transformRequestFunction: (request) => {
79
- * request.userData.foo = 'bar';
80
- * request.useExtendedUniqueKey = true;
81
- * return request;
82
- * }
83
- * }
84
- * ```
85
- * @param {number} [options.waitForPageIdleSecs=1]
86
- * Clicking in the page triggers various asynchronous operations that lead to new URLs being shown
87
- * by the browser. It could be a simple JavaScript redirect or opening of a new tab in the browser.
88
- * These events often happen only some time after the actual click. Requests typically take milliseconds
89
- * while new tabs open in hundreds of milliseconds.
90
- *
91
- * To be able to capture all those events, the `enqueueLinksByClickingElements()` function repeatedly waits
92
- * for the `waitForPageIdleSecs`. By repeatedly we mean that whenever a relevant event is triggered, the timer
93
- * is restarted. As long as new events keep coming, the function will not return, unless
94
- * the below `maxWaitForPageIdleSecs` timeout is reached.
95
- *
96
- * You may want to reduce this for example when you're sure that your clicks do not open new tabs,
97
- * or increase when you're not getting all the expected URLs.
98
- * @param {number} [options.maxWaitForPageIdleSecs=5]
99
- * This is the maximum period for which the function will keep tracking events, even if more events keep coming.
100
- * Its purpose is to prevent a deadlock in the page by periodic events, often unrelated to the clicking itself.
101
- * See `waitForPageIdleSecs` above for an explanation.
102
- * @return {Promise<Array<QueueOperationInfo>>}
103
- * Promise that resolves to an array of {@link QueueOperationInfo} objects.
104
- * @memberOf puppeteer
105
- * @name enqueueLinksByClickingElements
106
- * @function
107
- */
108
- export function enqueueLinksByClickingElements(options: {
109
- page: Page;
110
- requestQueue: RequestQueue;
111
- selector: string;
112
- pseudoUrls?: (string | RegExp | {
113
- [x: string]: any;
114
- })[] | undefined;
115
- clickOptions?: {
116
- clickCount?: number | undefined;
117
- delay?: number | undefined;
118
- } | undefined;
119
- transformRequestFunction?: RequestTransform | undefined;
120
- waitForPageIdleSecs?: number | undefined;
121
- maxWaitForPageIdleSecs?: number | undefined;
122
- }): Promise<Array<QueueOperationInfo>>;
123
- /**
124
- * Clicks all elements of given page matching given selector.
125
- * Catches and intercepts all initiated navigation requests and opened pages.
126
- * Returns a list of all target URLs.
127
- *
128
- * @param {object} options
129
- * @param {Page} options.page
130
- * @param {string} options.selector
131
- * @param {number} [options.waitForPageIdleMillis]
132
- * @param {number} [options.maxWaitForPageIdleMillis]
133
- * @param {object} [clickOptions]
134
- * @param {number} [clickOptions.clickCount]
135
- * @param {number} [clickOptions.delay]
136
- * @return {Promise<Array<*>>}
137
- * @ignore
138
- */
139
- export function clickElementsAndInterceptNavigationRequests(options: {
140
- page: Page;
141
- selector: string;
142
- waitForPageIdleMillis?: number | undefined;
143
- maxWaitForPageIdleMillis?: number | undefined;
144
- }): Promise<Array<any>>;
145
- /**
146
- * We're only interested in pages created by the page we're currently clicking in.
147
- * There will generally be a lot of other targets being created in the browser.
148
- * @param {Page} page
149
- * @param {Target} target
150
- * @return {boolean}
151
- */
152
- export function isTargetRelevant(page: Page, target: Target): boolean;
153
- /**
154
- * Click all elements matching the given selector. To be able to do this using
155
- * Puppeteer's `.click()` we need to make sure the elements are reachable by mouse,
156
- * so we first move them to the top of the page's stacking context and then click.
157
- * We do all in series to prevent elements from hiding one another. Therefore,
158
- * for large element sets, this will take considerable amount of time.
159
- *
160
- * @param {Page} page
161
- * @param {string} selector
162
- * @param {object} [clickOptions]
163
- * @param {number} [clickOptions.clickCount]
164
- * @param {number} [clickOptions.delay]
165
- * @return {Promise<void>}
166
- * @ignore
167
- */
168
- export function clickElements(page: Page, selector: string, clickOptions?: {
169
- clickCount?: number | undefined;
170
- delay?: number | undefined;
171
- } | undefined): Promise<void>;
172
- // @ts-ignore optional peer dependency
173
- import { Page } from "puppeteer";
174
- import { RequestQueue } from "../storages/request_queue";
175
- import { RequestTransform } from "./shared";
176
- import { QueueOperationInfo } from "../storages/request_queue";
177
- // @ts-ignore optional peer dependency
178
- import { Target } from "puppeteer";
179
- //# sourceMappingURL=click_elements.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"click_elements.d.ts","sourceRoot":"","sources":["../../src/enqueue_links/click_elements.js"],"names":[],"mappings":"AAkBA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA0GG;AACH;IAlEyB,IAAI,EAAlB,IAAI;IAEkB,YAAY,EAAlC,YAAY;IAEI,QAAQ,EAAxB,MAAM;IAG6C,UAAU;;;IAU5C,YAAY;;;;IAMF,wBAAwB;IAoBlC,mBAAmB;IAanB,sBAAsB;IAItC,QAAQ,MAAM,kBAAkB,CAAC,CAAC,CA8C7C;AAED;;;;;;;;;;;;;;;GAeG;AACH;IAVyB,IAAI,EAAlB,IAAI;IACY,QAAQ,EAAxB,MAAM;IACW,qBAAqB;IACrB,wBAAwB;IAIxC,QAAQ,UAAQ,CAAC,CAoC5B;AA6DD;;;;;;GAMG;AACH,uCAJW,IAAI,UACJ,MAAM,GACL,OAAO,CAKlB;AA2CD;;;;;;;;;;;;;;GAcG;AACH,oCARW,IAAI,YACJ,MAAM;;;gBAIL,QAAQ,IAAI,CAAC,CAyBxB"}