@crawlee/puppeteer 3.0.0-alpha.0 → 3.0.0-alpha.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/LICENSE.md +201 -0
- package/{README.md → dist/README.md} +0 -0
- package/dist/index.d.ts +12 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +12 -0
- package/dist/index.js.map +1 -0
- package/dist/index.mjs +76 -0
- package/dist/internals/enqueue-links/click-elements.d.ts +188 -0
- package/dist/internals/enqueue-links/click-elements.d.ts.map +1 -0
- package/dist/internals/enqueue-links/click-elements.js +336 -0
- package/dist/internals/enqueue-links/click-elements.js.map +1 -0
- package/dist/internals/puppeteer-crawler.d.ts +149 -0
- package/dist/internals/puppeteer-crawler.d.ts.map +1 -0
- package/dist/internals/puppeteer-crawler.js +117 -0
- package/dist/internals/puppeteer-crawler.js.map +1 -0
- package/dist/internals/puppeteer-launcher.d.ts +134 -0
- package/dist/internals/puppeteer-launcher.d.ts.map +1 -0
- package/dist/internals/puppeteer-launcher.js +146 -0
- package/dist/internals/puppeteer-launcher.js.map +1 -0
- package/dist/internals/stealth/hiding_tricks.d.ts +10 -0
- package/dist/internals/stealth/hiding_tricks.d.ts.map +1 -0
- package/dist/internals/stealth/hiding_tricks.js +334 -0
- package/dist/internals/stealth/hiding_tricks.js.map +1 -0
- package/dist/internals/stealth/index.d.ts +40 -0
- package/dist/internals/stealth/index.d.ts.map +1 -0
- package/dist/internals/stealth/index.js +108 -0
- package/dist/internals/stealth/index.js.map +1 -0
- package/dist/internals/utils/puppeteer_request_interception.d.ts +60 -0
- package/dist/internals/utils/puppeteer_request_interception.d.ts.map +1 -0
- package/dist/internals/utils/puppeteer_request_interception.js +225 -0
- package/dist/internals/utils/puppeteer_request_interception.js.map +1 -0
- package/dist/internals/utils/puppeteer_utils.d.ts +298 -0
- package/dist/internals/utils/puppeteer_utils.d.ts.map +1 -0
- package/dist/internals/utils/puppeteer_utils.js +468 -0
- package/dist/internals/utils/puppeteer_utils.js.map +1 -0
- package/dist/package.json +66 -0
- package/dist/tsconfig.build.tsbuildinfo +1 -0
- package/package.json +8 -7
package/dist/LICENSE.md
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "{}"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2018 Apify Technologies s.r.o.
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
|
File without changes
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export * from '@crawlee/browser';
|
|
2
|
+
export * from './internals/puppeteer-crawler';
|
|
3
|
+
export * from './internals/puppeteer-launcher';
|
|
4
|
+
export * as puppeteerStealth from './internals/stealth';
|
|
5
|
+
export type { StealthOptions } from './internals/stealth';
|
|
6
|
+
export * as puppeteerRequestInterception from './internals/utils/puppeteer_request_interception';
|
|
7
|
+
export type { InterceptHandler } from './internals/utils/puppeteer_request_interception';
|
|
8
|
+
export * as puppeteerUtils from './internals/utils/puppeteer_utils';
|
|
9
|
+
export type { BlockRequestsOptions, CompiledScriptFunction, CompiledScriptParams, DirectNavigationOptions as PuppeteerDirectNavigationOptions, InfiniteScrollOptions, InjectFileOptions, SaveSnapshotOptions, } from './internals/utils/puppeteer_utils';
|
|
10
|
+
export * as puppeteerClickElements from './internals/enqueue-links/click-elements';
|
|
11
|
+
export type { EnqueueLinksByClickingElementsOptions } from './internals/enqueue-links/click-elements';
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,kBAAkB,CAAC;AACjC,cAAc,+BAA+B,CAAC;AAC9C,cAAc,gCAAgC,CAAC;AAE/C,OAAO,KAAK,gBAAgB,MAAM,qBAAqB,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAE1D,OAAO,KAAK,4BAA4B,MAAM,kDAAkD,CAAC;AACjG,YAAY,EAAE,gBAAgB,EAAE,MAAM,kDAAkD,CAAC;AAEzF,OAAO,KAAK,cAAc,MAAM,mCAAmC,CAAC;AACpE,YAAY,EACR,oBAAoB,EACpB,sBAAsB,EACtB,oBAAoB,EACpB,uBAAuB,IAAI,gCAAgC,EAC3D,qBAAqB,EACrB,iBAAiB,EACjB,mBAAmB,GACtB,MAAM,mCAAmC,CAAC;AAE3C,OAAO,KAAK,sBAAsB,MAAM,0CAA0C,CAAC;AACnF,YAAY,EAAE,qCAAqC,EAAE,MAAM,0CAA0C,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.puppeteerClickElements = exports.puppeteerUtils = exports.puppeteerRequestInterception = exports.puppeteerStealth = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
tslib_1.__exportStar(require("@crawlee/browser"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./internals/puppeteer-crawler"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./internals/puppeteer-launcher"), exports);
|
|
8
|
+
exports.puppeteerStealth = tslib_1.__importStar(require("./internals/stealth"));
|
|
9
|
+
exports.puppeteerRequestInterception = tslib_1.__importStar(require("./internals/utils/puppeteer_request_interception"));
|
|
10
|
+
exports.puppeteerUtils = tslib_1.__importStar(require("./internals/utils/puppeteer_utils"));
|
|
11
|
+
exports.puppeteerClickElements = tslib_1.__importStar(require("./internals/enqueue-links/click-elements"));
|
|
12
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;AAAA,2DAAiC;AACjC,wEAA8C;AAC9C,yEAA+C;AAE/C,gFAAwD;AAGxD,yHAAiG;AAGjG,4FAAoE;AAWpE,2GAAmF"}
|
package/dist/index.mjs
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import mod from "./index.js";
|
|
2
|
+
|
|
3
|
+
export default mod;
|
|
4
|
+
export const API_PROCESSED_REQUESTS_DELAY_MILLIS = mod.API_PROCESSED_REQUESTS_DELAY_MILLIS;
|
|
5
|
+
export const AutoscaledPool = mod.AutoscaledPool;
|
|
6
|
+
export const BASIC_CRAWLER_TIMEOUT_BUFFER_SECS = mod.BASIC_CRAWLER_TIMEOUT_BUFFER_SECS;
|
|
7
|
+
export const BasicCrawler = mod.BasicCrawler;
|
|
8
|
+
export const BrowserCrawler = mod.BrowserCrawler;
|
|
9
|
+
export const BrowserLauncher = mod.BrowserLauncher;
|
|
10
|
+
export const Configuration = mod.Configuration;
|
|
11
|
+
export const CookieParseError = mod.CookieParseError;
|
|
12
|
+
export const CrawlerExtension = mod.CrawlerExtension;
|
|
13
|
+
export const DATASET_ITERATORS_DEFAULT_LIMIT = mod.DATASET_ITERATORS_DEFAULT_LIMIT;
|
|
14
|
+
export const Dataset = mod.Dataset;
|
|
15
|
+
export const EVENT_SESSION_RETIRED = mod.EVENT_SESSION_RETIRED;
|
|
16
|
+
export const EnqueueStrategy = mod.EnqueueStrategy;
|
|
17
|
+
export const EventManager = mod.EventManager;
|
|
18
|
+
export const EventType = mod.EventType;
|
|
19
|
+
export const KeyValueStore = mod.KeyValueStore;
|
|
20
|
+
export const LocalEventManager = mod.LocalEventManager;
|
|
21
|
+
export const Log = mod.Log;
|
|
22
|
+
export const LogLevel = mod.LogLevel;
|
|
23
|
+
export const Logger = mod.Logger;
|
|
24
|
+
export const LoggerJson = mod.LoggerJson;
|
|
25
|
+
export const LoggerText = mod.LoggerText;
|
|
26
|
+
export const MAX_QUERIES_FOR_CONSISTENCY = mod.MAX_QUERIES_FOR_CONSISTENCY;
|
|
27
|
+
export const ProxyConfiguration = mod.ProxyConfiguration;
|
|
28
|
+
export const PuppeteerCrawler = mod.PuppeteerCrawler;
|
|
29
|
+
export const PuppeteerLauncher = mod.PuppeteerLauncher;
|
|
30
|
+
export const QUERY_HEAD_BUFFER = mod.QUERY_HEAD_BUFFER;
|
|
31
|
+
export const QUERY_HEAD_MIN_LENGTH = mod.QUERY_HEAD_MIN_LENGTH;
|
|
32
|
+
export const REQUESTS_PERSISTENCE_KEY = mod.REQUESTS_PERSISTENCE_KEY;
|
|
33
|
+
export const Request = mod.Request;
|
|
34
|
+
export const RequestList = mod.RequestList;
|
|
35
|
+
export const RequestQueue = mod.RequestQueue;
|
|
36
|
+
export const STATE_PERSISTENCE_KEY = mod.STATE_PERSISTENCE_KEY;
|
|
37
|
+
export const STATUS_CODES_BLOCKED = mod.STATUS_CODES_BLOCKED;
|
|
38
|
+
export const STORAGE_CONSISTENCY_DELAY_MILLIS = mod.STORAGE_CONSISTENCY_DELAY_MILLIS;
|
|
39
|
+
export const Session = mod.Session;
|
|
40
|
+
export const SessionPool = mod.SessionPool;
|
|
41
|
+
export const Snapshotter = mod.Snapshotter;
|
|
42
|
+
export const Statistics = mod.Statistics;
|
|
43
|
+
export const StorageManager = mod.StorageManager;
|
|
44
|
+
export const SystemStatus = mod.SystemStatus;
|
|
45
|
+
export const basicCrawlerEnqueueLinks = mod.basicCrawlerEnqueueLinks;
|
|
46
|
+
export const browserCrawlerEnqueueLinks = mod.browserCrawlerEnqueueLinks;
|
|
47
|
+
export const checkAndSerialize = mod.checkAndSerialize;
|
|
48
|
+
export const chunkBySize = mod.chunkBySize;
|
|
49
|
+
export const constructGlobObjectsFromGlobs = mod.constructGlobObjectsFromGlobs;
|
|
50
|
+
export const constructRegExpObjectsFromPseudoUrls = mod.constructRegExpObjectsFromPseudoUrls;
|
|
51
|
+
export const constructRegExpObjectsFromRegExps = mod.constructRegExpObjectsFromRegExps;
|
|
52
|
+
export const createDeserialize = mod.createDeserialize;
|
|
53
|
+
export const createRequestOptions = mod.createRequestOptions;
|
|
54
|
+
export const createRequests = mod.createRequests;
|
|
55
|
+
export const deserializeArray = mod.deserializeArray;
|
|
56
|
+
export const diffCookies = mod.diffCookies;
|
|
57
|
+
export const enqueueLinks = mod.enqueueLinks;
|
|
58
|
+
export const getCookiesFromResponse = mod.getCookiesFromResponse;
|
|
59
|
+
export const getRequestId = mod.getRequestId;
|
|
60
|
+
export const handleRequestTimeout = mod.handleRequestTimeout;
|
|
61
|
+
export const launchPuppeteer = mod.launchPuppeteer;
|
|
62
|
+
export const log = mod.log;
|
|
63
|
+
export const maybeStringify = mod.maybeStringify;
|
|
64
|
+
export const mergeCookies = mod.mergeCookies;
|
|
65
|
+
export const openDataset = mod.openDataset;
|
|
66
|
+
export const puppeteerClickElements = mod.puppeteerClickElements;
|
|
67
|
+
export const puppeteerRequestInterception = mod.puppeteerRequestInterception;
|
|
68
|
+
export const puppeteerStealth = mod.puppeteerStealth;
|
|
69
|
+
export const puppeteerUtils = mod.puppeteerUtils;
|
|
70
|
+
export const pushData = mod.pushData;
|
|
71
|
+
export const serializeArray = mod.serializeArray;
|
|
72
|
+
export const storage = mod.storage;
|
|
73
|
+
export const throwOnBlockedRequest = mod.throwOnBlockedRequest;
|
|
74
|
+
export const updateEnqueueLinksPatternCache = mod.updateEnqueueLinksPatternCache;
|
|
75
|
+
export const validateGlobPattern = mod.validateGlobPattern;
|
|
76
|
+
export const validators = mod.validators;
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { GlobInput, PseudoUrlInput, RegExpInput, RequestTransform, RequestQueue, storage } from '@crawlee/browser';
|
|
2
|
+
import { Dictionary } from '@crawlee/utils';
|
|
3
|
+
import { ClickOptions, Page, Target } from 'puppeteer';
|
|
4
|
+
export interface EnqueueLinksByClickingElementsOptions {
|
|
5
|
+
/**
|
|
6
|
+
* Puppeteer [`Page`](https://pptr.dev/#?product=Puppeteer&show=api-class-page) object.
|
|
7
|
+
*/
|
|
8
|
+
page: Page;
|
|
9
|
+
/**
|
|
10
|
+
* A request queue to which the URLs will be enqueued.
|
|
11
|
+
*/
|
|
12
|
+
requestQueue: RequestQueue;
|
|
13
|
+
/**
|
|
14
|
+
* A CSS selector matching elements to be clicked on. Unlike in {@link enqueueLinks}, there is no default
|
|
15
|
+
* value. This is to prevent suboptimal use of this function by using it too broadly.
|
|
16
|
+
*/
|
|
17
|
+
selector: string;
|
|
18
|
+
/**
|
|
19
|
+
* Click options for use in Puppeteer's click handler.
|
|
20
|
+
*/
|
|
21
|
+
clickOptions?: ClickOptions;
|
|
22
|
+
/**
|
|
23
|
+
* An array of glob pattern strings or plain objects
|
|
24
|
+
* containing glob pattern strings matching the URLs to be enqueued.
|
|
25
|
+
*
|
|
26
|
+
* The plain objects must include at least the `glob` property, which holds the glob pattern string.
|
|
27
|
+
* All remaining keys will be used as request options for the corresponding enqueued {@link Request} objects.
|
|
28
|
+
*
|
|
29
|
+
* The matching is always case-insensitive.
|
|
30
|
+
* If you need case-sensitive matching, use `regexps` property directly.
|
|
31
|
+
*
|
|
32
|
+
* If `globs` is an empty array or `undefined`, then the function
|
|
33
|
+
* enqueues all the intercepted navigation requests produced by the page
|
|
34
|
+
* after clicking on elements matching the provided CSS selector.
|
|
35
|
+
*/
|
|
36
|
+
globs?: GlobInput[];
|
|
37
|
+
/**
|
|
38
|
+
* An array of regular expressions or plain objects
|
|
39
|
+
* containing regular expressions matching the URLs to be enqueued.
|
|
40
|
+
*
|
|
41
|
+
* The plain objects must include at least the `regexp` property, which holds the regular expression.
|
|
42
|
+
* All remaining keys will be used as request options for the corresponding enqueued {@link Request} objects.
|
|
43
|
+
*
|
|
44
|
+
* If `regexps` is an empty array or `undefined`, then the function
|
|
45
|
+
* enqueues all the intercepted navigation requests produced by the page
|
|
46
|
+
* after clicking on elements matching the provided CSS selector.
|
|
47
|
+
*/
|
|
48
|
+
regexps?: RegExpInput[];
|
|
49
|
+
/**
|
|
50
|
+
* *NOTE:* In future versions of SDK the options will be removed.
|
|
51
|
+
* Please use `globs` or `regexps` instead.
|
|
52
|
+
*
|
|
53
|
+
* An array of {@link PseudoUrl} strings or plain objects
|
|
54
|
+
* containing {@link PseudoUrl} strings matching the URLs to be enqueued.
|
|
55
|
+
*
|
|
56
|
+
* The plain objects must include at least the `purl` property, which holds the pseudo-URL pattern string.
|
|
57
|
+
* All remaining keys will be used as request options for the corresponding enqueued {@link Request} objects.
|
|
58
|
+
*
|
|
59
|
+
* With a pseudo-URL string, the matching is always case-insensitive.
|
|
60
|
+
* If you need case-sensitive matching, use `regexps` property directly.
|
|
61
|
+
*
|
|
62
|
+
* If `pseudoUrls` is an empty array or `undefined`, then the function
|
|
63
|
+
* enqueues all the intercepted navigation requests produced by the page
|
|
64
|
+
* after clicking on elements matching the provided CSS selector.
|
|
65
|
+
*
|
|
66
|
+
* @deprecated prefer using `globs` or `regexps` instead
|
|
67
|
+
*/
|
|
68
|
+
pseudoUrls?: PseudoUrlInput[];
|
|
69
|
+
/**
|
|
70
|
+
* Just before a new {@link Request} is constructed and enqueued to the {@link RequestQueue}, this function can be used
|
|
71
|
+
* to remove it or modify its contents such as `userData`, `payload` or, most importantly `uniqueKey`. This is useful
|
|
72
|
+
* when you need to enqueue multiple `Requests` to the queue that share the same URL, but differ in methods or payloads,
|
|
73
|
+
* or to dynamically update or create `userData`.
|
|
74
|
+
*
|
|
75
|
+
* For example: by adding `useExtendedUniqueKey: true` to the `request` object, `uniqueKey` will be computed from
|
|
76
|
+
* a combination of `url`, `method` and `payload` which enables crawling of websites that navigate using form submits
|
|
77
|
+
* (POST requests).
|
|
78
|
+
*
|
|
79
|
+
* **Example:**
|
|
80
|
+
* ```javascript
|
|
81
|
+
* {
|
|
82
|
+
* transformRequestFunction: (request) => {
|
|
83
|
+
* request.userData.foo = 'bar';
|
|
84
|
+
* request.useExtendedUniqueKey = true;
|
|
85
|
+
* return request;
|
|
86
|
+
* }
|
|
87
|
+
* }
|
|
88
|
+
* ```
|
|
89
|
+
*/
|
|
90
|
+
transformRequestFunction?: RequestTransform;
|
|
91
|
+
/**
|
|
92
|
+
* Clicking in the page triggers various asynchronous operations that lead to new URLs being shown
|
|
93
|
+
* by the browser. It could be a simple JavaScript redirect or opening of a new tab in the browser.
|
|
94
|
+
* These events often happen only some time after the actual click. Requests typically take milliseconds
|
|
95
|
+
* while new tabs open in hundreds of milliseconds.
|
|
96
|
+
*
|
|
97
|
+
* To be able to capture all those events, the `enqueueLinksByClickingElements()` function repeatedly waits
|
|
98
|
+
* for the `waitForPageIdleSecs`. By repeatedly we mean that whenever a relevant event is triggered, the timer
|
|
99
|
+
* is restarted. As long as new events keep coming, the function will not return, unless
|
|
100
|
+
* the below `maxWaitForPageIdleSecs` timeout is reached.
|
|
101
|
+
*
|
|
102
|
+
* You may want to reduce this for example when you're sure that your clicks do not open new tabs,
|
|
103
|
+
* or increase when you're not getting all the expected URLs.
|
|
104
|
+
* @default 1
|
|
105
|
+
*/
|
|
106
|
+
waitForPageIdleSecs?: number;
|
|
107
|
+
/**
|
|
108
|
+
* This is the maximum period for which the function will keep tracking events, even if more events keep coming.
|
|
109
|
+
* Its purpose is to prevent a deadlock in the page by periodic events, often unrelated to the clicking itself.
|
|
110
|
+
* See `waitForPageIdleSecs` above for an explanation.
|
|
111
|
+
* @default 5
|
|
112
|
+
*/
|
|
113
|
+
maxWaitForPageIdleSecs?: number;
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* The function finds elements matching a specific CSS selector in a Puppeteer page,
|
|
117
|
+
* clicks all those elements using a mouse move and a left mouse button click and intercepts
|
|
118
|
+
* all the navigation requests that are subsequently produced by the page. The intercepted
|
|
119
|
+
* requests, including their methods, headers and payloads are then enqueued to a provided
|
|
120
|
+
* {@link RequestQueue}. This is useful to crawl JavaScript heavy pages where links are not available
|
|
121
|
+
* in `href` elements, but rather navigations are triggered in click handlers.
|
|
122
|
+
* If you're looking to find URLs in `href` attributes of the page, see {@link enqueueLinks}.
|
|
123
|
+
*
|
|
124
|
+
* Optionally, the function allows you to filter the target links' URLs using an array of {@link PseudoUrl} objects
|
|
125
|
+
* and override settings of the enqueued {@link Request} objects.
|
|
126
|
+
*
|
|
127
|
+
* **IMPORTANT**: To be able to do this, this function uses various mutations on the page,
|
|
128
|
+
* such as changing the Z-index of elements being clicked and their visibility. Therefore,
|
|
129
|
+
* it is recommended to only use this function as the last operation in the page.
|
|
130
|
+
*
|
|
131
|
+
* **USING HEADFUL BROWSER**: When using a headful browser, this function will only be able to click elements
|
|
132
|
+
* in the focused tab, effectively limiting concurrency to 1. In headless mode, full concurrency can be achieved.
|
|
133
|
+
*
|
|
134
|
+
* **PERFORMANCE**: Clicking elements with a mouse and intercepting requests is not a low level operation
|
|
135
|
+
* that takes nanoseconds. It's not very CPU intensive, but it takes time. We strongly recommend limiting
|
|
136
|
+
* the scope of the clicking as much as possible by using a specific selector that targets only the elements
|
|
137
|
+
* that you assume or know will produce a navigation. You can certainly click everything by using
|
|
138
|
+
* the `*` selector, but be prepared to wait minutes to get results on a large and complex page.
|
|
139
|
+
*
|
|
140
|
+
* **Example usage**
|
|
141
|
+
*
|
|
142
|
+
* ```javascript
|
|
143
|
+
* await Actor.utils.puppeteer.enqueueLinksByClickingElements({
|
|
144
|
+
* page,
|
|
145
|
+
* requestQueue,
|
|
146
|
+
* selector: 'a.product-detail',
|
|
147
|
+
* pseudoUrls: [
|
|
148
|
+
* 'https://www.example.com/handbags/[.*]'
|
|
149
|
+
* 'https://www.example.com/purses/[.*]'
|
|
150
|
+
* ],
|
|
151
|
+
* });
|
|
152
|
+
* ```
|
|
153
|
+
*
|
|
154
|
+
* @returns Promise that resolves to {@link BatchAddRequestsResult} object.
|
|
155
|
+
*/
|
|
156
|
+
export declare function enqueueLinksByClickingElements(options: EnqueueLinksByClickingElementsOptions): Promise<storage.BatchAddRequestsResult>;
|
|
157
|
+
interface WaitForPageIdleOptions {
|
|
158
|
+
page: Page;
|
|
159
|
+
waitForPageIdleMillis?: number;
|
|
160
|
+
maxWaitForPageIdleMillis?: number;
|
|
161
|
+
}
|
|
162
|
+
interface ClickElementsAndInterceptNavigationRequestsOptions extends WaitForPageIdleOptions {
|
|
163
|
+
selector: string;
|
|
164
|
+
clickOptions?: ClickOptions;
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Clicks all elements of given page matching given selector.
|
|
168
|
+
* Catches and intercepts all initiated navigation requests and opened pages.
|
|
169
|
+
* Returns a list of all target URLs.
|
|
170
|
+
* @ignore
|
|
171
|
+
*/
|
|
172
|
+
export declare function clickElementsAndInterceptNavigationRequests(options: ClickElementsAndInterceptNavigationRequestsOptions): Promise<Dictionary[]>;
|
|
173
|
+
/**
|
|
174
|
+
* We're only interested in pages created by the page we're currently clicking in.
|
|
175
|
+
* There will generally be a lot of other targets being created in the browser.
|
|
176
|
+
*/
|
|
177
|
+
export declare function isTargetRelevant(page: Page, target: Target): boolean;
|
|
178
|
+
/**
|
|
179
|
+
* Click all elements matching the given selector. To be able to do this using
|
|
180
|
+
* Puppeteer's `.click()` we need to make sure the elements are reachable by mouse,
|
|
181
|
+
* so we first move them to the top of the page's stacking context and then click.
|
|
182
|
+
* We do all in series to prevent elements from hiding one another. Therefore,
|
|
183
|
+
* for large element sets, this will take considerable amount of time.
|
|
184
|
+
* @ignore
|
|
185
|
+
*/
|
|
186
|
+
export declare function clickElements(page: Page, selector: string, clickOptions?: ClickOptions): Promise<void>;
|
|
187
|
+
export {};
|
|
188
|
+
//# sourceMappingURL=click-elements.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"click-elements.d.ts","sourceRoot":"","sources":["../../../src/internals/enqueue-links/click-elements.ts"],"names":[],"mappings":"AAAA,OAAO,EAMH,SAAS,EACT,cAAc,EACd,WAAW,EACX,gBAAgB,EAEhB,YAAY,EACZ,OAAO,EACV,MAAM,kBAAkB,CAAC;AAE1B,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAE5C,OAAO,EAGH,YAAY,EAGZ,IAAI,EAEJ,MAAM,EACT,MAAM,WAAW,CAAC;AAOnB,MAAM,WAAW,qCAAqC;IAClD;;OAEG;IACH,IAAI,EAAE,IAAI,CAAC;IAEX;;OAEG;IACH,YAAY,EAAE,YAAY,CAAC;IAE3B;;;OAGG;IACH,QAAQ,EAAE,MAAM,CAAC;IAEjB;;OAEG;IACH,YAAY,CAAC,EAAE,YAAY,CAAC;IAE5B;;;;;;;;;;;;;OAaG;IACH,KAAK,CAAC,EAAE,SAAS,EAAE,CAAC;IAEpB;;;;;;;;;;OAUG;IACH,OAAO,CAAC,EAAE,WAAW,EAAE,CAAC;IAExB;;;;;;;;;;;;;;;;;;OAkBG;IACH,UAAU,CAAC,EAAE,cAAc,EAAE,CAAC;IAE9B;;;;;;;;;;;;;;;;;;;;OAoBG;IACH,wBAAwB,CAAC,EAAE,gBAAgB,CAAC;IAE5C;;;;;;;;;;;;;;OAcG;IACH,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAE7B;;;;;OAKG;IACH,sBAAsB,CAAC,EAAE,MAAM,CAAC;CACnC;AAED;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwCG;AACH,wBAAsB,8BAA8B,CAAC,OAAO,EAAE,qCAAqC,GAAG,OAAO,CAAC,OAAO,CAAC,sBAAsB,CAAC,CAmE5I;AAED,UAAU,sBAAsB;IAC5B,IAAI,EAAE,IAAI,CAAC;IACX,qBAAqB,CAAC,EAAE,MAAM,CAAC;IAC/B,wBAAwB,CAAC,EAAE,MAAM,CAAC;CACrC;AAED,UAAU,kDAAmD,SAAQ,sBAAsB;IACvF,QAAQ,EAAE,MAAM,CAAC;IACjB,YAAY,CAAC,EAAE,YAAY,CAAC;CAC/B;AAED;;;;;GAKG;AACH,wBAAsB,2CAA2C,CAAC,OAAO,EAAE,kDAAkD,GAAG,OAAO,CAAC,UAAU,EAAE,CAAC,CAiCpJ;AAoDD;;;GAGG;AACH,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAGpE;AAiDD;;;;;;;GAOG;AACH,wBAAsB,aAAa,CAAC,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,EAAE,YAAY,CAAC,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAuB5G"}
|