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.
- package/README.md +6 -5
- package/package.json +69 -128
- package/build/actor.d.ts +0 -113
- package/build/actor.d.ts.map +0 -1
- package/build/actor.js +0 -582
- package/build/actor.js.map +0 -1
- package/build/apify.d.ts +0 -752
- package/build/apify.d.ts.map +0 -1
- package/build/apify.js +0 -877
- package/build/apify.js.map +0 -1
- package/build/autoscaling/autoscaled_pool.d.ts +0 -384
- package/build/autoscaling/autoscaled_pool.d.ts.map +0 -1
- package/build/autoscaling/autoscaled_pool.js +0 -557
- package/build/autoscaling/autoscaled_pool.js.map +0 -1
- package/build/autoscaling/snapshotter.d.ts +0 -278
- package/build/autoscaling/snapshotter.d.ts.map +0 -1
- package/build/autoscaling/snapshotter.js +0 -447
- package/build/autoscaling/snapshotter.js.map +0 -1
- package/build/autoscaling/system_status.d.ts +0 -224
- package/build/autoscaling/system_status.d.ts.map +0 -1
- package/build/autoscaling/system_status.js +0 -228
- package/build/autoscaling/system_status.js.map +0 -1
- package/build/browser_launchers/browser_launcher.d.ts +0 -154
- package/build/browser_launchers/browser_launcher.d.ts.map +0 -1
- package/build/browser_launchers/browser_launcher.js +0 -160
- package/build/browser_launchers/browser_launcher.js.map +0 -1
- package/build/browser_launchers/browser_plugin.d.ts +0 -23
- package/build/browser_launchers/browser_plugin.d.ts.map +0 -1
- package/build/browser_launchers/browser_plugin.js +0 -25
- package/build/browser_launchers/browser_plugin.js.map +0 -1
- package/build/browser_launchers/playwright_launcher.d.ts +0 -131
- package/build/browser_launchers/playwright_launcher.d.ts.map +0 -1
- package/build/browser_launchers/playwright_launcher.js +0 -150
- package/build/browser_launchers/playwright_launcher.js.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.d.ts +0 -153
- package/build/browser_launchers/puppeteer_launcher.d.ts.map +0 -1
- package/build/browser_launchers/puppeteer_launcher.js +0 -197
- package/build/browser_launchers/puppeteer_launcher.js.map +0 -1
- package/build/cache_container.d.ts +0 -31
- package/build/cache_container.d.ts.map +0 -1
- package/build/cache_container.js +0 -48
- package/build/cache_container.js.map +0 -1
- package/build/configuration.d.ts +0 -226
- package/build/configuration.d.ts.map +0 -1
- package/build/configuration.js +0 -325
- package/build/configuration.js.map +0 -1
- package/build/constants.d.ts +0 -37
- package/build/constants.d.ts.map +0 -1
- package/build/constants.js +0 -41
- package/build/constants.js.map +0 -1
- package/build/crawlers/basic_crawler.d.ts +0 -443
- package/build/crawlers/basic_crawler.d.ts.map +0 -1
- package/build/crawlers/basic_crawler.js +0 -664
- package/build/crawlers/basic_crawler.js.map +0 -1
- package/build/crawlers/browser_crawler.d.ts +0 -512
- package/build/crawlers/browser_crawler.d.ts.map +0 -1
- package/build/crawlers/browser_crawler.js +0 -540
- package/build/crawlers/browser_crawler.js.map +0 -1
- package/build/crawlers/cheerio_crawler.d.ts +0 -931
- package/build/crawlers/cheerio_crawler.d.ts.map +0 -1
- package/build/crawlers/cheerio_crawler.js +0 -913
- package/build/crawlers/cheerio_crawler.js.map +0 -1
- package/build/crawlers/crawler_extension.d.ts +0 -10
- package/build/crawlers/crawler_extension.d.ts.map +0 -1
- package/build/crawlers/crawler_extension.js +0 -19
- package/build/crawlers/crawler_extension.js.map +0 -1
- package/build/crawlers/crawler_utils.d.ts +0 -34
- package/build/crawlers/crawler_utils.d.ts.map +0 -1
- package/build/crawlers/crawler_utils.js +0 -87
- package/build/crawlers/crawler_utils.js.map +0 -1
- package/build/crawlers/playwright_crawler.d.ts +0 -448
- package/build/crawlers/playwright_crawler.d.ts.map +0 -1
- package/build/crawlers/playwright_crawler.js +0 -299
- package/build/crawlers/playwright_crawler.js.map +0 -1
- package/build/crawlers/puppeteer_crawler.d.ts +0 -425
- package/build/crawlers/puppeteer_crawler.d.ts.map +0 -1
- package/build/crawlers/puppeteer_crawler.js +0 -299
- package/build/crawlers/puppeteer_crawler.js.map +0 -1
- package/build/crawlers/statistics.d.ts +0 -185
- package/build/crawlers/statistics.d.ts.map +0 -1
- package/build/crawlers/statistics.js +0 -331
- package/build/crawlers/statistics.js.map +0 -1
- package/build/enqueue_links/click_elements.d.ts +0 -179
- package/build/enqueue_links/click_elements.d.ts.map +0 -1
- package/build/enqueue_links/click_elements.js +0 -434
- package/build/enqueue_links/click_elements.js.map +0 -1
- package/build/enqueue_links/enqueue_links.d.ts +0 -117
- package/build/enqueue_links/enqueue_links.d.ts.map +0 -1
- package/build/enqueue_links/enqueue_links.js +0 -163
- package/build/enqueue_links/enqueue_links.js.map +0 -1
- package/build/enqueue_links/shared.d.ts +0 -42
- package/build/enqueue_links/shared.d.ts.map +0 -1
- package/build/enqueue_links/shared.js +0 -121
- package/build/enqueue_links/shared.js.map +0 -1
- package/build/errors.d.ts +0 -29
- package/build/errors.d.ts.map +0 -1
- package/build/errors.js +0 -38
- package/build/errors.js.map +0 -1
- package/build/events.d.ts +0 -11
- package/build/events.d.ts.map +0 -1
- package/build/events.js +0 -147
- package/build/events.js.map +0 -1
- package/build/index.d.ts +0 -4
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -7
- package/build/index.js.map +0 -1
- package/build/main.d.ts +0 -179
- package/build/main.d.ts.map +0 -1
- package/build/main.js +0 -81
- package/build/main.js.map +0 -1
- package/build/playwright_utils.d.ts +0 -9
- package/build/playwright_utils.d.ts.map +0 -1
- package/build/playwright_utils.js +0 -90
- package/build/playwright_utils.js.map +0 -1
- package/build/proxy_configuration.d.ts +0 -411
- package/build/proxy_configuration.d.ts.map +0 -1
- package/build/proxy_configuration.js +0 -517
- package/build/proxy_configuration.js.map +0 -1
- package/build/pseudo_url.d.ts +0 -86
- package/build/pseudo_url.d.ts.map +0 -1
- package/build/pseudo_url.js +0 -153
- package/build/pseudo_url.js.map +0 -1
- package/build/puppeteer_request_interception.d.ts +0 -8
- package/build/puppeteer_request_interception.d.ts.map +0 -1
- package/build/puppeteer_request_interception.js +0 -235
- package/build/puppeteer_request_interception.js.map +0 -1
- package/build/puppeteer_utils.d.ts +0 -250
- package/build/puppeteer_utils.d.ts.map +0 -1
- package/build/puppeteer_utils.js +0 -551
- package/build/puppeteer_utils.js.map +0 -1
- package/build/request.d.ts +0 -180
- package/build/request.d.ts.map +0 -1
- package/build/request.js +0 -261
- package/build/request.js.map +0 -1
- package/build/request_list.d.ts +0 -581
- package/build/request_list.d.ts.map +0 -1
- package/build/request_list.js +0 -826
- package/build/request_list.js.map +0 -1
- package/build/serialization.d.ts +0 -5
- package/build/serialization.d.ts.map +0 -1
- package/build/serialization.js +0 -139
- package/build/serialization.js.map +0 -1
- package/build/session_pool/errors.d.ts +0 -11
- package/build/session_pool/errors.d.ts.map +0 -1
- package/build/session_pool/errors.js +0 -18
- package/build/session_pool/errors.js.map +0 -1
- package/build/session_pool/events.d.ts +0 -5
- package/build/session_pool/events.d.ts.map +0 -1
- package/build/session_pool/events.js +0 -6
- package/build/session_pool/events.js.map +0 -1
- package/build/session_pool/session.d.ts +0 -286
- package/build/session_pool/session.d.ts.map +0 -1
- package/build/session_pool/session.js +0 -355
- package/build/session_pool/session.js.map +0 -1
- package/build/session_pool/session_pool.d.ts +0 -280
- package/build/session_pool/session_pool.d.ts.map +0 -1
- package/build/session_pool/session_pool.js +0 -393
- package/build/session_pool/session_pool.js.map +0 -1
- package/build/session_pool/session_utils.d.ts +0 -4
- package/build/session_pool/session_utils.d.ts.map +0 -1
- package/build/session_pool/session_utils.js +0 -24
- package/build/session_pool/session_utils.js.map +0 -1
- package/build/stealth/hiding_tricks.d.ts +0 -22
- package/build/stealth/hiding_tricks.d.ts.map +0 -1
- package/build/stealth/hiding_tricks.js +0 -308
- package/build/stealth/hiding_tricks.js.map +0 -1
- package/build/stealth/stealth.d.ts +0 -56
- package/build/stealth/stealth.d.ts.map +0 -1
- package/build/stealth/stealth.js +0 -125
- package/build/stealth/stealth.js.map +0 -1
- package/build/storages/dataset.d.ts +0 -288
- package/build/storages/dataset.d.ts.map +0 -1
- package/build/storages/dataset.js +0 -480
- package/build/storages/dataset.js.map +0 -1
- package/build/storages/key_value_store.d.ts +0 -243
- package/build/storages/key_value_store.d.ts.map +0 -1
- package/build/storages/key_value_store.js +0 -462
- package/build/storages/key_value_store.js.map +0 -1
- package/build/storages/request_queue.d.ts +0 -318
- package/build/storages/request_queue.d.ts.map +0 -1
- package/build/storages/request_queue.js +0 -636
- package/build/storages/request_queue.js.map +0 -1
- package/build/storages/storage_manager.d.ts +0 -87
- package/build/storages/storage_manager.d.ts.map +0 -1
- package/build/storages/storage_manager.js +0 -150
- package/build/storages/storage_manager.js.map +0 -1
- package/build/tsconfig.tsbuildinfo +0 -1
- package/build/typedefs.d.ts +0 -146
- package/build/typedefs.d.ts.map +0 -1
- package/build/typedefs.js +0 -88
- package/build/typedefs.js.map +0 -1
- package/build/utils.d.ts +0 -175
- package/build/utils.d.ts.map +0 -1
- package/build/utils.js +0 -731
- package/build/utils.js.map +0 -1
- package/build/utils_log.d.ts +0 -41
- package/build/utils_log.d.ts.map +0 -1
- package/build/utils_log.js +0 -192
- package/build/utils_log.js.map +0 -1
- package/build/utils_request.d.ts +0 -77
- package/build/utils_request.d.ts.map +0 -1
- package/build/utils_request.js +0 -385
- package/build/utils_request.js.map +0 -1
- package/build/utils_social.d.ts +0 -210
- package/build/utils_social.d.ts.map +0 -1
- package/build/utils_social.js +0 -787
- package/build/utils_social.js.map +0 -1
- package/build/validators.d.ts +0 -23
- package/build/validators.d.ts.map +0 -1
- package/build/validators.js +0 -29
- package/build/validators.js.map +0 -1
|
@@ -1,411 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @callback ProxyConfigurationFunction
|
|
3
|
-
* @param {string|number} sessionId
|
|
4
|
-
* @returns {string}
|
|
5
|
-
*/
|
|
6
|
-
/**
|
|
7
|
-
* @typedef ProxyConfigurationOptions
|
|
8
|
-
* @property {string} [password]
|
|
9
|
-
* User's password for the proxy. By default, it is taken from the `APIFY_PROXY_PASSWORD`
|
|
10
|
-
* environment variable, which is automatically set by the system when running the actors.
|
|
11
|
-
* @property {string[]} [groups]
|
|
12
|
-
* An array of proxy groups to be used by the [Apify Proxy](https://docs.apify.com/proxy).
|
|
13
|
-
* If not provided, the proxy will select the groups automatically.
|
|
14
|
-
* @property {string} [countryCode]
|
|
15
|
-
* If set and relevant proxies are available in your Apify account, all proxied requests will
|
|
16
|
-
* use IP addresses that are geolocated to the specified country. For example `GB` for IPs
|
|
17
|
-
* from Great Britain. Note that online services often have their own rules for handling
|
|
18
|
-
* geolocation and thus the country selection is a best attempt at geolocation, rather than
|
|
19
|
-
* a guaranteed hit. This parameter is optional, by default, each proxied request is assigned
|
|
20
|
-
* an IP address from a random country. The country code needs to be a two letter ISO country code. See the
|
|
21
|
-
* [full list of available country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements).
|
|
22
|
-
* This parameter is optional, by default, the proxy uses all available proxy servers from all countries.
|
|
23
|
-
* on the Apify cloud, or when using the [Apify CLI](https://github.com/apify/apify-cli).
|
|
24
|
-
* @property {string[]} [apifyProxyGroups]
|
|
25
|
-
* Same option as `groups` which can be used to
|
|
26
|
-
* configurate the proxy by UI input schema. You should use the `groups` option in your crawler code.
|
|
27
|
-
* @property {string} [apifyProxyCountry]
|
|
28
|
-
* Same option as `countryCode` which can be used to
|
|
29
|
-
* configurate the proxy by UI input schema. You should use the `countryCode` option in your crawler code.
|
|
30
|
-
* @property {string[]} [proxyUrls]
|
|
31
|
-
* An array of custom proxy URLs to be rotated.
|
|
32
|
-
* Custom proxies are not compatible with Apify Proxy and an attempt to use both
|
|
33
|
-
* configuration options will cause an error to be thrown on initialize.
|
|
34
|
-
* @property {ProxyConfigurationFunction} [newUrlFunction]
|
|
35
|
-
* Custom function that allows you to generate the new proxy URL dynamically. It gets the `sessionId` as a parameter
|
|
36
|
-
* and should always return stringified proxy URL.
|
|
37
|
-
* This function is used to generate the URL when {@link ProxyConfiguration.newUrl} or {@link ProxyConfiguration.newProxyInfo} is called.
|
|
38
|
-
*/
|
|
39
|
-
/**
|
|
40
|
-
* The main purpose of the ProxyInfo object is to provide information
|
|
41
|
-
* about the current proxy connection used by the crawler for the request.
|
|
42
|
-
* Outside of crawlers, you can get this object by calling {@link ProxyConfiguration.newProxyInfo}.
|
|
43
|
-
*
|
|
44
|
-
* **Example usage:**
|
|
45
|
-
*
|
|
46
|
-
* ```javascript
|
|
47
|
-
*
|
|
48
|
-
* const proxyConfiguration = await Apify.createProxyConfiguration({
|
|
49
|
-
* groups: ['GROUP1', 'GROUP2'] // List of Apify Proxy groups
|
|
50
|
-
* countryCode: 'US',
|
|
51
|
-
* });
|
|
52
|
-
*
|
|
53
|
-
* // Getting proxyInfo object by calling class method directly
|
|
54
|
-
* const proxyInfo = proxyConfiguration.newProxyInfo();
|
|
55
|
-
*
|
|
56
|
-
* // In crawler
|
|
57
|
-
* const crawler = new Apify.CheerioCrawler({
|
|
58
|
-
* // ...
|
|
59
|
-
* proxyConfiguration,
|
|
60
|
-
* handlePageFunction: ({ proxyInfo }) => {
|
|
61
|
-
* // Getting used proxy URL
|
|
62
|
-
* const proxyUrl = proxyInfo.url;
|
|
63
|
-
*
|
|
64
|
-
* // Getting ID of used Session
|
|
65
|
-
* const sessionIdentifier = proxyInfo.sessionId;
|
|
66
|
-
* }
|
|
67
|
-
* })
|
|
68
|
-
*
|
|
69
|
-
* ```
|
|
70
|
-
* @typedef ProxyInfo
|
|
71
|
-
* @property {string} [sessionId]
|
|
72
|
-
* The identifier of used {@link Session}, if used.
|
|
73
|
-
* @property {string} url
|
|
74
|
-
* The URL of the proxy.
|
|
75
|
-
* @property {string[]} groups
|
|
76
|
-
* An array of proxy groups to be used by the [Apify Proxy](https://docs.apify.com/proxy).
|
|
77
|
-
* If not provided, the proxy will select the groups automatically.
|
|
78
|
-
* @property {string} [countryCode]
|
|
79
|
-
* If set and relevant proxies are available in your Apify account, all proxied requests will
|
|
80
|
-
* use IP addresses that are geolocated to the specified country. For example `GB` for IPs
|
|
81
|
-
* from Great Britain. Note that online services often have their own rules for handling
|
|
82
|
-
* geolocation and thus the country selection is a best attempt at geolocation, rather than
|
|
83
|
-
* a guaranteed hit. This parameter is optional, by default, each proxied request is assigned
|
|
84
|
-
* an IP address from a random country. The country code needs to be a two letter ISO country code. See the
|
|
85
|
-
* [full list of available country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements).
|
|
86
|
-
* This parameter is optional, by default, the proxy uses all available proxy servers from all countries.
|
|
87
|
-
* @property {string} password
|
|
88
|
-
* User's password for the proxy. By default, it is taken from the `APIFY_PROXY_PASSWORD`
|
|
89
|
-
* environment variable, which is automatically set by the system when running the actors
|
|
90
|
-
* on the Apify cloud, or when using the [Apify CLI](https://github.com/apify/apify-cli).
|
|
91
|
-
* @property {string} hostname
|
|
92
|
-
* Hostname of your proxy.
|
|
93
|
-
* @property {string} port
|
|
94
|
-
* Proxy port.
|
|
95
|
-
*/
|
|
96
|
-
/**
|
|
97
|
-
* Configures connection to a proxy server with the provided options. Proxy servers are used to prevent target websites from blocking
|
|
98
|
-
* your crawlers based on IP address rate limits or blacklists. Setting proxy configuration in your crawlers automatically configures
|
|
99
|
-
* them to use the selected proxies for all connections. You can get information about the currently used proxy by inspecting
|
|
100
|
-
* the {@link ProxyInfo} property in your crawler's page function. There, you can inspect the proxy's URL and other attributes.
|
|
101
|
-
*
|
|
102
|
-
* The proxy servers are managed by [Apify Proxy](https://docs.apify.com/proxy). To be able to use Apify Proxy,
|
|
103
|
-
* you need an Apify account and access to the selected proxies. If you provide no configuration option,
|
|
104
|
-
* the proxies will be managed automatically using a smart algorithm.
|
|
105
|
-
*
|
|
106
|
-
* If you want to use your own proxies, use the {@link ProxyConfigurationOptions.proxyUrls} option. Your list of proxy URLs will
|
|
107
|
-
* be rotated by the configuration if this option is provided.
|
|
108
|
-
*
|
|
109
|
-
* **Example usage:**
|
|
110
|
-
*
|
|
111
|
-
* ```javascript
|
|
112
|
-
*
|
|
113
|
-
* const proxyConfiguration = await Apify.createProxyConfiguration({
|
|
114
|
-
* groups: ['GROUP1', 'GROUP2'] // List of Apify Proxy groups
|
|
115
|
-
* countryCode: 'US',
|
|
116
|
-
* });
|
|
117
|
-
*
|
|
118
|
-
* const crawler = new Apify.CheerioCrawler({
|
|
119
|
-
* // ...
|
|
120
|
-
* proxyConfiguration,
|
|
121
|
-
* handlePageFunction: ({ proxyInfo }) => {
|
|
122
|
-
* const usedProxyUrl = proxyInfo.url; // Getting the proxy URL
|
|
123
|
-
* }
|
|
124
|
-
* })
|
|
125
|
-
*
|
|
126
|
-
* ```
|
|
127
|
-
* @hideconstructor
|
|
128
|
-
*/
|
|
129
|
-
export class ProxyConfiguration {
|
|
130
|
-
/**
|
|
131
|
-
* Configuration of proxy.
|
|
132
|
-
*
|
|
133
|
-
* @param {ProxyConfigurationOptions} [options] All `ProxyConfiguration` options.
|
|
134
|
-
* @param {Configuration} [config]
|
|
135
|
-
*/
|
|
136
|
-
constructor(options?: ProxyConfigurationOptions | undefined, config?: Configuration | undefined);
|
|
137
|
-
groups: string[];
|
|
138
|
-
countryCode: string | undefined;
|
|
139
|
-
password: string | number | boolean;
|
|
140
|
-
hostname: string | number | boolean;
|
|
141
|
-
port: string | number | boolean;
|
|
142
|
-
nextCustomUrlIndex: number;
|
|
143
|
-
proxyUrls: string[];
|
|
144
|
-
usedProxyUrls: Map<any, any>;
|
|
145
|
-
newUrlFunction: (ProxyConfigurationFunction & Function) | undefined;
|
|
146
|
-
usesApifyProxy: boolean;
|
|
147
|
-
log: import("@apify/log/log").Log;
|
|
148
|
-
config: Configuration;
|
|
149
|
-
isManInTheMiddle: boolean;
|
|
150
|
-
/**
|
|
151
|
-
* Loads proxy password if token is provided and checks access to Apify Proxy and provided proxy groups
|
|
152
|
-
* if Apify Proxy configuration is used.
|
|
153
|
-
* Also checks if country has access to Apify Proxy groups if the country code is provided.
|
|
154
|
-
*
|
|
155
|
-
* You should use the {@link Apify.createProxyConfiguration} function to create a pre-initialized
|
|
156
|
-
* `ProxyConfiguration` instance instead of calling this manually.
|
|
157
|
-
*
|
|
158
|
-
* @returns {Promise<void>}
|
|
159
|
-
*/
|
|
160
|
-
initialize(): Promise<void>;
|
|
161
|
-
/**
|
|
162
|
-
* This function creates a new {@link ProxyInfo} info object.
|
|
163
|
-
* It is used by CheerioCrawler and PuppeteerCrawler to generate proxy URLs and also to allow the user to inspect
|
|
164
|
-
* the currently used proxy via the handlePageFunction parameter: proxyInfo.
|
|
165
|
-
* Use it if you want to work with a rich representation of a proxy URL.
|
|
166
|
-
* If you need the URL string only, use {@link ProxyConfiguration.newUrl}.
|
|
167
|
-
* @param {string|number} [sessionId]
|
|
168
|
-
* Represents the identifier of user {@link Session} that can be managed by the {@link SessionPool} or
|
|
169
|
-
* you can use the Apify Proxy [Session](https://docs.apify.com/proxy#sessions) identifier.
|
|
170
|
-
* When the provided sessionId is a number, it's converted to a string. Property sessionId of
|
|
171
|
-
* {@link ProxyInfo} is always returned as a type string.
|
|
172
|
-
*
|
|
173
|
-
* All the HTTP requests going through the proxy with the same session identifier
|
|
174
|
-
* will use the same target proxy server (i.e. the same IP address).
|
|
175
|
-
* The identifier must not be longer than 50 characters and include only the following: `0-9`, `a-z`, `A-Z`, `"."`, `"_"` and `"~"`.
|
|
176
|
-
* @return {ProxyInfo} represents information about used proxy and its configuration.
|
|
177
|
-
*/
|
|
178
|
-
newProxyInfo(sessionId?: string | number | undefined): ProxyInfo;
|
|
179
|
-
/**
|
|
180
|
-
* Returns a new proxy URL based on provided configuration options and the `sessionId` parameter.
|
|
181
|
-
* @param {string|number} [sessionId]
|
|
182
|
-
* Represents the identifier of user {@link Session} that can be managed by the {@link SessionPool} or
|
|
183
|
-
* you can use the Apify Proxy [Session](https://docs.apify.com/proxy#sessions) identifier.
|
|
184
|
-
* When the provided sessionId is a number, it's converted to a string.
|
|
185
|
-
*
|
|
186
|
-
* All the HTTP requests going through the proxy with the same session identifier
|
|
187
|
-
* will use the same target proxy server (i.e. the same IP address).
|
|
188
|
-
* The identifier must not be longer than 50 characters and include only the following: `0-9`, `a-z`, `A-Z`, `"."`, `"_"` and `"~"`.
|
|
189
|
-
* @return {string} A string with a proxy URL, including authentication credentials and port number.
|
|
190
|
-
* For example, `http://bob:password123@proxy.example.com:8000`
|
|
191
|
-
*/
|
|
192
|
-
newUrl(sessionId?: string | number | undefined): string;
|
|
193
|
-
/**
|
|
194
|
-
* Returns proxy username.
|
|
195
|
-
* @param {string} [sessionId]
|
|
196
|
-
* @return {string} the proxy username
|
|
197
|
-
* @ignore
|
|
198
|
-
* @protected
|
|
199
|
-
* @internal
|
|
200
|
-
*/
|
|
201
|
-
protected _getUsername(sessionId?: string | undefined): string;
|
|
202
|
-
/**
|
|
203
|
-
* Checks if Apify Token is provided in env
|
|
204
|
-
* and gets the password via API and sets it to env
|
|
205
|
-
* @returns {Promise<void>}
|
|
206
|
-
* @ignore
|
|
207
|
-
* @protected
|
|
208
|
-
* @internal
|
|
209
|
-
*/
|
|
210
|
-
protected _setPasswordIfToken(): Promise<void>;
|
|
211
|
-
/**
|
|
212
|
-
* Checks whether the user has access to the proxies specified in the provided ProxyConfigurationOptions.
|
|
213
|
-
* If the check can not be made, it only prints a warning and allows the program to continue. This is to
|
|
214
|
-
* prevent program crashes caused by short downtimes of Proxy.
|
|
215
|
-
*
|
|
216
|
-
* @returns {Promise<void>}
|
|
217
|
-
* @protected
|
|
218
|
-
* @ignore
|
|
219
|
-
* @internal
|
|
220
|
-
*/
|
|
221
|
-
protected _checkAccess(): Promise<void>;
|
|
222
|
-
/**
|
|
223
|
-
* Apify Proxy can be down for a second or a minute, but this should not crash processes.
|
|
224
|
-
*
|
|
225
|
-
* @return {Promise<{ connected: boolean, connectionError: string } | undefined>}
|
|
226
|
-
* @protected
|
|
227
|
-
* @ignore
|
|
228
|
-
* @internal
|
|
229
|
-
*/
|
|
230
|
-
protected _fetchStatus(): Promise<{
|
|
231
|
-
connected: boolean;
|
|
232
|
-
connectionError: string;
|
|
233
|
-
} | undefined>;
|
|
234
|
-
/**
|
|
235
|
-
* Handles custom url rotation with session
|
|
236
|
-
* @param {string} [sessionId]
|
|
237
|
-
* @returns {string} url
|
|
238
|
-
* @protected
|
|
239
|
-
* @ignore
|
|
240
|
-
* @internal
|
|
241
|
-
*/
|
|
242
|
-
protected _handleCustomUrl(sessionId?: string | undefined): string;
|
|
243
|
-
/**
|
|
244
|
-
* Calls the custom newUrlFunction and checks format of its return value
|
|
245
|
-
* @param {string} [sessionId]
|
|
246
|
-
* @protected
|
|
247
|
-
* @ignore
|
|
248
|
-
* @internal
|
|
249
|
-
*/
|
|
250
|
-
protected _callNewUrlFunction(sessionId?: string | undefined): string | undefined;
|
|
251
|
-
/**
|
|
252
|
-
* Throws invalid custom newUrlFunction return
|
|
253
|
-
* @param {Error} err
|
|
254
|
-
* @protected
|
|
255
|
-
* @ignore
|
|
256
|
-
* @internal
|
|
257
|
-
*/
|
|
258
|
-
protected _throwNewUrlFunctionInvalid(err: Error): void;
|
|
259
|
-
/**
|
|
260
|
-
* Throws invalid proxy value error
|
|
261
|
-
* @param {string} param
|
|
262
|
-
* @param {string} value
|
|
263
|
-
* @protected
|
|
264
|
-
* @ignore
|
|
265
|
-
* @internal
|
|
266
|
-
*/
|
|
267
|
-
protected _throwInvalidProxyValueError(param: string, value: string): void;
|
|
268
|
-
/**
|
|
269
|
-
* Throws Apify Proxy is not connected
|
|
270
|
-
* @protected
|
|
271
|
-
* @ignore
|
|
272
|
-
* @internal
|
|
273
|
-
*/
|
|
274
|
-
protected _throwApifyProxyConnectionError(errorMessage: any): void;
|
|
275
|
-
/**
|
|
276
|
-
* Throws cannot combine custom proxies with Apify Proxy
|
|
277
|
-
* @protected
|
|
278
|
-
* @ignore
|
|
279
|
-
* @internal
|
|
280
|
-
*/
|
|
281
|
-
protected _throwCannotCombineCustomWithApify(): void;
|
|
282
|
-
/**
|
|
283
|
-
* Throws cannot combine custom 2 custom methods
|
|
284
|
-
* @protected
|
|
285
|
-
* @ignore
|
|
286
|
-
* @internal
|
|
287
|
-
*/
|
|
288
|
-
protected _throwCannotCombineCustomMethods(): void;
|
|
289
|
-
}
|
|
290
|
-
export function createProxyConfiguration(proxyConfigurationOptions?: ProxyConfigurationOptions | undefined): Promise<ProxyConfiguration | undefined>;
|
|
291
|
-
export type ProxyConfigurationFunction = (sessionId: string | number) => string;
|
|
292
|
-
export type ProxyConfigurationOptions = {
|
|
293
|
-
/**
|
|
294
|
-
* User's password for the proxy. By default, it is taken from the `APIFY_PROXY_PASSWORD`
|
|
295
|
-
* environment variable, which is automatically set by the system when running the actors.
|
|
296
|
-
*/
|
|
297
|
-
password?: string | undefined;
|
|
298
|
-
/**
|
|
299
|
-
* An array of proxy groups to be used by the [Apify Proxy](https://docs.apify.com/proxy).
|
|
300
|
-
* If not provided, the proxy will select the groups automatically.
|
|
301
|
-
*/
|
|
302
|
-
groups?: string[] | undefined;
|
|
303
|
-
/**
|
|
304
|
-
* If set and relevant proxies are available in your Apify account, all proxied requests will
|
|
305
|
-
* use IP addresses that are geolocated to the specified country. For example `GB` for IPs
|
|
306
|
-
* from Great Britain. Note that online services often have their own rules for handling
|
|
307
|
-
* geolocation and thus the country selection is a best attempt at geolocation, rather than
|
|
308
|
-
* a guaranteed hit. This parameter is optional, by default, each proxied request is assigned
|
|
309
|
-
* an IP address from a random country. The country code needs to be a two letter ISO country code. See the
|
|
310
|
-
* [full list of available country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements).
|
|
311
|
-
* This parameter is optional, by default, the proxy uses all available proxy servers from all countries.
|
|
312
|
-
* on the Apify cloud, or when using the [Apify CLI](https://github.com/apify/apify-cli).
|
|
313
|
-
*/
|
|
314
|
-
countryCode?: string | undefined;
|
|
315
|
-
/**
|
|
316
|
-
* Same option as `groups` which can be used to
|
|
317
|
-
* configurate the proxy by UI input schema. You should use the `groups` option in your crawler code.
|
|
318
|
-
*/
|
|
319
|
-
apifyProxyGroups?: string[] | undefined;
|
|
320
|
-
/**
|
|
321
|
-
* Same option as `countryCode` which can be used to
|
|
322
|
-
* configurate the proxy by UI input schema. You should use the `countryCode` option in your crawler code.
|
|
323
|
-
*/
|
|
324
|
-
apifyProxyCountry?: string | undefined;
|
|
325
|
-
/**
|
|
326
|
-
* An array of custom proxy URLs to be rotated.
|
|
327
|
-
* Custom proxies are not compatible with Apify Proxy and an attempt to use both
|
|
328
|
-
* configuration options will cause an error to be thrown on initialize.
|
|
329
|
-
*/
|
|
330
|
-
proxyUrls?: string[] | undefined;
|
|
331
|
-
/**
|
|
332
|
-
* Custom function that allows you to generate the new proxy URL dynamically. It gets the `sessionId` as a parameter
|
|
333
|
-
* and should always return stringified proxy URL.
|
|
334
|
-
* This function is used to generate the URL when {@link ProxyConfiguration.newUrl } or {@link ProxyConfiguration.newProxyInfo } is called.
|
|
335
|
-
*/
|
|
336
|
-
newUrlFunction?: ProxyConfigurationFunction | undefined;
|
|
337
|
-
};
|
|
338
|
-
/**
|
|
339
|
-
* The main purpose of the ProxyInfo object is to provide information
|
|
340
|
-
* about the current proxy connection used by the crawler for the request.
|
|
341
|
-
* Outside of crawlers, you can get this object by calling {@link ProxyConfiguration.newProxyInfo }.
|
|
342
|
-
*
|
|
343
|
-
* **Example usage:**
|
|
344
|
-
*
|
|
345
|
-
* ```javascript
|
|
346
|
-
*
|
|
347
|
-
* const proxyConfiguration = await Apify.createProxyConfiguration({
|
|
348
|
-
* groups: ['GROUP1', 'GROUP2'] // List of Apify Proxy groups
|
|
349
|
-
* countryCode: 'US',
|
|
350
|
-
* });
|
|
351
|
-
*
|
|
352
|
-
* // Getting proxyInfo object by calling class method directly
|
|
353
|
-
* const proxyInfo = proxyConfiguration.newProxyInfo();
|
|
354
|
-
*
|
|
355
|
-
* // In crawler
|
|
356
|
-
* const crawler = new Apify.CheerioCrawler({
|
|
357
|
-
* // ...
|
|
358
|
-
* proxyConfiguration,
|
|
359
|
-
* handlePageFunction: ({ proxyInfo }) => {
|
|
360
|
-
* // Getting used proxy URL
|
|
361
|
-
* const proxyUrl = proxyInfo.url;
|
|
362
|
-
*
|
|
363
|
-
* // Getting ID of used Session
|
|
364
|
-
* const sessionIdentifier = proxyInfo.sessionId;
|
|
365
|
-
* }
|
|
366
|
-
* })
|
|
367
|
-
*
|
|
368
|
-
* ```
|
|
369
|
-
*/
|
|
370
|
-
export type ProxyInfo = {
|
|
371
|
-
/**
|
|
372
|
-
* The identifier of used {@link Session }, if used.
|
|
373
|
-
*/
|
|
374
|
-
sessionId?: string | undefined;
|
|
375
|
-
/**
|
|
376
|
-
* The URL of the proxy.
|
|
377
|
-
*/
|
|
378
|
-
url: string;
|
|
379
|
-
/**
|
|
380
|
-
* An array of proxy groups to be used by the [Apify Proxy](https://docs.apify.com/proxy).
|
|
381
|
-
* If not provided, the proxy will select the groups automatically.
|
|
382
|
-
*/
|
|
383
|
-
groups: string[];
|
|
384
|
-
/**
|
|
385
|
-
* If set and relevant proxies are available in your Apify account, all proxied requests will
|
|
386
|
-
* use IP addresses that are geolocated to the specified country. For example `GB` for IPs
|
|
387
|
-
* from Great Britain. Note that online services often have their own rules for handling
|
|
388
|
-
* geolocation and thus the country selection is a best attempt at geolocation, rather than
|
|
389
|
-
* a guaranteed hit. This parameter is optional, by default, each proxied request is assigned
|
|
390
|
-
* an IP address from a random country. The country code needs to be a two letter ISO country code. See the
|
|
391
|
-
* [full list of available country codes](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2#Officially_assigned_code_elements).
|
|
392
|
-
* This parameter is optional, by default, the proxy uses all available proxy servers from all countries.
|
|
393
|
-
*/
|
|
394
|
-
countryCode?: string | undefined;
|
|
395
|
-
/**
|
|
396
|
-
* User's password for the proxy. By default, it is taken from the `APIFY_PROXY_PASSWORD`
|
|
397
|
-
* environment variable, which is automatically set by the system when running the actors
|
|
398
|
-
* on the Apify cloud, or when using the [Apify CLI](https://github.com/apify/apify-cli).
|
|
399
|
-
*/
|
|
400
|
-
password: string;
|
|
401
|
-
/**
|
|
402
|
-
* Hostname of your proxy.
|
|
403
|
-
*/
|
|
404
|
-
hostname: string;
|
|
405
|
-
/**
|
|
406
|
-
* Proxy port.
|
|
407
|
-
*/
|
|
408
|
-
port: string;
|
|
409
|
-
};
|
|
410
|
-
import { Configuration } from "./configuration";
|
|
411
|
-
//# sourceMappingURL=proxy_configuration.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"proxy_configuration.d.ts","sourceRoot":"","sources":["../src/proxy_configuration.js"],"names":[],"mappings":"AAeA;;;;GAIG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAwDG;AAEH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH;IACI;;;;;OAKG;IACH,iGAoDC;IApBG,iBAAyB;IACzB,gCAAmC;IACnC,oCAAwB;IACxB,oCAAwB;IACxB,gCAAgB;IAChB,2BAA2B;IAC3B,oBAA0B;IAC1B,6BAA8B;IAC9B,oEAAoC;IACpC,wBAA6D;IAC7D,kCAA6D;IAC7D,sBAAoB;IACpB,0BAA6B;IAUjC;;;;;;;;;OASG;IACH,cAFa,QAAQ,IAAI,CAAC,CAQzB;IAED;;;;;;;;;;;;;;;;OAgBG;IACH,uDAFY,SAAS,CAkBpB;IAED;;;;;;;;;;;;OAYG;IACH,iDAHY,MAAM,CAgBjB;IAED;;;;;;;OAOG;IACH,wDALY,MAAM,CAyBjB;IAED;;;;;;;OAOG;IACH,iCALa,QAAQ,IAAI,CAAC,CAsBzB;IAED;;;;;;;;;OASG;IACH,0BALa,QAAQ,IAAI,CAAC,CAgBzB;IAED;;;;;;;OAOG;IACH,0BALY,QAAQ;QAAE,SAAS,EAAE,OAAO,CAAC;QAAC,eAAe,EAAE,MAAM,CAAA;KAAE,GAAG,SAAS,CAAC,CAoB/E;IAED;;;;;;;OAOG;IACH,4DALa,MAAM,CAkBlB;IAED;;;;;;OAMG;IACH,kFASC;IAED;;;;;;OAMG;IACH,2CALW,KAAK,QAOf;IAED;;;;;;;OAOG;IACH,8CANW,MAAM,SACN,MAAM,QAOhB;IAED;;;;;OAKG;IACH,mEAEC;IAED;;;;;OAKG;IACH,qDAIC;IAED;;;;;OAKG;IACH,mDAEC;CACJ;AA2CM,6GALM,QAAQ,kBAAkB,GAAC,SAAS,CAAC,CAiBjD;qDA9gBU,MAAM,GAAC,MAAM,KACX,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;SAuEL,MAAM;;;;;YAEN,MAAM,EAAE;;;;;;;;;;;;;;;;;cAYR,MAAM;;;;cAIN,MAAM;;;;UAEN,MAAM"}
|