@crawlee/utils 3.13.5 → 4.0.0-beta.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/index.d.ts +15 -16
- package/index.d.ts.map +1 -1
- package/index.js +15 -22
- package/index.js.map +1 -1
- package/internals/blocked.js +4 -7
- package/internals/blocked.js.map +1 -1
- package/internals/cheerio.d.ts +4 -5
- package/internals/cheerio.d.ts.map +1 -1
- package/internals/cheerio.js +9 -17
- package/internals/cheerio.js.map +1 -1
- package/internals/chunk.js +1 -4
- package/internals/chunk.js.map +1 -1
- package/internals/debug.js +5 -9
- package/internals/debug.js.map +1 -1
- package/internals/extract-urls.js +17 -23
- package/internals/extract-urls.js.map +1 -1
- package/internals/general.js +19 -31
- package/internals/general.js.map +1 -1
- package/internals/memory-info.js +22 -26
- package/internals/memory-info.js.map +1 -1
- package/internals/open_graph_parser.js +3 -6
- package/internals/open_graph_parser.js.map +1 -1
- package/internals/robots.d.ts +1 -1
- package/internals/robots.d.ts.map +1 -1
- package/internals/robots.js +16 -26
- package/internals/robots.js.map +1 -1
- package/internals/sitemap.d.ts.map +1 -1
- package/internals/sitemap.js +28 -73
- package/internals/sitemap.js.map +1 -1
- package/internals/social.js +37 -46
- package/internals/social.js.map +1 -1
- package/internals/systemInfoV2/cpu-info.js +26 -36
- package/internals/systemInfoV2/cpu-info.js.map +1 -1
- package/internals/systemInfoV2/memory-info.js +22 -26
- package/internals/systemInfoV2/memory-info.js.map +1 -1
- package/internals/systemInfoV2/ps-tree.js +5 -9
- package/internals/systemInfoV2/ps-tree.js.map +1 -1
- package/internals/typedefs.js +2 -6
- package/internals/typedefs.js.map +1 -1
- package/internals/url.js +1 -4
- package/internals/url.js.map +1 -1
- package/package.json +13 -22
- package/tsconfig.build.tsbuildinfo +1 -1
- package/index.mjs +0 -36
- package/internals/gotScraping.d.ts +0 -5
- package/internals/gotScraping.d.ts.map +0 -1
- package/internals/gotScraping.js +0 -10
- package/internals/gotScraping.js.map +0 -1
package/index.d.ts
CHANGED
|
@@ -1,18 +1,17 @@
|
|
|
1
|
-
export * from './internals/blocked';
|
|
2
|
-
export * from './internals/cheerio';
|
|
3
|
-
export * from './internals/chunk';
|
|
4
|
-
export * from './internals/extract-urls';
|
|
5
|
-
export * from './internals/general';
|
|
6
|
-
export * from './internals/memory-info';
|
|
7
|
-
export * from './internals/debug';
|
|
8
|
-
export * as social from './internals/social';
|
|
9
|
-
export * from './internals/typedefs';
|
|
10
|
-
export * from './internals/open_graph_parser';
|
|
11
|
-
export * from './internals/
|
|
12
|
-
export * from './internals/
|
|
13
|
-
export * from './internals/
|
|
14
|
-
export
|
|
15
|
-
export {
|
|
16
|
-
export { getMemoryInfoV2 } from './internals/systemInfoV2/memory-info';
|
|
1
|
+
export * from './internals/blocked.js';
|
|
2
|
+
export * from './internals/cheerio.js';
|
|
3
|
+
export * from './internals/chunk.js';
|
|
4
|
+
export * from './internals/extract-urls.js';
|
|
5
|
+
export * from './internals/general.js';
|
|
6
|
+
export * from './internals/memory-info.js';
|
|
7
|
+
export * from './internals/debug.js';
|
|
8
|
+
export * as social from './internals/social.js';
|
|
9
|
+
export * from './internals/typedefs.js';
|
|
10
|
+
export * from './internals/open_graph_parser.js';
|
|
11
|
+
export * from './internals/robots.js';
|
|
12
|
+
export * from './internals/sitemap.js';
|
|
13
|
+
export * from './internals/url.js';
|
|
14
|
+
export { getCurrentCpuTicksV2 } from './internals/systemInfoV2/cpu-info.js';
|
|
15
|
+
export { getMemoryInfoV2 } from './internals/systemInfoV2/memory-info.js';
|
|
17
16
|
export { Dictionary, Awaitable, Constructor } from '@crawlee/types';
|
|
18
17
|
//# sourceMappingURL=index.d.ts.map
|
package/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC;AAE1E,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC"}
|
package/index.js
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
tslib_1.__exportStar(require("./internals/robots"), exports);
|
|
17
|
-
tslib_1.__exportStar(require("./internals/sitemap"), exports);
|
|
18
|
-
tslib_1.__exportStar(require("./internals/url"), exports);
|
|
19
|
-
var cpu_info_1 = require("./internals/systemInfoV2/cpu-info");
|
|
20
|
-
Object.defineProperty(exports, "getCurrentCpuTicksV2", { enumerable: true, get: function () { return cpu_info_1.getCurrentCpuTicksV2; } });
|
|
21
|
-
var memory_info_1 = require("./internals/systemInfoV2/memory-info");
|
|
22
|
-
Object.defineProperty(exports, "getMemoryInfoV2", { enumerable: true, get: function () { return memory_info_1.getMemoryInfoV2; } });
|
|
1
|
+
export * from './internals/blocked.js';
|
|
2
|
+
export * from './internals/cheerio.js';
|
|
3
|
+
export * from './internals/chunk.js';
|
|
4
|
+
export * from './internals/extract-urls.js';
|
|
5
|
+
export * from './internals/general.js';
|
|
6
|
+
export * from './internals/memory-info.js';
|
|
7
|
+
export * from './internals/debug.js';
|
|
8
|
+
export * as social from './internals/social.js';
|
|
9
|
+
export * from './internals/typedefs.js';
|
|
10
|
+
export * from './internals/open_graph_parser.js';
|
|
11
|
+
export * from './internals/robots.js';
|
|
12
|
+
export * from './internals/sitemap.js';
|
|
13
|
+
export * from './internals/url.js';
|
|
14
|
+
export { getCurrentCpuTicksV2 } from './internals/systemInfoV2/cpu-info.js';
|
|
15
|
+
export { getMemoryInfoV2 } from './internals/systemInfoV2/memory-info.js';
|
|
23
16
|
//# sourceMappingURL=index.js.map
|
package/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,wBAAwB,CAAC;AACvC,cAAc,wBAAwB,CAAC;AACvC,cAAc,sBAAsB,CAAC;AACrC,cAAc,6BAA6B,CAAC;AAC5C,cAAc,wBAAwB,CAAC;AACvC,cAAc,4BAA4B,CAAC;AAC3C,cAAc,sBAAsB,CAAC;AACrC,OAAO,KAAK,MAAM,MAAM,uBAAuB,CAAC;AAChD,cAAc,yBAAyB,CAAC;AACxC,cAAc,kCAAkC,CAAC;AACjD,cAAc,uBAAuB,CAAC;AACtC,cAAc,wBAAwB,CAAC;AACvC,cAAc,oBAAoB,CAAC;AAEnC,OAAO,EAAE,oBAAoB,EAAE,MAAM,sCAAsC,CAAC;AAC5E,OAAO,EAAE,eAAe,EAAE,MAAM,yCAAyC,CAAC"}
|
package/internals/blocked.js
CHANGED
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ROTATE_PROXY_ERRORS = exports.RETRY_CSS_SELECTORS = exports.CLOUDFLARE_RETRY_CSS_SELECTORS = void 0;
|
|
4
|
-
exports.CLOUDFLARE_RETRY_CSS_SELECTORS = ['#turnstile-wrapper iframe[src^="https://challenges.cloudflare.com"]'];
|
|
1
|
+
export const CLOUDFLARE_RETRY_CSS_SELECTORS = ['#turnstile-wrapper iframe[src^="https://challenges.cloudflare.com"]'];
|
|
5
2
|
/**
|
|
6
3
|
* CSS selectors for elements that should trigger a retry, as the crawler is likely getting blocked.
|
|
7
4
|
*/
|
|
8
|
-
|
|
9
|
-
...
|
|
5
|
+
export const RETRY_CSS_SELECTORS = [
|
|
6
|
+
...CLOUDFLARE_RETRY_CSS_SELECTORS,
|
|
10
7
|
'div#infoDiv0 a[href*="//www.google.com/policies/terms/"]',
|
|
11
8
|
'iframe[src*="_Incapsula_Resource"]',
|
|
12
9
|
];
|
|
13
10
|
/**
|
|
14
11
|
* Content of proxy errors that should trigger a retry, as the proxy is likely getting blocked / is malfunctioning.
|
|
15
12
|
*/
|
|
16
|
-
|
|
13
|
+
export const ROTATE_PROXY_ERRORS = [
|
|
17
14
|
'ECONNRESET',
|
|
18
15
|
'ECONNREFUSED',
|
|
19
16
|
'ERR_PROXY_CONNECTION_FAILED',
|
package/internals/blocked.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"blocked.js","sourceRoot":"","sources":["../../src/internals/blocked.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"blocked.js","sourceRoot":"","sources":["../../src/internals/blocked.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,8BAA8B,GAAG,CAAC,qEAAqE,CAAC,CAAC;AAEtH;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,GAAG,8BAA8B;IACjC,0DAA0D;IAC1D,oCAAoC;CACvC,CAAC;AAEF;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG;IAC/B,YAAY;IACZ,cAAc;IACd,6BAA6B;IAC7B,8BAA8B;IAC9B,sBAAsB;CACzB,CAAC"}
|
package/internals/cheerio.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { CheerioAPI
|
|
2
|
-
export type CheerioRoot =
|
|
1
|
+
import type { CheerioAPI } from 'cheerio';
|
|
2
|
+
export type CheerioRoot = CheerioAPI;
|
|
3
3
|
/**
|
|
4
4
|
* The function converts a HTML document to a plain text.
|
|
5
5
|
*
|
|
@@ -17,13 +17,12 @@ export type CheerioRoot = ReturnType<typeof load>;
|
|
|
17
17
|
*
|
|
18
18
|
* Note that the function uses [cheerio](https://www.npmjs.com/package/cheerio) to parse the HTML.
|
|
19
19
|
* Optionally, to avoid duplicate parsing of HTML and thus improve performance, you can pass
|
|
20
|
-
* an existing Cheerio object to the function instead of the HTML text.
|
|
21
|
-
* with the `decodeEntities` option set to `true`. For example:
|
|
20
|
+
* an existing Cheerio object to the function instead of the HTML text.
|
|
22
21
|
*
|
|
23
22
|
* ```javascript
|
|
24
23
|
* import * as cheerio from 'cheerio';
|
|
25
24
|
* const html = '<html><body>Some text</body></html>';
|
|
26
|
-
* const text = htmlToText(cheerio.load(html
|
|
25
|
+
* const text = htmlToText(cheerio.load(html));
|
|
27
26
|
* ```
|
|
28
27
|
* @param htmlOrCheerioElement HTML text or parsed HTML represented using a [cheerio](https://www.npmjs.com/package/cheerio) function.
|
|
29
28
|
* @return Plain text
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cheerio.d.ts","sourceRoot":"","sources":["../../src/internals/cheerio.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,
|
|
1
|
+
{"version":3,"file":"cheerio.d.ts","sourceRoot":"","sources":["../../src/internals/cheerio.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAK1C,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC;AAOrC;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,wBAAgB,UAAU,CAAC,oBAAoB,EAAE,MAAM,GAAG,WAAW,GAAG,MAAM,CAwC7E;AAED;;;;;;;;GAQG;AACH,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,UAAU,EAAE,QAAQ,SAAM,EAAE,OAAO,SAAK,GAAG,MAAM,EAAE,CAwB5F"}
|
package/internals/cheerio.js
CHANGED
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.htmlToText = htmlToText;
|
|
4
|
-
exports.extractUrlsFromCheerio = extractUrlsFromCheerio;
|
|
5
|
-
const tslib_1 = require("tslib");
|
|
6
|
-
const cheerio = tslib_1.__importStar(require("cheerio"));
|
|
7
|
-
const extract_urls_1 = require("./extract-urls");
|
|
1
|
+
import * as cheerio from 'cheerio';
|
|
2
|
+
import { tryAbsoluteURL } from './extract-urls.js';
|
|
8
3
|
// NOTE: We are skipping 'noscript' since it's content is evaluated as text, instead of HTML elements. That damages the results.
|
|
9
4
|
const SKIP_TAGS_REGEX = /^(script|style|canvas|svg|noscript)$/i;
|
|
10
5
|
const BLOCK_TAGS_REGEX = /^(p|h1|h2|h3|h4|h5|h6|ol|ul|li|pre|address|blockquote|dl|div|fieldset|form|table|tr|select|option)$/i;
|
|
@@ -25,23 +20,20 @@ const BLOCK_TAGS_REGEX = /^(p|h1|h2|h3|h4|h5|h6|ol|ul|li|pre|address|blockquote|
|
|
|
25
20
|
*
|
|
26
21
|
* Note that the function uses [cheerio](https://www.npmjs.com/package/cheerio) to parse the HTML.
|
|
27
22
|
* Optionally, to avoid duplicate parsing of HTML and thus improve performance, you can pass
|
|
28
|
-
* an existing Cheerio object to the function instead of the HTML text.
|
|
29
|
-
* with the `decodeEntities` option set to `true`. For example:
|
|
23
|
+
* an existing Cheerio object to the function instead of the HTML text.
|
|
30
24
|
*
|
|
31
25
|
* ```javascript
|
|
32
26
|
* import * as cheerio from 'cheerio';
|
|
33
27
|
* const html = '<html><body>Some text</body></html>';
|
|
34
|
-
* const text = htmlToText(cheerio.load(html
|
|
28
|
+
* const text = htmlToText(cheerio.load(html));
|
|
35
29
|
* ```
|
|
36
30
|
* @param htmlOrCheerioElement HTML text or parsed HTML represented using a [cheerio](https://www.npmjs.com/package/cheerio) function.
|
|
37
31
|
* @return Plain text
|
|
38
32
|
*/
|
|
39
|
-
function htmlToText(htmlOrCheerioElement) {
|
|
33
|
+
export function htmlToText(htmlOrCheerioElement) {
|
|
40
34
|
if (!htmlOrCheerioElement)
|
|
41
35
|
return '';
|
|
42
|
-
const $ = typeof htmlOrCheerioElement === 'function'
|
|
43
|
-
? htmlOrCheerioElement
|
|
44
|
-
: cheerio.load(htmlOrCheerioElement, { decodeEntities: true });
|
|
36
|
+
const $ = typeof htmlOrCheerioElement === 'function' ? htmlOrCheerioElement : cheerio.load(htmlOrCheerioElement);
|
|
45
37
|
let text = '';
|
|
46
38
|
const process = (elems) => {
|
|
47
39
|
const len = elems ? elems.length : 0;
|
|
@@ -94,9 +86,9 @@ function htmlToText(htmlOrCheerioElement) {
|
|
|
94
86
|
* @throws when a relative URL is encountered with no baseUrl set
|
|
95
87
|
* @return An array of absolute URLs
|
|
96
88
|
*/
|
|
97
|
-
function extractUrlsFromCheerio($, selector = 'a', baseUrl = '') {
|
|
89
|
+
export function extractUrlsFromCheerio($, selector = 'a', baseUrl = '') {
|
|
98
90
|
const base = $('base').attr('href');
|
|
99
|
-
const absoluteBaseUrl = base &&
|
|
91
|
+
const absoluteBaseUrl = base && tryAbsoluteURL(base, baseUrl);
|
|
100
92
|
if (absoluteBaseUrl) {
|
|
101
93
|
baseUrl = absoluteBaseUrl;
|
|
102
94
|
}
|
|
@@ -111,7 +103,7 @@ function extractUrlsFromCheerio($, selector = 'a', baseUrl = '') {
|
|
|
111
103
|
throw new Error(`An extracted URL: ${href} is relative and baseUrl is not set. ` +
|
|
112
104
|
'Provide a baseUrl to automatically resolve relative URLs.');
|
|
113
105
|
}
|
|
114
|
-
return baseUrl ?
|
|
106
|
+
return baseUrl ? tryAbsoluteURL(href, baseUrl) : href;
|
|
115
107
|
})
|
|
116
108
|
.filter(Boolean);
|
|
117
109
|
}
|
package/internals/cheerio.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cheerio.js","sourceRoot":"","sources":["../../src/internals/cheerio.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cheerio.js","sourceRoot":"","sources":["../../src/internals/cheerio.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AAEnC,OAAO,EAAE,cAAc,EAAE,MAAM,mBAAmB,CAAC;AAInD,gIAAgI;AAChI,MAAM,eAAe,GAAG,uCAAuC,CAAC;AAChE,MAAM,gBAAgB,GAClB,sGAAsG,CAAC;AAE3G;;;;;;;;;;;;;;;;;;;;;;;;;;GA0BG;AACH,MAAM,UAAU,UAAU,CAAC,oBAA0C;IACjE,IAAI,CAAC,oBAAoB;QAAE,OAAO,EAAE,CAAC;IAErC,MAAM,CAAC,GAAG,OAAO,oBAAoB,KAAK,UAAU,CAAC,CAAC,CAAC,oBAAoB,CAAC,CAAC,CAAC,OAAO,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;IACjH,IAAI,IAAI,GAAG,EAAE,CAAC;IAEd,MAAM,OAAO,GAAG,CAAC,KAAiB,EAAE,EAAE;QAClC,MAAM,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC;QACrC,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC;YAC3B,MAAM,IAAI,GAAG,KAAK,CAAC,CAAC,CAAC,CAAC;YACtB,IAAI,IAAI,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;gBACvB,qDAAqD;gBACrD,IA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AACrC,CAAC"}
|
package/internals/chunk.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
/*
|
|
3
2
|
The MIT License (MIT)
|
|
4
3
|
|
|
@@ -25,9 +24,7 @@ WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
|
|
|
25
24
|
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
|
|
26
25
|
OTHER DEALINGS IN THE SOFTWARE.
|
|
27
26
|
*/
|
|
28
|
-
|
|
29
|
-
exports.chunk = chunk;
|
|
30
|
-
function chunk(array, chunkSize) {
|
|
27
|
+
export function chunk(array, chunkSize) {
|
|
31
28
|
if (!Array.isArray(array))
|
|
32
29
|
throw new TypeError('entries must be an array.');
|
|
33
30
|
if (!Number.isInteger(chunkSize))
|
package/internals/chunk.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../src/internals/chunk.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"chunk.js","sourceRoot":"","sources":["../../src/internals/chunk.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;EAyBE;AAEF,MAAM,UAAU,KAAK,CAAI,KAAmB,EAAE,SAAiB;IAC3D,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,2BAA2B,CAAC,CAAC;IAC5E,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,+BAA+B,CAAC,CAAC;IACvF,IAAI,SAAS,GAAG,CAAC;QAAE,MAAM,IAAI,UAAU,CAAC,iCAAiC,CAAC,CAAC;IAC3E,MAAM,KAAK,GAAQ,KAAK,CAAC,KAAK,EAAE,CAAC;IACjC,MAAM,MAAM,GAAU,EAAE,CAAC;IACzB,OAAO,KAAK,CAAC,MAAM;QAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,EAAE,SAAS,CAAC,CAAC,CAAC;IAC7D,OAAO,MAAM,CAAC;AAClB,CAAC"}
|
package/internals/debug.js
CHANGED
|
@@ -1,8 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRequestDebugInfo = createRequestDebugInfo;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
1
|
+
import ow from 'ow';
|
|
6
2
|
/**
|
|
7
3
|
* Creates a standardized debug info from request and response. This info is usually added to dataset under the hidden `#debug` field.
|
|
8
4
|
*
|
|
@@ -12,10 +8,10 @@ const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
|
12
8
|
* or NodeJS [`http.IncomingMessage`](https://nodejs.org/api/http.html#http_class_http_serverresponse).
|
|
13
9
|
* @param [additionalFields] Object containing additional fields to be added.
|
|
14
10
|
*/
|
|
15
|
-
function createRequestDebugInfo(request, response = {}, additionalFields = {}) {
|
|
16
|
-
(
|
|
17
|
-
(
|
|
18
|
-
(
|
|
11
|
+
export function createRequestDebugInfo(request, response = {}, additionalFields = {}) {
|
|
12
|
+
ow(request, ow.object);
|
|
13
|
+
ow(response, ow.object);
|
|
14
|
+
ow(additionalFields, ow.object);
|
|
19
15
|
return {
|
|
20
16
|
requestId: request.id,
|
|
21
17
|
url: request.url,
|
package/internals/debug.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/internals/debug.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"debug.js","sourceRoot":"","sources":["../../src/internals/debug.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,MAAM,IAAI,CAAC;AAqBpB;;;;;;;;GAQG;AACH,MAAM,UAAU,sBAAsB,CAClC,OAAgB,EAChB,WAA2D,EAAE,EAC7D,mBAA+B,EAAE;IAEjC,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IACvB,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IACxB,EAAE,CAAC,gBAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,CAAC;IAEhC,OAAO;QACH,SAAS,EAAE,OAAO,CAAC,EAAE;QACrB,GAAG,EAAE,OAAO,CAAC,GAAG;QAChB,SAAS,EAAE,OAAO,CAAC,SAAS;QAC5B,MAAM,EAAE,OAAO,CAAC,MAAM;QACtB,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,aAAa,EAAE,OAAO,CAAC,aAAa;QACpC,sFAAsF;QACtF,UAAU,EACN,QAAQ,IAAI,QAAQ,IAAI,QAAQ,CAAC,MAAM,YAAY,QAAQ;YACvD,CAAC,CAAC,QAAQ,CAAC,MAAM,EAAE;YACnB,CAAC,CAAE,QAA4B,CAAC,UAAU;QAClD,GAAG,gBAAgB;KACtB,CAAC;AACN,CAAC"}
|
|
@@ -1,44 +1,38 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
exports.extractUrls = extractUrls;
|
|
5
|
-
exports.tryAbsoluteURL = tryAbsoluteURL;
|
|
6
|
-
const tslib_1 = require("tslib");
|
|
7
|
-
const ow_1 = tslib_1.__importDefault(require("ow"));
|
|
8
|
-
const general_1 = require("./general");
|
|
9
|
-
const gotScraping_1 = require("./gotScraping");
|
|
1
|
+
import { gotScraping } from 'got-scraping';
|
|
2
|
+
import ow from 'ow';
|
|
3
|
+
import { URL_NO_COMMAS_REGEX } from './general.js';
|
|
10
4
|
/**
|
|
11
5
|
* Returns a promise that resolves to an array of urls parsed from the resource available at the provided url.
|
|
12
6
|
* Optionally, custom regular expression and encoding may be provided.
|
|
13
7
|
*/
|
|
14
|
-
async function downloadListOfUrls(options) {
|
|
15
|
-
(
|
|
16
|
-
url:
|
|
17
|
-
encoding:
|
|
18
|
-
urlRegExp:
|
|
19
|
-
proxyUrl:
|
|
8
|
+
export async function downloadListOfUrls(options) {
|
|
9
|
+
ow(options, ow.object.exactShape({
|
|
10
|
+
url: ow.string.url,
|
|
11
|
+
encoding: ow.optional.string,
|
|
12
|
+
urlRegExp: ow.optional.regExp,
|
|
13
|
+
proxyUrl: ow.optional.string,
|
|
20
14
|
}));
|
|
21
|
-
const { url, encoding = 'utf8', urlRegExp =
|
|
15
|
+
const { url, encoding = 'utf8', urlRegExp = URL_NO_COMMAS_REGEX, proxyUrl } = options;
|
|
22
16
|
// Try to detect wrong urls and fix them. Currently, detects only sharing url instead of csv download one.
|
|
23
17
|
const match = url.match(/^(https:\/\/docs\.google\.com\/spreadsheets\/d\/(?:\w|-)+)\/?/);
|
|
24
18
|
let fixedUrl = url;
|
|
25
19
|
if (match) {
|
|
26
20
|
fixedUrl = `${match[1]}/gviz/tq?tqx=out:csv`;
|
|
27
21
|
}
|
|
28
|
-
const { body: string } = await
|
|
22
|
+
const { body: string } = await gotScraping({ url: fixedUrl, encoding, proxyUrl });
|
|
29
23
|
return extractUrls({ string, urlRegExp });
|
|
30
24
|
}
|
|
31
25
|
/**
|
|
32
26
|
* Collects all URLs in an arbitrary string to an array, optionally using a custom regular expression.
|
|
33
27
|
*/
|
|
34
|
-
function extractUrls(options) {
|
|
35
|
-
(
|
|
36
|
-
string:
|
|
37
|
-
urlRegExp:
|
|
28
|
+
export function extractUrls(options) {
|
|
29
|
+
ow(options, ow.object.exactShape({
|
|
30
|
+
string: ow.string,
|
|
31
|
+
urlRegExp: ow.optional.regExp,
|
|
38
32
|
}));
|
|
39
33
|
const lines = options.string.split('\n');
|
|
40
34
|
const result = [];
|
|
41
|
-
const urlRegExp = options.urlRegExp ??
|
|
35
|
+
const urlRegExp = options.urlRegExp ?? URL_NO_COMMAS_REGEX;
|
|
42
36
|
for (const line of lines) {
|
|
43
37
|
result.push(...(line.match(urlRegExp) ?? []));
|
|
44
38
|
}
|
|
@@ -47,7 +41,7 @@ function extractUrls(options) {
|
|
|
47
41
|
/**
|
|
48
42
|
* Helper function used to validate URLs used when extracting URLs from a page
|
|
49
43
|
*/
|
|
50
|
-
function tryAbsoluteURL(href, baseUrl) {
|
|
44
|
+
export function tryAbsoluteURL(href, baseUrl) {
|
|
51
45
|
try {
|
|
52
46
|
return new URL(href, baseUrl).href;
|
|
53
47
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"extract-urls.js","sourceRoot":"","sources":["../../src/internals/extract-urls.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"extract-urls.js","sourceRoot":"","sources":["../../src/internals/extract-urls.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAyBnD;;;GAGG;AACH,MAAM,CAAC,KAAK,UAAU,kBAAkB,CAAC,OAAkC;IACvE,EAAE,CACE,OAAc,EACd,EAAE,CAAC,MAAM,CAAC,UAAU,CAAC;QACjB,GAAG,EAAE,EAAE,CAAC,MAAM,CAAC,GAAG;QAClB,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM;QAC5B,SAAS,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM;QAC7B,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,MAAM;KAC/B,CAAC,CACL,CAAC;IACF,MAAM,EAAE,GAAG,EAAE,QAAQ,GAAG,MAAM,EAAE,SAAS,GAAG,mBAAmB,EAAE,QAAQ,EAAE,GAAG,OAAO,CAAC;IAEtF,0GAA0G;IAC1G,MAAM,KAAK,GAAG,GAAG,CAAC,KAAK,CAAC,+DAA+D,CAAC,CAAC;IACzF,IAAI,QAAQ,GAAG,GAAG,CAAC;IAEnB,IAAI,KAAK,EAAE,CAAC;QACR,QAAQ,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC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ker;
|
|
5
|
-
exports.isContainerized = isContainerized;
|
|
6
|
-
exports.isLambda = isLambda;
|
|
7
|
-
exports.getCgroupsVersion = getCgroupsVersion;
|
|
8
|
-
exports.weightedAvg = weightedAvg;
|
|
9
|
-
exports.sleep = sleep;
|
|
10
|
-
exports.snakeCaseToCamelCase = snakeCaseToCamelCase;
|
|
11
|
-
exports.expandShadowRoots = expandShadowRoots;
|
|
12
|
-
const tslib_1 = require("tslib");
|
|
13
|
-
const promises_1 = tslib_1.__importDefault(require("node:fs/promises"));
|
|
14
|
-
const promises_2 = require("node:timers/promises");
|
|
1
|
+
import fs from 'node:fs/promises';
|
|
2
|
+
import { setTimeout } from 'node:timers/promises';
|
|
15
3
|
/**
|
|
16
4
|
* Default regular expression to match URLs in a string that may be plain text, JSON, CSV or other. It supports common URL characters
|
|
17
5
|
* and does not support URLs containing commas or spaces. The URLs also may contain Unicode letters (not symbols).
|
|
18
6
|
*/
|
|
19
|
-
|
|
7
|
+
export const URL_NO_COMMAS_REGEX = /https?:\/\/(www\.)?([\p{L}0-9]|[\p{L}0-9][-\p{L}0-9@:%._+~#=]{0,254}[\p{L}0-9])\.[a-z]{2,63}(:\d{1,5})?(\/[-\p{L}0-9@:%_+.~#?&/=()]*)?/giu;
|
|
20
8
|
/**
|
|
21
9
|
* Regular expression that, in addition to the default regular expression `URL_NO_COMMAS_REGEX`, supports matching commas in URL path and query.
|
|
22
10
|
* Note, however, that this may prevent parsing URLs from comma delimited lists, or the URLs may become malformed.
|
|
23
11
|
*/
|
|
24
|
-
|
|
12
|
+
export const URL_WITH_COMMAS_REGEX = /https?:\/\/(www\.)?([\p{L}0-9]|[\p{L}0-9][-\p{L}0-9@:%._+~#=]{0,254}[\p{L}0-9])\.[a-z]{2,63}(:\d{1,5})?(\/[-\p{L}0-9@:%_+,.~#?&/=()]*)?/giu;
|
|
25
13
|
let isDockerPromiseCache;
|
|
26
14
|
async function createIsDockerPromise() {
|
|
27
|
-
const promise1 =
|
|
15
|
+
const promise1 = fs
|
|
28
16
|
.stat('/.dockerenv')
|
|
29
17
|
.then(() => true)
|
|
30
18
|
.catch(() => false);
|
|
31
|
-
const promise2 =
|
|
19
|
+
const promise2 = fs
|
|
32
20
|
.readFile('/proc/self/cgroup', 'utf8')
|
|
33
21
|
.then((content) => content.includes('docker'))
|
|
34
22
|
.catch(() => false);
|
|
@@ -38,7 +26,7 @@ async function createIsDockerPromise() {
|
|
|
38
26
|
/**
|
|
39
27
|
* Returns a `Promise` that resolves to true if the code is running in a Docker container.
|
|
40
28
|
*/
|
|
41
|
-
async function isDocker(forceReset) {
|
|
29
|
+
export async function isDocker(forceReset) {
|
|
42
30
|
// Parameter forceReset is just internal for unit tests.
|
|
43
31
|
if (!isDockerPromiseCache || forceReset)
|
|
44
32
|
isDockerPromiseCache = createIsDockerPromise();
|
|
@@ -48,7 +36,7 @@ let isContainerizedResult;
|
|
|
48
36
|
/**
|
|
49
37
|
* Detects if crawlee is running in a containerized environment.
|
|
50
38
|
*/
|
|
51
|
-
async function isContainerized() {
|
|
39
|
+
export async function isContainerized() {
|
|
52
40
|
// Value is very unlikley to change. Cache the result after the first execution.
|
|
53
41
|
if (isContainerizedResult !== undefined) {
|
|
54
42
|
return isContainerizedResult;
|
|
@@ -58,11 +46,11 @@ async function isContainerized() {
|
|
|
58
46
|
isContainerizedResult = false;
|
|
59
47
|
return isContainerizedResult;
|
|
60
48
|
}
|
|
61
|
-
const dockerenvCheck =
|
|
49
|
+
const dockerenvCheck = fs
|
|
62
50
|
.stat('/.dockerenv')
|
|
63
51
|
.then(() => true)
|
|
64
52
|
.catch(() => false);
|
|
65
|
-
const cgroupCheck =
|
|
53
|
+
const cgroupCheck = fs
|
|
66
54
|
.readFile('/proc/self/cgroup', 'utf8')
|
|
67
55
|
.then((content) => content.includes('docker'))
|
|
68
56
|
.catch(() => false);
|
|
@@ -70,7 +58,7 @@ async function isContainerized() {
|
|
|
70
58
|
isContainerizedResult = dockerenvResult || cgroupResult || !!process.env.KUBERNETES_SERVICE_HOST;
|
|
71
59
|
return isContainerizedResult;
|
|
72
60
|
}
|
|
73
|
-
function isLambda() {
|
|
61
|
+
export function isLambda() {
|
|
74
62
|
return !!process.env.AWS_LAMBDA_FUNCTION_MEMORY_SIZE;
|
|
75
63
|
}
|
|
76
64
|
let _cgroupsVersion;
|
|
@@ -78,14 +66,14 @@ let _cgroupsVersion;
|
|
|
78
66
|
* gets the cgroup version by checking for a file at /sys/fs/cgroup/memory
|
|
79
67
|
* @returns "V1" or "V2" for the version of cgroup or null if cgroup is not found.
|
|
80
68
|
*/
|
|
81
|
-
async function getCgroupsVersion(forceReset) {
|
|
69
|
+
export async function getCgroupsVersion(forceReset) {
|
|
82
70
|
// Parameter forceReset is just internal for unit tests.
|
|
83
71
|
if (_cgroupsVersion !== undefined && !forceReset) {
|
|
84
72
|
return _cgroupsVersion;
|
|
85
73
|
}
|
|
86
74
|
try {
|
|
87
75
|
// If this directory does not exists, cgroups are not available
|
|
88
|
-
await
|
|
76
|
+
await fs.access('/sys/fs/cgroup/');
|
|
89
77
|
}
|
|
90
78
|
catch (e) {
|
|
91
79
|
_cgroupsVersion = null;
|
|
@@ -94,7 +82,7 @@ async function getCgroupsVersion(forceReset) {
|
|
|
94
82
|
_cgroupsVersion = 'V1';
|
|
95
83
|
try {
|
|
96
84
|
// If this directory does not exists, assume the container is using cgroups V2
|
|
97
|
-
await
|
|
85
|
+
await fs.access('/sys/fs/cgroup/memory/');
|
|
98
86
|
}
|
|
99
87
|
catch (e) {
|
|
100
88
|
_cgroupsVersion = 'V2';
|
|
@@ -105,7 +93,7 @@ async function getCgroupsVersion(forceReset) {
|
|
|
105
93
|
* Computes a weighted average of an array of numbers, complemented by an array of weights.
|
|
106
94
|
* @ignore
|
|
107
95
|
*/
|
|
108
|
-
function weightedAvg(arrValues, arrWeights) {
|
|
96
|
+
export function weightedAvg(arrValues, arrWeights) {
|
|
109
97
|
const result = arrValues
|
|
110
98
|
.map((value, i) => {
|
|
111
99
|
const weight = arrWeights[i];
|
|
@@ -131,14 +119,14 @@ function weightedAvg(arrValues, arrWeights) {
|
|
|
131
119
|
* ```
|
|
132
120
|
* @param millis Period of time to sleep, in milliseconds. If not a positive number, the returned promise resolves immediately.
|
|
133
121
|
*/
|
|
134
|
-
async function sleep(millis) {
|
|
135
|
-
return
|
|
122
|
+
export async function sleep(millis) {
|
|
123
|
+
return setTimeout(millis ?? undefined);
|
|
136
124
|
}
|
|
137
125
|
/**
|
|
138
126
|
* Converts SNAKE_CASE to camelCase.
|
|
139
127
|
* @ignore
|
|
140
128
|
*/
|
|
141
|
-
function snakeCaseToCamelCase(snakeCaseStr) {
|
|
129
|
+
export function snakeCaseToCamelCase(snakeCaseStr) {
|
|
142
130
|
return snakeCaseStr
|
|
143
131
|
.toLowerCase()
|
|
144
132
|
.split('_')
|
|
@@ -151,7 +139,7 @@ function snakeCaseToCamelCase(snakeCaseStr) {
|
|
|
151
139
|
* Traverses DOM and expands shadow-root elements (created by custom components).
|
|
152
140
|
* @ignore
|
|
153
141
|
*/
|
|
154
|
-
function expandShadowRoots(document) {
|
|
142
|
+
export function expandShadowRoots(document) {
|
|
155
143
|
// Returns HTML of given shadow DOM.
|
|
156
144
|
function getShadowDomHtml(shadowRoot) {
|
|
157
145
|
let shadowHTML = '';
|
package/internals/general.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../src/internals/general.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"general.js","sourceRoot":"","sources":["../../src/internals/general.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,kBAAkB,CAAC;AAClC,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAElD;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAC5B,2IAA2I,CAAC;AAEhJ;;;GAGG;AACH,MAAM,CAAC,MAAM,qBAAqB,GAC9B,4IAA4I,CAAC;AAEjJ,IAAI,oBA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