@cloud411716/fancy-webnovel 0.2.21 → 0.2.23
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
CHANGED
|
@@ -183,6 +183,7 @@ async function scrapeRank(channelId, rankTypeId, periodId) {
|
|
|
183
183
|
if (!b.bookId && !b.novel_id && !b.id) continue;
|
|
184
184
|
const id = String(b.bookId || b.novel_id || b.id);
|
|
185
185
|
xhrBookMap.set(id, {
|
|
186
|
+
id: id,
|
|
186
187
|
title: b.title || b.bookName || b.name || "",
|
|
187
188
|
author: b.author || b.authorName || "",
|
|
188
189
|
});
|
|
@@ -278,6 +279,28 @@ async function scrapeRank(channelId, rankTypeId, periodId) {
|
|
|
278
279
|
rawCount = rawBooks.length;
|
|
279
280
|
books = rawBooks.filter(isUsableBook);
|
|
280
281
|
|
|
282
|
+
// 直接从 DOM 提取 /shuku/{id}/ 链接补到每本书上(不依赖 XHR 匹配)
|
|
283
|
+
const urlMap = {};
|
|
284
|
+
await page.evaluate(() => {
|
|
285
|
+
document.querySelectorAll('a[href*="/shuku/"]').forEach(a => {
|
|
286
|
+
var m = a.href.match(/\/shuku\/(\d+)\//);
|
|
287
|
+
if (!m) return;
|
|
288
|
+
var id = m[1];
|
|
289
|
+
// 取离它最近的文字作为书名
|
|
290
|
+
var title = (a.innerText || '').trim();
|
|
291
|
+
if (title && title.length < 50 && title.length > 0) {
|
|
292
|
+
urlMap[title] = 'https://www.qimao.com/shuku/' + id + '/';
|
|
293
|
+
}
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
const norm = s => (s || '').replace(/\s+/g, '');
|
|
297
|
+
for (const b of books) {
|
|
298
|
+
if (!b.url) {
|
|
299
|
+
var found = Object.entries(urlMap).find(([t]) => norm(t) === norm(b.title));
|
|
300
|
+
if (found) b.url = found[1];
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
|
|
281
304
|
// 用 XHR 数据覆盖明文书名/作者,绕过字体加密
|
|
282
305
|
if (xhrBookMap.size > 0) {
|
|
283
306
|
let updated = 0;
|
|
@@ -324,7 +347,7 @@ async function scrapeRank(channelId, rankTypeId, periodId) {
|
|
|
324
347
|
|
|
325
348
|
for (const b of books) {
|
|
326
349
|
lines.push(`书名:${b.title || ""}`);
|
|
327
|
-
lines.push(`题材:${b.genre || ""}`);
|
|
350
|
+
lines.push(`题材:${b.genre || ""}${b.subGenre ? " - " + b.subGenre : ""}`);
|
|
328
351
|
lines.push(`作者:${b.author || ""}`);
|
|
329
352
|
if (b.url) lines.push(`作品页:${b.url}`);
|
|
330
353
|
lines.push("");
|