@cloud411716/fancy-webnovel 1.0.6 → 1.0.8

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.
@@ -5,34 +5,31 @@
5
5
  * pageContext JSON,绕过了服务端渲染的加密,直接提取书籍数据。
6
6
  * 无需 Playwright。
7
7
  *
8
- * Rank paths (mobile):
9
- * /rank/1_5173_2 畅销榜
10
- * /rank/1_5173_7 月票榜
11
- * /rank/1_5173_14 签约作者新书榜
12
- * /rank/1_5173_22 公众作者新书榜
13
- * /rank/1_5173_31 新人作者新书榜
8
+ * Rank paths (mobile, slug-based):
9
+ * /rank/hotsales/ 畅销榜
10
+ * /rank/yuepiao/ 月票榜
11
+ * /rank/newbook/ 新书榜
12
+ * /rank/newauthor/ 新人作者榜
14
13
  */
15
14
 
16
15
  const MOBILE_BASE = 'https://m.qidian.com';
17
16
 
18
- // RANK_PATHS keys match rank.type (passed by scraper as rankId)
17
+ // rank.id URL slug, matches RANK_PATHS keys used by scrapeRank()
19
18
  const RANK_PATHS = {
20
- '5173_2': '/rank/1_5173_2',
21
- '5173_7': '/rank/1_5173_7',
22
- '5173_14': '/rank/1_5173_14',
23
- '5173_22': '/rank/1_5173_22',
24
- '5173_31': '/rank/1_5173_31',
19
+ hotsales: '/rank/hotsales/',
20
+ yuepiao: '/rank/yuepiao/',
21
+ newbook: '/rank/newbook/',
22
+ newauthor: '/rank/newauthor/',
25
23
  };
26
24
 
27
25
  export const platform = 'qidian';
28
26
  export const label = '起点';
29
27
 
30
28
  export const rankList = [
31
- { id: '5173_2', label: '畅销榜', channel: '1', type: '5173_2' },
32
- { id: '5173_7', label: '月票榜', channel: '1', type: '5173_7' },
33
- { id: '5173_14', label: '签约作者新书榜', channel: '1', type: '5173_14' },
34
- { id: '5173_22', label: '公众作者新书榜', channel: '1', type: '5173_22' },
35
- { id: '5173_31', label: '新人作者新书榜', channel: '1', type: '5173_31' },
29
+ { id: 'hotsales', label: '畅销榜', channel: '1', type: 'hotsales' },
30
+ { id: 'yuepiao', label: '月票榜', channel: '1', type: 'yuepiao' },
31
+ { id: 'newbook', label: '新书榜', channel: '1', type: 'newbook' },
32
+ { id: 'newauthor', label: '新人作者榜', channel: '1', type: 'newauthor' },
36
33
  ];
37
34
 
38
35
  const HEADERS = {
@@ -73,15 +70,13 @@ export async function scrapeRank(rankId, ctx, signal) {
73
70
  if (!records.length) return { ok: false, books: [], error: 'no book records found' };
74
71
 
75
72
  const books = records.map((r) => ({
76
- rank: r.rank ?? 0,
77
- title: r.title ?? '',
78
- author: r.author ?? '',
79
- category: r.categoryName ?? '',
80
- status: r.statusName ?? '',
81
- words: r.wordCount ?? 0,
82
- intro: (r.description ?? '').slice(0, 150),
83
- cover: r.cover ?? '',
84
- bookId: r.bookId ?? '',
73
+ rank: r.rankNum ?? 0,
74
+ title: r.bName ?? '',
75
+ author: r.bAuth ?? '',
76
+ category: r.cat ?? '',
77
+ words: r.cnt ?? '0',
78
+ intro: (r.desc ?? '').slice(0, 150),
79
+ bookId: r.bid ?? '',
85
80
  }));
86
81
 
87
82
  return { ok: true, books };
@@ -79,7 +79,7 @@ export async function runScans(ctx, projectRoot, ranks, signal) {
79
79
  attempt++;
80
80
  try {
81
81
  result = await withTimeout(
82
- platform.scrapeRank(rank.type, ctx, signal),
82
+ platform.scrapeRank(rank.id, ctx, signal),
83
83
  ctx,
84
84
  SCRAPER_TIMEOUT,
85
85
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cloud411716/fancy-webnovel",
3
- "version": "1.0.6",
3
+ "version": "1.0.8",
4
4
  "type": "module",
5
5
  "main": "index.js",
6
6
  "exports": {