chengjie hace 2 meses
padre
commit
216fd12520

+ 13 - 2
.gitignore

@@ -11,8 +11,19 @@ public/ZxGw5vkQbG.txt
11 11
 src/web_crawler/Zhui-Xu/
12 12
 src/web_crawler/Hidden-Assassin/
13 13
 src/web_crawler/Release-that-Witch/
14
-src/web_crawler/Strange-Life-of-a-Cat/
15
-src/web_crawler/Throne-of-Magical-Arcana/
14
+src/web_crawler/Strange-Life-of-a-Cat/Strange-Life-of-a-Cat_contents/
15
+src/web_crawler/Throne-of-Magical-Arcana/Throne-of-Magical-Arcana_contents/
16 16
 src/web_crawler/The-Legendary-Mechanic/
17 17
 src/web_crawler/奥术神座/
18 18
 src/web_crawler/回到过去变成猫/
19
+src/web_crawler/Strange-Life-of-a-Cat/Strange-Life-of-a-Cat_all_contents.json
20
+src/web_crawler/Strange-Life-of-a-Cat/Strange-Life-of-a-Cat_chapters_with_content.json
21
+src/web_crawler/Strange-Life-of-a-Cat/Strange-Life-of-a-Cat.jpeg
22
+src/web_crawler/Strange-Life-of-a-Cat/Strange-Life-of-a-Cat.txt
23
+src/web_crawler/Strange-Life-of-a-Cat/Strange-Life-of-a-Cat.epub
24
+src/web_crawler/Throne-of-Magical-Arcana/Throne-of-Magical-Arcana_all_contents.json
25
+src/web_crawler/Throne-of-Magical-Arcana/Throne-of-Magical-Arcana_chapters_with_content.json
26
+src/web_crawler/Throne-of-Magical-Arcana/Throne-of-Magical-Arcana.jpeg
27
+src/web_crawler/Throne-of-Magical-Arcana/Throne-of-Magical-Arcana.txt
28
+src/web_crawler/Throne-of-Magical-Arcana/Throne-of-Magical-Arcana.epub
29
+.gitignore

+ 11 - 16
src/api/yjbdc/readerController.js

@@ -42,24 +42,19 @@ export async function GetReaderBooksChapter(ctx) {
42 42
     };
43 43
 
44 44
     let result = [];
45
-
46 45
     const { readdir, readFile, writeFile } = fs.promises;
47
-    let sourceDir = path.join(__dirname, '../../web_crawler/'+ param.Title + '/' + param.Title + '_contents');
48
-    const files = (await readdir(sourceDir))
49
-            .filter(file => file.endsWith('.html'))
50
-            .sort((a, b) => parseInt(a.split('_')[0]) - parseInt(b.split('_')[0]));
51
-    
52
-    for (const file of files) {
53
-        // 提取章节标题
54
-        const titleMatch = file.match(/_([^\.]+)\.html$/);
55
-        const title = titleMatch ? titleMatch[1] : file;
56
-        result.push(title);
46
+    let filePath = path.join(__dirname, '../../web_crawler/'+ param.Title + '/' + param.Title + '_chapters.json');
47
+    let content = await fs.promises.readFile(filePath, 'utf-8');
48
+    content=JSON.parse(content);
49
+    for(const item of content) {
50
+        result.push(item.title);
57 51
     }
58 52
 
59
-    if (param.Title === "Strange-Life-of-a-Cat") {
60
-        for(let i=0;i<5;i++) 
61
-            result = result.slice(1); // 去掉第一个章节
62
-    }
53
+    // 处理Strange-Life-of-a-Cat的章节,去掉前5个章节
54
+    // if (param.Title === "Strange-Life-of-a-Cat") {
55
+    //     for(let i=0;i<5;i++) 
56
+    //         result = result.slice(1); // 去掉第一个章节
57
+    // }
63 58
 
64 59
     ctx.body = { "errcode": 10000, result: result };
65 60
 }
@@ -74,7 +69,7 @@ export async function GetReaderBooksChapterContent(ctx) {
74 69
 
75 70
     const {readFile} = fs.promises;
76 71
     // 读取文本文件
77
-    let filePath = path.join(__dirname, '../../web_crawler/' + param.Title + '.html');
72
+    let filePath = path.join(__dirname, '../../web_crawler/'+ param.Title + '/' + param.Title + '.html');
78 73
     
79 74
     const content = await fs.promises.readFile(filePath, 'utf-8');
80 75
     console.log(`已读取文件: ${filePath}`);

src/web_crawler/Strange-Life-of-a-Cat.html → src/web_crawler/Strange-Life-of-a-Cat/Strange-Life-of-a-Cat.html


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 2103 - 0
src/web_crawler/Strange-Life-of-a-Cat/Strange-Life-of-a-Cat_chapters.json


src/web_crawler/Throne-of-Magical-Arcana.html → src/web_crawler/Throne-of-Magical-Arcana/Throne-of-Magical-Arcana.html


La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 4562 - 0
src/web_crawler/Throne-of-Magical-Arcana/Throne-of-Magical-Arcana_chapters.json