@cloud411716/fancy-webnovel 0.1.46 → 0.1.48
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/package.json +1 -1
- package/plugins/fancy-scan/scripts/run-scan.js +11 -10
- package/plugins/fancy-scan/scripts/scrapers/{fanqie-rank-scraper.js → fanqie-rank-scraper.cjs} +1 -1
- package/plugins/fancy-scan/scripts/scrapers/{jjwxc-rank-scraper.js → jjwxc-rank-scraper.cjs} +1 -1
- package/plugins/fancy-scan/scripts/scrapers/{qimao-rank-scraper.js → qimao-rank-scraper.cjs} +1 -1
- package/plugins/fancy-scan/scripts/scrapers/{zhihu-rank-scraper.js → zhihu-rank-scraper.cjs} +1 -1
- /package/plugins/fancy-scan/scripts/scrapers/{cdp-utils.js → cdp-utils.cjs} +0 -0
package/package.json
CHANGED
|
@@ -176,28 +176,29 @@ function spawnScraper(platform, length, outDir) {
|
|
|
176
176
|
return new Promise(async (resolve) => {
|
|
177
177
|
const { spawn } = await import('child_process');
|
|
178
178
|
const args = scraperArgs(platform, length, outDir);
|
|
179
|
-
// 先尝试 9222 端口(Chrome CDP),没有 Chrome 则尝试 9223
|
|
180
179
|
const ports = ['9222', '9223'];
|
|
181
180
|
let portIdx = 0;
|
|
182
181
|
|
|
183
182
|
function tryPort(port) {
|
|
184
183
|
const scraperScript = join(dirname(fileURLToPath(import.meta.url)), 'scrapers', args.script);
|
|
185
184
|
const fullArgs = ['--port', port, ...args.extra];
|
|
185
|
+
// stderr 透传到父进程 stderr,用户实时看到进度
|
|
186
186
|
const p = spawn('node', [scraperScript, ...fullArgs], {
|
|
187
187
|
timeout: 120000,
|
|
188
|
-
stdio: ['ignore', 'pipe', '
|
|
188
|
+
stdio: ['ignore', 'pipe', 'inherit'],
|
|
189
189
|
});
|
|
190
|
-
let out = ''
|
|
190
|
+
let out = '';
|
|
191
191
|
p.stdout.on('data', d => { out += d.toString(); });
|
|
192
|
-
p.stderr.on('data', d => { err += d.toString(); });
|
|
193
192
|
p.on('close', (code) => {
|
|
194
193
|
if (code === 0 && out.trim()) {
|
|
195
|
-
resolve({ ok: true, output: out, stderr:
|
|
194
|
+
resolve({ ok: true, output: out, stderr: '' });
|
|
196
195
|
} else if (portIdx < ports.length - 1) {
|
|
197
196
|
portIdx++;
|
|
198
197
|
tryPort(ports[portIdx]);
|
|
199
198
|
} else {
|
|
200
|
-
|
|
199
|
+
// 截取 stderr 末尾 300 字符,避免过长
|
|
200
|
+
const errTail = out.trimEnd().slice(-300);
|
|
201
|
+
resolve({ ok: false, output: out, error: errTail || `exit ${code}` });
|
|
201
202
|
}
|
|
202
203
|
});
|
|
203
204
|
p.on('error', (e) => {
|
|
@@ -213,22 +214,22 @@ function scraperArgs(platform, length) {
|
|
|
213
214
|
switch (platform) {
|
|
214
215
|
case 'fanqie':
|
|
215
216
|
return {
|
|
216
|
-
script: 'fanqie-rank-scraper.
|
|
217
|
+
script: 'fanqie-rank-scraper.cjs',
|
|
217
218
|
extra: ['--channel', 'all', '--top', '20'],
|
|
218
219
|
};
|
|
219
220
|
case 'jinjiang':
|
|
220
221
|
return {
|
|
221
|
-
script: 'jjwxc-rank-scraper.
|
|
222
|
+
script: 'jjwxc-rank-scraper.cjs',
|
|
222
223
|
extra: ['--type', '12'],
|
|
223
224
|
};
|
|
224
225
|
case 'zhihu':
|
|
225
226
|
return {
|
|
226
|
-
script: 'zhihu-rank-scraper.
|
|
227
|
+
script: 'zhihu-rank-scraper.cjs',
|
|
227
228
|
extra: ['--length', length === 'short' ? 'short' : 'long'],
|
|
228
229
|
};
|
|
229
230
|
case 'qimao':
|
|
230
231
|
return {
|
|
231
|
-
script: 'qimao-rank-scraper.
|
|
232
|
+
script: 'qimao-rank-scraper.cjs',
|
|
232
233
|
extra: ['--channel', length === 'short' ? 'female' : 'male', '--type', 'hot'],
|
|
233
234
|
};
|
|
234
235
|
case 'dianzhong':
|
package/plugins/fancy-scan/scripts/scrapers/{fanqie-rank-scraper.js → fanqie-rank-scraper.cjs}
RENAMED
|
@@ -20,7 +20,7 @@
|
|
|
20
20
|
|
|
21
21
|
const fs = require("fs");
|
|
22
22
|
const path = require("path");
|
|
23
|
-
const { ab, sleep, evalJSONBase64, scrollLoad, getArg, localDateStamp, runCli } = require("./cdp-utils");
|
|
23
|
+
const { ab, sleep, evalJSONBase64, scrollLoad, getArg, localDateStamp, runCli } = require("./cdp-utils.cjs");
|
|
24
24
|
|
|
25
25
|
// 一次详情请求的并发批大小。番茄详情页用同步 XHR 拉取,批太大会撞上
|
|
26
26
|
// cdp-utils 里 ab() 的 20s 超时;超时会显式失败,这里分批是为了避免整个题材被中断。
|
package/plugins/fancy-scan/scripts/scrapers/{jjwxc-rank-scraper.js → jjwxc-rank-scraper.cjs}
RENAMED
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
|
|
25
25
|
const fs = require("fs");
|
|
26
26
|
const path = require("path");
|
|
27
|
-
const { ab, sleep, evalJSONBase64, getArg, localDateStamp, runCli } = require("./cdp-utils");
|
|
27
|
+
const { ab, sleep, evalJSONBase64, getArg, localDateStamp, runCli } = require("./cdp-utils.cjs");
|
|
28
28
|
|
|
29
29
|
const BASE_URL = "https://www.jjwxc.net/topten.php";
|
|
30
30
|
|
package/plugins/fancy-scan/scripts/scrapers/{qimao-rank-scraper.js → qimao-rank-scraper.cjs}
RENAMED
|
@@ -19,7 +19,7 @@
|
|
|
19
19
|
|
|
20
20
|
const fs = require("fs");
|
|
21
21
|
const path = require("path");
|
|
22
|
-
const { ab, sleep, evalJSONBase64, scrollLoad, getArg, localDateStamp, runCli } = require("./cdp-utils");
|
|
22
|
+
const { ab, sleep, evalJSONBase64, scrollLoad, getArg, localDateStamp, runCli } = require("./cdp-utils.cjs");
|
|
23
23
|
|
|
24
24
|
const RANK_URL = "https://www.qimao.com/paihang";
|
|
25
25
|
|
package/plugins/fancy-scan/scripts/scrapers/{zhihu-rank-scraper.js → zhihu-rank-scraper.cjs}
RENAMED
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
|
|
22
22
|
const fs = require("fs");
|
|
23
23
|
const path = require("path");
|
|
24
|
-
const { ab, evalJSONBase64, getArg, localDateStamp, runCli } = require("./cdp-utils");
|
|
24
|
+
const { ab, evalJSONBase64, getArg, localDateStamp, runCli } = require("./cdp-utils.cjs");
|
|
25
25
|
|
|
26
26
|
const PORT = 9222;
|
|
27
27
|
const OUTDIR = getArg(process.argv, "--outdir") || "扫榜结果";
|
|
File without changes
|