@cloud411716/fancy-webnovel 0.2.22 → 0.2.24
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
|
@@ -280,19 +280,21 @@ async function scrapeRank(channelId, rankTypeId, periodId) {
|
|
|
280
280
|
books = rawBooks.filter(isUsableBook);
|
|
281
281
|
|
|
282
282
|
// 直接从 DOM 提取 /shuku/{id}/ 链接补到每本书上(不依赖 XHR 匹配)
|
|
283
|
-
const urlMap = {};
|
|
284
283
|
await page.evaluate(() => {
|
|
284
|
+
var urlMap = {};
|
|
285
285
|
document.querySelectorAll('a[href*="/shuku/"]').forEach(a => {
|
|
286
286
|
var m = a.href.match(/\/shuku\/(\d+)\//);
|
|
287
287
|
if (!m) return;
|
|
288
288
|
var id = m[1];
|
|
289
|
-
// 取离它最近的文字作为书名
|
|
290
289
|
var title = (a.innerText || '').trim();
|
|
291
290
|
if (title && title.length < 50 && title.length > 0) {
|
|
292
291
|
urlMap[title] = 'https://www.qimao.com/shuku/' + id + '/';
|
|
293
292
|
}
|
|
294
293
|
});
|
|
294
|
+
// 通过 window 传递到外面
|
|
295
|
+
window.__qimaoUrlMap = urlMap;
|
|
295
296
|
});
|
|
297
|
+
const urlMap = await page.evaluate(() => window.__qimaoUrlMap || {});
|
|
296
298
|
const norm = s => (s || '').replace(/\s+/g, '');
|
|
297
299
|
for (const b of books) {
|
|
298
300
|
if (!b.url) {
|
|
@@ -347,7 +349,7 @@ async function scrapeRank(channelId, rankTypeId, periodId) {
|
|
|
347
349
|
|
|
348
350
|
for (const b of books) {
|
|
349
351
|
lines.push(`书名:${b.title || ""}`);
|
|
350
|
-
lines.push(`题材:${b.genre || ""}`);
|
|
352
|
+
lines.push(`题材:${b.genre || ""}${b.subGenre ? " - " + b.subGenre : ""}`);
|
|
351
353
|
lines.push(`作者:${b.author || ""}`);
|
|
352
354
|
if (b.url) lines.push(`作品页:${b.url}`);
|
|
353
355
|
lines.push("");
|