@wikicasa-dev/node-common 1.1.0 → 1.2.1
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/index.d.ts +8 -0
- package/dist/index.js +9 -0
- package/dist/src/Cache.js +8 -3
- package/dist/src/CacheES.js +2 -2
- package/dist/src/CallPool.js +27 -24
- package/dist/src/Console.js +0 -1
- package/dist/src/Crawler.js +8 -9
- package/dist/src/Pool.js +8 -9
- package/dist/src/common.js +5 -6
- package/dist/{utils.d.ts → src/utils.d.ts} +0 -1
- package/dist/src/utils.js +0 -14
- package/package.json +1 -1
- package/dist/Cache.js +0 -114
- package/dist/CacheES.js +0 -119
- package/dist/CallPool.js +0 -226
- package/dist/Console.js +0 -113
- package/dist/Crawler.js +0 -85
- package/dist/Pool.js +0 -70
- package/dist/common.js +0 -150
- package/dist/src/Cache.js.map +0 -1
- package/dist/src/CacheES.js.map +0 -1
- package/dist/src/CallPool.js.map +0 -1
- package/dist/src/Console.js.map +0 -1
- package/dist/src/Crawler.js.map +0 -1
- package/dist/src/Pool.js.map +0 -1
- package/dist/src/common.js.map +0 -1
- package/dist/src/utils.js.map +0 -1
- package/dist/utils.js +0 -209
- /package/dist/{Cache.d.ts → src/Cache.d.ts} +0 -0
- /package/dist/{CacheES.d.ts → src/CacheES.d.ts} +0 -0
- /package/dist/{CallPool.d.ts → src/CallPool.d.ts} +0 -0
- /package/dist/{Console.d.ts → src/Console.d.ts} +0 -0
- /package/dist/{Crawler.d.ts → src/Crawler.d.ts} +0 -0
- /package/dist/{Pool.d.ts → src/Pool.d.ts} +0 -0
- /package/dist/{common.d.ts → src/common.d.ts} +0 -0
package/dist/CallPool.js
DELETED
|
@@ -1,226 +0,0 @@
|
|
|
1
|
-
import throttledQueue from "throttled-queue";
|
|
2
|
-
import Console, { COLORS } from "./Console.js";
|
|
3
|
-
import { EventEmitter } from "events";
|
|
4
|
-
import axios from "axios";
|
|
5
|
-
import { sleep } from "./common.js";
|
|
6
|
-
import CacheableLookup from "cacheable-lookup";
|
|
7
|
-
import Agent from "agentkeepalive";
|
|
8
|
-
import * as RandomUserAgent from "random-useragent";
|
|
9
|
-
import axiosRetry from "axios-retry";
|
|
10
|
-
import _ from "lodash";
|
|
11
|
-
import { HttpsProxyAgent } from "https-proxy-agent";
|
|
12
|
-
const cacheable = new CacheableLookup();
|
|
13
|
-
// Increase the limit
|
|
14
|
-
EventEmitter.defaultMaxListeners = 20;
|
|
15
|
-
//const a = new CallPool("test", 1, 10, 50, 1000, PROXY.DYNAMIC);
|
|
16
|
-
axiosRetry(axios, {
|
|
17
|
-
retries: 1,
|
|
18
|
-
retryDelay: (retryCount, error) => {
|
|
19
|
-
Console.log(`retry attempt: ${retryCount}. Error ${error}`);
|
|
20
|
-
return retryCount * 1000;
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
export var PROXY;
|
|
24
|
-
(function (PROXY) {
|
|
25
|
-
PROXY[PROXY["NONE"] = 0] = "NONE";
|
|
26
|
-
PROXY[PROXY["STATIC"] = 1] = "STATIC";
|
|
27
|
-
PROXY[PROXY["DYNAMIC"] = 2] = "DYNAMIC";
|
|
28
|
-
})(PROXY || (PROXY = {}));
|
|
29
|
-
export class CallPool {
|
|
30
|
-
name;
|
|
31
|
-
concurrency;
|
|
32
|
-
minConcurrency = 1;
|
|
33
|
-
maxConcurrency;
|
|
34
|
-
_print = "";
|
|
35
|
-
limiter;
|
|
36
|
-
proxy;
|
|
37
|
-
CLOCK_NUMBER = 1;
|
|
38
|
-
WEIGHT = 100;
|
|
39
|
-
mean = 0;
|
|
40
|
-
targetMean = 0;
|
|
41
|
-
clock = this.CLOCK_NUMBER;
|
|
42
|
-
queue = [];
|
|
43
|
-
activeCount;
|
|
44
|
-
// @ts-ignore
|
|
45
|
-
agent;
|
|
46
|
-
constructor(name = "default", proxy = PROXY.STATIC, minConcurrency = 1, maxConcurrency, limitCall = 1000, limitInterval = 1000) {
|
|
47
|
-
this.name = name;
|
|
48
|
-
this.concurrency = (minConcurrency + maxConcurrency) / 2;
|
|
49
|
-
this.minConcurrency = minConcurrency;
|
|
50
|
-
this.maxConcurrency = maxConcurrency;
|
|
51
|
-
this.queue = [];
|
|
52
|
-
this.activeCount = 0;
|
|
53
|
-
this.limiter = throttledQueue(limitCall, limitInterval, true);
|
|
54
|
-
this.proxy = proxy;
|
|
55
|
-
this.updatePrint();
|
|
56
|
-
this.agent = new Agent({
|
|
57
|
-
maxSockets: 100,
|
|
58
|
-
maxFreeSockets: 10,
|
|
59
|
-
timeout: 30000,
|
|
60
|
-
lookup: cacheable.lookupAsync,
|
|
61
|
-
});
|
|
62
|
-
/*axios("https://api.ipify.org?format=json", {
|
|
63
|
-
method: "GET",
|
|
64
|
-
proxy: null,
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
fetch("https://api.ipify.org?format=json", {
|
|
68
|
-
method: "GET",
|
|
69
|
-
agent: null,
|
|
70
|
-
headers: {
|
|
71
|
-
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.3"
|
|
72
|
-
}
|
|
73
|
-
})*/
|
|
74
|
-
}
|
|
75
|
-
call(url, config) {
|
|
76
|
-
return new Promise((resolve, reject) => {
|
|
77
|
-
this.queue.push({
|
|
78
|
-
call: async () => {
|
|
79
|
-
/*const response = await this.fetchWithRetry(url, {
|
|
80
|
-
...config,
|
|
81
|
-
agent: this.agent,
|
|
82
|
-
headers: {
|
|
83
|
-
...config?.headers,
|
|
84
|
-
"User-Agent": this.proxy !== PROXY.NONE ? RandomUserAgent.getRandom() : undefined
|
|
85
|
-
}
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
// Andrea M: handle 400-500 errors
|
|
89
|
-
if (!response.ok)
|
|
90
|
-
throw response;*/
|
|
91
|
-
/*httpAgent: new Agent({
|
|
92
|
-
keepAlive: false,
|
|
93
|
-
maxSockets: 100,
|
|
94
|
-
maxFreeSockets: 10,
|
|
95
|
-
timeout: 60000,
|
|
96
|
-
lookup: cacheable.lookupAsync,
|
|
97
|
-
}),
|
|
98
|
-
httpsAgent: new Agent({
|
|
99
|
-
keepAlive: false,
|
|
100
|
-
maxSockets: 100,
|
|
101
|
-
maxFreeSockets: 10,
|
|
102
|
-
timeout: 60000,
|
|
103
|
-
lookup: cacheable.lookupAsync,
|
|
104
|
-
}),*/
|
|
105
|
-
return axios(url, _.merge({
|
|
106
|
-
method: "GET",
|
|
107
|
-
proxy: this.proxy === PROXY.DYNAMIC ? {
|
|
108
|
-
protocol: "http",
|
|
109
|
-
host: "api.zyte.com",
|
|
110
|
-
port: 8011,
|
|
111
|
-
auth: {
|
|
112
|
-
username: "cf3dd14c1b9c4daf9cf67007520d0c48",
|
|
113
|
-
password: ""
|
|
114
|
-
},
|
|
115
|
-
} : undefined,
|
|
116
|
-
httpsAgent: this.proxy === PROXY.STATIC ? new HttpsProxyAgent("http://wikicasa:VTt7KYb5fsqDhK6xXinS@162.19.104.35:3128") : undefined,
|
|
117
|
-
httpAgent: this.proxy === PROXY.STATIC ? new HttpsProxyAgent("http://wikicasa:VTt7KYb5fsqDhK6xXinS@162.19.104.35:3128") : undefined,
|
|
118
|
-
maxContentLength: Infinity,
|
|
119
|
-
maxBodyLength: Infinity,
|
|
120
|
-
timeout: 600000,
|
|
121
|
-
headers: {
|
|
122
|
-
...(this.proxy === PROXY.DYNAMIC && { "Zyte-Geolocation": "IT" }),
|
|
123
|
-
"User-Agent": this.proxy !== PROXY.NONE ? this.getRandomUserAgent() : undefined,
|
|
124
|
-
}
|
|
125
|
-
}, config));
|
|
126
|
-
},
|
|
127
|
-
resolve,
|
|
128
|
-
reject
|
|
129
|
-
});
|
|
130
|
-
this.schedule();
|
|
131
|
-
});
|
|
132
|
-
}
|
|
133
|
-
getRandomUserAgent() {
|
|
134
|
-
const browsers = [
|
|
135
|
-
{ name: "Chrome", version: 109 },
|
|
136
|
-
{ name: "Firefox", version: 115 },
|
|
137
|
-
{ name: "Edge", version: 116 }
|
|
138
|
-
];
|
|
139
|
-
return RandomUserAgent.getRandom(function (ua) {
|
|
140
|
-
return browsers.some(b => b.name === ua.browserName && b.version <= parseInt(ua.browserVersion));
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
enqueue(call) {
|
|
144
|
-
return new Promise((resolve, reject) => {
|
|
145
|
-
this.queue.push({
|
|
146
|
-
call,
|
|
147
|
-
resolve,
|
|
148
|
-
reject,
|
|
149
|
-
});
|
|
150
|
-
this.schedule();
|
|
151
|
-
});
|
|
152
|
-
}
|
|
153
|
-
schedule() {
|
|
154
|
-
while (this.activeCount < this.concurrency && this.queue.length > 0) {
|
|
155
|
-
const item = this.queue.shift();
|
|
156
|
-
if (!item)
|
|
157
|
-
return;
|
|
158
|
-
const { call, resolve, reject } = item;
|
|
159
|
-
this.activeCount++;
|
|
160
|
-
const time = performance.now();
|
|
161
|
-
this.limiter(() => {
|
|
162
|
-
call()
|
|
163
|
-
.then((result) => {
|
|
164
|
-
resolve(result);
|
|
165
|
-
})
|
|
166
|
-
.catch((error) => {
|
|
167
|
-
reject(error);
|
|
168
|
-
})
|
|
169
|
-
.finally(() => {
|
|
170
|
-
this.activeCount--;
|
|
171
|
-
this.clock--;
|
|
172
|
-
if (this.clock < 0) {
|
|
173
|
-
this.clock = this.CLOCK_NUMBER;
|
|
174
|
-
if (this.mean > this.targetMean && this.mean > 10)
|
|
175
|
-
this.concurrency = Math.max(this.concurrency - Math.floor(this.concurrency / 10), this.minConcurrency);
|
|
176
|
-
if (this.mean < this.targetMean || this.mean < 2)
|
|
177
|
-
this.concurrency = Math.min(this.concurrency + Math.ceil(this.concurrency / 20), this.maxConcurrency);
|
|
178
|
-
this.targetMean = this.mean;
|
|
179
|
-
}
|
|
180
|
-
const t = (performance.now() - time) / 1000;
|
|
181
|
-
this.mean = this.mean > 0 ? this.mean + (t - this.mean) / this.WEIGHT : t;
|
|
182
|
-
this.updatePrint();
|
|
183
|
-
//console.debug(this.name, t, this.mean, this.targetMean, `${this.activeCount}/${this.queue.length}`, this.concurrency, `${(60 / this.mean) * this.concurrency} avg/m`);
|
|
184
|
-
this.schedule();
|
|
185
|
-
});
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
print() {
|
|
190
|
-
return this._print;
|
|
191
|
-
}
|
|
192
|
-
updatePrint() {
|
|
193
|
-
const textStart = `${Console.color(this.name.padEnd(16), COLORS.YELLOW)} [POOL][`;
|
|
194
|
-
// eslint-disable-next-line max-len
|
|
195
|
-
const textEnd = `][${this.activeCount + this.queue?.length}/${this.concurrency}][${this.mean.toFixed(2)}s, ${((60 / this.mean) * this.activeCount).toFixed(2)} avg/m]`;
|
|
196
|
-
let progress = "";
|
|
197
|
-
const max = process.stdout.columns - Math.max(textStart.length + textEnd.length, process.stdout.columns * 0.5);
|
|
198
|
-
const percent = this.activeCount / this.concurrency * max;
|
|
199
|
-
for (let j = 0; j < max; j++) {
|
|
200
|
-
const char = j < percent ? "=" : " ";
|
|
201
|
-
progress += Console.color(char, j < (max * 0.8) ? COLORS.GREEN : j < (max * 0.9) ? COLORS.YELLOW : COLORS.RED);
|
|
202
|
-
}
|
|
203
|
-
this._print = textStart + progress + textEnd;
|
|
204
|
-
}
|
|
205
|
-
async finish() {
|
|
206
|
-
while (this.activeCount) {
|
|
207
|
-
await this.finish();
|
|
208
|
-
}
|
|
209
|
-
return;
|
|
210
|
-
}
|
|
211
|
-
async fetchWithRetry(url, options, retries = 3, sleepTime = 1000) {
|
|
212
|
-
try {
|
|
213
|
-
const response = await fetch(url, options);
|
|
214
|
-
if (!response.ok)
|
|
215
|
-
throw new Error(`HTTP error! status: ${response.status}`);
|
|
216
|
-
return response;
|
|
217
|
-
}
|
|
218
|
-
catch (error) {
|
|
219
|
-
if (retries === 0)
|
|
220
|
-
throw new Error(`Failed to fetch ${url} after several retries`);
|
|
221
|
-
Console.log(`Retrying fetch for ${url}. Attempts remaining: ${retries - 1}`);
|
|
222
|
-
await sleep(sleepTime);
|
|
223
|
-
return this.fetchWithRetry(url, options, retries - 1);
|
|
224
|
-
}
|
|
225
|
-
}
|
|
226
|
-
}
|
package/dist/Console.js
DELETED
|
@@ -1,113 +0,0 @@
|
|
|
1
|
-
import readline from "readline";
|
|
2
|
-
import fs from "fs";
|
|
3
|
-
const log_stdout = process.stdout;
|
|
4
|
-
export var COLORS;
|
|
5
|
-
(function (COLORS) {
|
|
6
|
-
COLORS["BLACK"] = "\u001B[30m";
|
|
7
|
-
COLORS["RED"] = "\u001B[31m";
|
|
8
|
-
COLORS["GREEN"] = "\u001B[32m";
|
|
9
|
-
COLORS["YELLOW"] = "\u001B[33m";
|
|
10
|
-
COLORS["BLUE"] = "\u001B[34m";
|
|
11
|
-
COLORS["MAGENTA"] = "\u001B[35m";
|
|
12
|
-
COLORS["CYAN"] = "\u001B[36m";
|
|
13
|
-
COLORS["WHITE"] = "\u001B[0m";
|
|
14
|
-
})(COLORS || (COLORS = {}));
|
|
15
|
-
/**
|
|
16
|
-
* @author Andrea Moraglia
|
|
17
|
-
*/
|
|
18
|
-
export default class Console {
|
|
19
|
-
static prefix = null;
|
|
20
|
-
static postfix = null;
|
|
21
|
-
static loader;
|
|
22
|
-
static first = true;
|
|
23
|
-
static summaryLines = [];
|
|
24
|
-
static setPrefix(prefix, color = COLORS.WHITE) {
|
|
25
|
-
this.prefix = this.color(prefix, color);
|
|
26
|
-
}
|
|
27
|
-
static setPostfix(postfix, color = COLORS.WHITE) {
|
|
28
|
-
this.postfix = this.color(postfix, color);
|
|
29
|
-
}
|
|
30
|
-
static appendSummaryLine(fn, color = COLORS.WHITE) {
|
|
31
|
-
if (process.env.NODE_ENV === "production")
|
|
32
|
-
return;
|
|
33
|
-
this.summaryLines.push({ fn, color });
|
|
34
|
-
}
|
|
35
|
-
static clearSummaryLine() {
|
|
36
|
-
this.summaryLines = [];
|
|
37
|
-
}
|
|
38
|
-
static processSummaryLines() {
|
|
39
|
-
return this.summaryLines.map(l => this.color(l.fn(), l.color)).join("\n");
|
|
40
|
-
}
|
|
41
|
-
static clearPostfix() {
|
|
42
|
-
this.postfix = null;
|
|
43
|
-
}
|
|
44
|
-
static clearPrefix() {
|
|
45
|
-
this.prefix = null;
|
|
46
|
-
}
|
|
47
|
-
static color(str, color) {
|
|
48
|
-
return `${color}${str}${COLORS.WHITE}`;
|
|
49
|
-
}
|
|
50
|
-
static log(str = "", spinner = false, file) {
|
|
51
|
-
this.write(str, COLORS.WHITE, spinner, file);
|
|
52
|
-
}
|
|
53
|
-
static error(str = "", spinner = false, file) {
|
|
54
|
-
this.write(str, COLORS.RED, spinner, file);
|
|
55
|
-
}
|
|
56
|
-
static warn(str = "", spinner = false, file) {
|
|
57
|
-
this.write(str, COLORS.YELLOW, spinner, file);
|
|
58
|
-
}
|
|
59
|
-
static success(str = "", spinner = false, file) {
|
|
60
|
-
this.write(str, COLORS.GREEN, spinner, file);
|
|
61
|
-
}
|
|
62
|
-
static getPrefix() {
|
|
63
|
-
return this.prefix ? this.prefix + " " : "";
|
|
64
|
-
}
|
|
65
|
-
static getPostfix() {
|
|
66
|
-
return this.postfix ? this.postfix + " " : "";
|
|
67
|
-
}
|
|
68
|
-
static clearLines(number) {
|
|
69
|
-
for (let i = 0; i < number; i++) {
|
|
70
|
-
const y = i === 0 ? null : -1;
|
|
71
|
-
readline.moveCursor(log_stdout, 0, y);
|
|
72
|
-
readline.clearLine(log_stdout, 0);
|
|
73
|
-
}
|
|
74
|
-
readline.cursorTo(log_stdout, 0);
|
|
75
|
-
}
|
|
76
|
-
static write(str = "", color, spinner, file = "") {
|
|
77
|
-
if (this.loader) {
|
|
78
|
-
clearInterval(this.loader);
|
|
79
|
-
this.loader = null;
|
|
80
|
-
}
|
|
81
|
-
if (spinner) {
|
|
82
|
-
const P = ["\\", "|", "/", "-"];
|
|
83
|
-
let x = 0;
|
|
84
|
-
readline.clearLine(log_stdout, 0);
|
|
85
|
-
log_stdout.write(`\r${this.getPrefix()}${P[x++]} ${this.color(str, color)}${this.getPostfix()}`);
|
|
86
|
-
if (this.summaryLines.length) {
|
|
87
|
-
readline.clearScreenDown(log_stdout);
|
|
88
|
-
log_stdout.write(`\n${this.processSummaryLines()}`);
|
|
89
|
-
readline.moveCursor(log_stdout, 0, -this.summaryLines.length);
|
|
90
|
-
}
|
|
91
|
-
x &= 3;
|
|
92
|
-
this.loader = setInterval(() => {
|
|
93
|
-
log_stdout.write(`\r${this.getPrefix()}${P[x++]} ${this.color(str, color)}${this.getPostfix()}`);
|
|
94
|
-
x &= 3;
|
|
95
|
-
}, 250);
|
|
96
|
-
}
|
|
97
|
-
else {
|
|
98
|
-
//this.clearLines(this.summaryLines.length + (this.loader ? 1 : 0));
|
|
99
|
-
//readline.moveCursor(log_stdout, 0, this.summaryLines.length);
|
|
100
|
-
//readline.cursorTo(log_stdout, 0);
|
|
101
|
-
readline.clearLine(log_stdout, 0);
|
|
102
|
-
log_stdout.write(`\r${this.getPrefix()}${this.color(str, color)}${this.getPostfix()}\n`);
|
|
103
|
-
if (file)
|
|
104
|
-
fs.appendFileSync(file, `\r${this.getPrefix()}${this.color(str, color)}${this.getPostfix()}\n`);
|
|
105
|
-
if (this.summaryLines.length && !this.first) {
|
|
106
|
-
readline.clearScreenDown(log_stdout);
|
|
107
|
-
log_stdout.write(`\r${this.processSummaryLines()}`);
|
|
108
|
-
readline.moveCursor(log_stdout, 0, -(this.summaryLines.length - 1));
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
this.first = false;
|
|
112
|
-
}
|
|
113
|
-
}
|
package/dist/Crawler.js
DELETED
|
@@ -1,85 +0,0 @@
|
|
|
1
|
-
import { pool } from "./common.js";
|
|
2
|
-
import Webdriver from "selenium-webdriver";
|
|
3
|
-
import Console from "./Console.js";
|
|
4
|
-
import { Options } from "selenium-webdriver/chrome.js";
|
|
5
|
-
export default class Crawler {
|
|
6
|
-
drivers = [];
|
|
7
|
-
first = true;
|
|
8
|
-
options = {
|
|
9
|
-
concurrent: 1,
|
|
10
|
-
throttling: false,
|
|
11
|
-
crawlListing: null,
|
|
12
|
-
nextPage: null,
|
|
13
|
-
crawlHub: null,
|
|
14
|
-
crawlDetail: null
|
|
15
|
-
};
|
|
16
|
-
constructor(options) {
|
|
17
|
-
this.options = { ...this.options, ...options };
|
|
18
|
-
}
|
|
19
|
-
execute() {
|
|
20
|
-
this.createDrivers();
|
|
21
|
-
try {
|
|
22
|
-
return new Promise(resolve => {
|
|
23
|
-
this.options.crawlHub(this.drivers[0]).then(urls => {
|
|
24
|
-
const tasks = urls.map((url, index) => () => {
|
|
25
|
-
const driver = this.drivers.pop();
|
|
26
|
-
Console.log(`[${index + 1}/${Math.floor(urls.length)}] Valuating url ${urls[index]}`);
|
|
27
|
-
return this.crawlFn(driver, url)
|
|
28
|
-
.then(results => this.options.callback?.call(null, results, index, this.first))
|
|
29
|
-
.finally(() => {
|
|
30
|
-
this.first = false;
|
|
31
|
-
this.drivers.push(driver);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
pool(tasks, this.options.concurrent).then(results => {
|
|
35
|
-
this.destroyDrivers();
|
|
36
|
-
resolve(results);
|
|
37
|
-
Console.success("FINISHED");
|
|
38
|
-
});
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
console.error(e);
|
|
44
|
-
this.destroyDrivers();
|
|
45
|
-
}
|
|
46
|
-
}
|
|
47
|
-
createDrivers() {
|
|
48
|
-
for (let i = 0; i < this.options.concurrent; i++) {
|
|
49
|
-
this.drivers.push(new Webdriver.Builder()
|
|
50
|
-
.withCapabilities(Webdriver.Capabilities.chrome())
|
|
51
|
-
.setChromeOptions(new Options().headless())
|
|
52
|
-
.forBrowser("chrome")
|
|
53
|
-
.build());
|
|
54
|
-
}
|
|
55
|
-
}
|
|
56
|
-
destroyDrivers() {
|
|
57
|
-
this.drivers.forEach(driver => driver.close());
|
|
58
|
-
}
|
|
59
|
-
crawlFn(driver, url) {
|
|
60
|
-
const _self = this;
|
|
61
|
-
return new Promise(resolve => {
|
|
62
|
-
driver.get(url).then(() => {
|
|
63
|
-
_self.options.crawlListing(driver).then(listings => {
|
|
64
|
-
if (_self.options.crawlDetail) {
|
|
65
|
-
pool(listings.map((listing) => () => new Promise(resolve1 => {
|
|
66
|
-
driver.get(listing.url).then(() => _self.options.crawlDetail(driver).then(detail => resolve1({ ...listing, ...detail })));
|
|
67
|
-
})), 1)
|
|
68
|
-
.then(details => {
|
|
69
|
-
_self.options.pageCallback?.call(null, details);
|
|
70
|
-
driver.get(url).then(() => _self.options.nextPage(driver)
|
|
71
|
-
.then(url => _self.crawlFn(driver, url).then(acc => resolve([...details, ...acc])))
|
|
72
|
-
.catch(() => resolve(details)));
|
|
73
|
-
});
|
|
74
|
-
}
|
|
75
|
-
else {
|
|
76
|
-
_self.options.pageCallback?.call(null, listings);
|
|
77
|
-
_self.options.nextPage(driver)
|
|
78
|
-
.then(url => _self.crawlFn(driver, url).then(acc => resolve([...listings, ...acc])))
|
|
79
|
-
.catch(() => resolve(listings));
|
|
80
|
-
}
|
|
81
|
-
});
|
|
82
|
-
});
|
|
83
|
-
});
|
|
84
|
-
}
|
|
85
|
-
}
|
package/dist/Pool.js
DELETED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
import Console, { COLORS } from "./Console.js";
|
|
2
|
-
const BATCH_SIZE = 1000;
|
|
3
|
-
export class Pool {
|
|
4
|
-
name;
|
|
5
|
-
concurrency;
|
|
6
|
-
queue = [];
|
|
7
|
-
activeCount;
|
|
8
|
-
constructor(name = "default", concurrency) {
|
|
9
|
-
this.name = name;
|
|
10
|
-
this.concurrency = concurrency;
|
|
11
|
-
this.queue = [];
|
|
12
|
-
this.activeCount = 0;
|
|
13
|
-
this.updatePrint();
|
|
14
|
-
}
|
|
15
|
-
static run = async (calls, concurrency) => {
|
|
16
|
-
const pool = new Pool("", concurrency);
|
|
17
|
-
const batchPromises = Array.from({ length: Math.ceil(calls.length / BATCH_SIZE) }, async (_, index) => {
|
|
18
|
-
const start = index * BATCH_SIZE;
|
|
19
|
-
const end = Math.min((index + 1) * BATCH_SIZE, calls.length);
|
|
20
|
-
const batch = calls.slice(start, end);
|
|
21
|
-
return await pool.enqueue(...batch);
|
|
22
|
-
});
|
|
23
|
-
const batchResults = await Promise.all(batchPromises);
|
|
24
|
-
return batchResults.flat();
|
|
25
|
-
};
|
|
26
|
-
enqueue(...calls) {
|
|
27
|
-
return Promise.all(calls.map(call => new Promise((resolve, reject) => {
|
|
28
|
-
this.queue.push({
|
|
29
|
-
call,
|
|
30
|
-
resolve,
|
|
31
|
-
reject,
|
|
32
|
-
});
|
|
33
|
-
this.schedule();
|
|
34
|
-
})));
|
|
35
|
-
}
|
|
36
|
-
schedule() {
|
|
37
|
-
while (this.activeCount < this.concurrency && this.queue.length > 0) {
|
|
38
|
-
const { call, resolve, reject } = this.queue.shift();
|
|
39
|
-
this.activeCount++;
|
|
40
|
-
call()
|
|
41
|
-
.then((result) => {
|
|
42
|
-
resolve(result);
|
|
43
|
-
})
|
|
44
|
-
.catch((error) => {
|
|
45
|
-
reject(error);
|
|
46
|
-
})
|
|
47
|
-
.finally(() => {
|
|
48
|
-
this.activeCount--;
|
|
49
|
-
this.updatePrint();
|
|
50
|
-
this.schedule();
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
print() {
|
|
55
|
-
return this._print;
|
|
56
|
-
}
|
|
57
|
-
updatePrint() {
|
|
58
|
-
const textStart = `${Console.color(this.name.padEnd(16), COLORS.YELLOW)} [POOL][`;
|
|
59
|
-
const textEnd = `][${this.activeCount + this.queue?.length}/${this.concurrency}]`;
|
|
60
|
-
let progress = "";
|
|
61
|
-
const max = process.stdout.columns - Math.max(textStart.length + textEnd.length, process.stdout.columns * 0.5);
|
|
62
|
-
const percent = this.activeCount / this.concurrency * max;
|
|
63
|
-
for (let j = 0; j < max; j++) {
|
|
64
|
-
const char = j < percent ? "=" : " ";
|
|
65
|
-
progress += Console.color(char, j < (max * 0.8) ? COLORS.GREEN : j < (max * 0.9) ? COLORS.YELLOW : COLORS.RED);
|
|
66
|
-
}
|
|
67
|
-
this._print = textStart + progress + textEnd;
|
|
68
|
-
}
|
|
69
|
-
_print;
|
|
70
|
-
}
|
package/dist/common.js
DELETED
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import fs from "fs";
|
|
2
|
-
import { PromisePool } from "@supercharge/promise-pool";
|
|
3
|
-
import Console from "./Console.js";
|
|
4
|
-
import { brotliCompressSync, brotliDecompressSync } from "zlib";
|
|
5
|
-
import { parse } from "csv-parse/sync";
|
|
6
|
-
export class CustomError extends Error {
|
|
7
|
-
critical;
|
|
8
|
-
constructor(message, critical = false) {
|
|
9
|
-
super(message);
|
|
10
|
-
this.critical = critical;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
export function sequentially(promises, step = 1, exit = false) {
|
|
14
|
-
return new Promise(resolve => {
|
|
15
|
-
let results = [];
|
|
16
|
-
const groupedPromises = promises.reduce((acc, fn, index) => {
|
|
17
|
-
const i = Math.floor(index / step);
|
|
18
|
-
if (acc[i])
|
|
19
|
-
acc[i].push(fn);
|
|
20
|
-
else
|
|
21
|
-
acc[i] = [fn];
|
|
22
|
-
return acc;
|
|
23
|
-
}, []);
|
|
24
|
-
groupedPromises.reduce((accumulatorPromise, promise) => {
|
|
25
|
-
return accumulatorPromise.then(() => {
|
|
26
|
-
return Promise.all(promise.map(f => f())).then(res => {
|
|
27
|
-
results = [...results, ...res];
|
|
28
|
-
});
|
|
29
|
-
});
|
|
30
|
-
}, Promise.resolve([])).then(() => {
|
|
31
|
-
resolve(results);
|
|
32
|
-
});
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
export function pool(promises, concurrent, stopIfError = true) {
|
|
36
|
-
return new Promise((resolve, reject) => {
|
|
37
|
-
PromisePool
|
|
38
|
-
.for(promises)
|
|
39
|
-
.withConcurrency(concurrent)
|
|
40
|
-
.handleError(async (error, user, pool) => {
|
|
41
|
-
if (stopIfError || (error instanceof CustomError && error.critical)) {
|
|
42
|
-
reject(error);
|
|
43
|
-
pool.stop();
|
|
44
|
-
}
|
|
45
|
-
})
|
|
46
|
-
.useCorrespondingResults()
|
|
47
|
-
.process((fn) => fn())
|
|
48
|
-
.then((poolResult) => resolve(poolResult.results))
|
|
49
|
-
.catch((poolResult) => reject(poolResult.errors));
|
|
50
|
-
});
|
|
51
|
-
}
|
|
52
|
-
export async function promisesFirst(fns) {
|
|
53
|
-
for await (const f of fns) {
|
|
54
|
-
try {
|
|
55
|
-
const a = await f();
|
|
56
|
-
if (a) {
|
|
57
|
-
return a;
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
catch (e) {
|
|
61
|
-
//console.error(e);
|
|
62
|
-
//
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
throw "No promises resolve";
|
|
66
|
-
}
|
|
67
|
-
export function readCache(path) {
|
|
68
|
-
const brotliPath = `${path}.br`;
|
|
69
|
-
if (!fs.existsSync(brotliPath))
|
|
70
|
-
return null;
|
|
71
|
-
let data;
|
|
72
|
-
try {
|
|
73
|
-
data = JSON.parse(brotliDecompressSync(fs.readFileSync(brotliPath)).toString());
|
|
74
|
-
}
|
|
75
|
-
catch (e) {
|
|
76
|
-
data = null;
|
|
77
|
-
}
|
|
78
|
-
return data;
|
|
79
|
-
}
|
|
80
|
-
export function writeCache(path, data) {
|
|
81
|
-
const brotliPath = `${path}.br`;
|
|
82
|
-
try {
|
|
83
|
-
fs.writeFileSync(brotliPath, brotliCompressSync(JSON.stringify(data)), "binary");
|
|
84
|
-
}
|
|
85
|
-
catch (e) {
|
|
86
|
-
console.error("Can't pack data to file");
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
export function readJson(path, strict = false) {
|
|
90
|
-
if (!fs.existsSync(path) && strict)
|
|
91
|
-
throw new Error(`File ${path} not found`);
|
|
92
|
-
if (!fs.existsSync(path))
|
|
93
|
-
return null;
|
|
94
|
-
let json;
|
|
95
|
-
try {
|
|
96
|
-
json = JSON.parse(fs.readFileSync(path, "utf8"));
|
|
97
|
-
}
|
|
98
|
-
catch (e) {
|
|
99
|
-
json = null;
|
|
100
|
-
}
|
|
101
|
-
return json;
|
|
102
|
-
}
|
|
103
|
-
export function readCSV(path, delimiter = ",", strict = false) {
|
|
104
|
-
if (!fs.existsSync(path) && strict)
|
|
105
|
-
throw new Error(`File ${path} not found`);
|
|
106
|
-
if (!fs.existsSync(path))
|
|
107
|
-
return null;
|
|
108
|
-
let csv;
|
|
109
|
-
try {
|
|
110
|
-
csv = parse(fs.readFileSync(path, "utf8"), {
|
|
111
|
-
columns: true,
|
|
112
|
-
skip_empty_lines: true,
|
|
113
|
-
delimiter: delimiter
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
catch (e) {
|
|
117
|
-
csv = null;
|
|
118
|
-
}
|
|
119
|
-
return csv;
|
|
120
|
-
}
|
|
121
|
-
export function groupBy(list, keyGetter) {
|
|
122
|
-
const map = new Map();
|
|
123
|
-
list.forEach((item) => {
|
|
124
|
-
const key = keyGetter(item);
|
|
125
|
-
const collection = map.get(key);
|
|
126
|
-
if (!collection) {
|
|
127
|
-
map.set(key, [item]);
|
|
128
|
-
}
|
|
129
|
-
else {
|
|
130
|
-
collection.push(item);
|
|
131
|
-
}
|
|
132
|
-
});
|
|
133
|
-
return map;
|
|
134
|
-
}
|
|
135
|
-
export function sleep(ms, feedback = false) {
|
|
136
|
-
return new Promise((resolve) => {
|
|
137
|
-
const t = performance.now();
|
|
138
|
-
setTimeout(resolve, ms);
|
|
139
|
-
if (feedback)
|
|
140
|
-
setInterval(function () {
|
|
141
|
-
const left = (ms - (performance.now() - t)) / 1000;
|
|
142
|
-
Console.log(`Time left: ${Math.round(left)}s`, true);
|
|
143
|
-
}, 1000);
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
export function unique(array) {
|
|
147
|
-
if (!array || !array.length)
|
|
148
|
-
return;
|
|
149
|
-
return Array.from(new Set(array));
|
|
150
|
-
}
|
package/dist/src/Cache.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Cache.js","sourceRoot":"","sources":["../../src/Cache.ts"],"names":[],"mappings":"AAAA,OAAO,KAA6G,MAAM,OAAO,CAAC;AAClI,OAAO,EAAC,kBAAkB,EAAE,oBAAoB,EAAC,MAAM,MAAM,CAAC;AAC9D,OAAO,EAAC,MAAM,EAAC,MAAM,aAAa,CAAC;AAEnC,MAAM,CAAN,IAAY,IAKX;AALD,WAAY,IAAI;IACZ,mCAAM,CAAA;IACN,+BAAI,CAAA;IACJ,+BAAI,CAAA;IACJ,iDAAa,CAAA;AACjB,CAAC,EALW,IAAI,KAAJ,IAAI,QAKf;AAED,MAAM,OAAO,KAAK;IAEd,IAAI,CAAe;IAEZ,MAAM,CAAoF;IAEjG,YAAY,OAA4B;QACpC,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,YAAY,CAAC,OAAO,CAAC,CAAC;IAC9C,CAAC;IAED,KAAK,CAAC,KAAK;QACP,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;IACtC,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW,EAAE,OAAa,IAAI,CAAC,aAAa;QAElD,IAAI,CAAC,IAAI,CAAC,IAAI;YACV,MAAM,IAAI,CAAC,KAAK,EAAE,CAAC;QACvB,qCAAqC;QACrC,kBAAkB;QAElB,IAAI,IAAI,CAAC;QAET,IAAI,CAAC;YACD,QAAQ,IAAI,EAAE,CAAC;gBACX,KAAK,IAAI,CAAC,MAAM;oBACZ,IAAI,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;oBAClC,MAAM;gBACV,KAAK,IAAI,CAAC,aAAa,CAAC;gBACxB,OAAO,CAAC,CAAC,CAAC;oBACN,MAAM,KAAK,GAAG,MAAM,IAAI,CAAC,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