From f0b277489c33baa100a4772100abac7abbb88761 Mon Sep 17 00:00:00 2001
From: Fengshaoyuan <1914442689@qq.com>
Date: Wed, 15 May 2024 09:16:21 +0800
Subject: [PATCH] =?UTF-8?q?=E6=89=A9=E5=B1=95paozw?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Classes/ChapterPaozwClass.cs | 120 +++++++++++++++++++++++++++++++++++
MainForm.Designer.cs | 1 +
MainForm.cs | 5 ++
3 files changed, 126 insertions(+)
create mode 100644 Classes/ChapterPaozwClass.cs
diff --git a/Classes/ChapterPaozwClass.cs b/Classes/ChapterPaozwClass.cs
new file mode 100644
index 0000000..b3510e8
--- /dev/null
+++ b/Classes/ChapterPaozwClass.cs
@@ -0,0 +1,120 @@
+using HtmlAgilityPack;
+using HtmlToTxtWFA.Utils;
+using System.Collections.Generic;
+using System.Text;
+using System.Windows.Forms;
+
+namespace HtmlToTxtWFA.Classes
+{
+ ///
+ /// 章节 Nfxs
+ ///
+ public class ChapterPaozwClass : ChapterClass
+ {
+ public ChapterPaozwClass() { }
+
+ public ChapterPaozwClass(HtmlNode aElement, bool isStarted)
+ {
+ // 第1章 洪战
+ string label = aElement.InnerText;
+ if (!isStarted && (label.StartsWith("第1章") || label.StartsWith("第一章")))
+ {
+ this.Label = label;
+ this.Url = aElement.GetAttributeValue("href", "");
+ }
+ else if (isStarted && label.Contains("第") && label.Contains("章"))
+ {
+ this.Label = label;
+ this.Url = aElement.GetAttributeValue("href", "");
+ }
+ }
+
+ public override List ReadChapterList(string HOST, string serialNumber)
+ {
+ HtmlWeb web = new HtmlWeb();
+ HtmlAgilityPack.HtmlDocument doc;
+ HtmlNodeCollection conNodes;
+ //从url中加载
+ doc = web.LoadFromWebAsync(HOST + "/biquge/" + serialNumber + "/", Encoding.UTF8).Result;
+ if (doc == null)
+ {
+ MessageBox.Show("获取章节列表异常");
+ return new List();
+ }
+
+ conNodes = doc.DocumentNode.SelectNodes("//*[@id=\"list\"]");
+ if (conNodes == null || conNodes.Count == 0)
+ {
+ MessageBox.Show("获取章节列表异常");
+ return new List();
+ }
+
+ HtmlNodeCollection aNodes = conNodes[0].SelectNodes(".//a");
+ if (aNodes == null || aNodes.Count == 0)
+ {
+ MessageBox.Show("获取章节列表异常");
+ return new List();
+ }
+
+ bool isStarted = false;
+ List chapterList = new List();
+ for (int c = 0; c < aNodes.Count; c++)
+ {
+ // 第1章 洪战
+ HtmlNode aNode = aNodes[c];
+ if (aNode == null)
+ {
+ continue;
+ }
+
+ ChapterPaozwClass chapterClass = new ChapterPaozwClass(aNode, isStarted);
+ if (!chapterClass.IsNull())
+ {
+ chapterList.Add(chapterClass);
+ if (!isStarted)
+ {
+ isStarted = true;
+ }
+ }
+ }
+
+ return chapterList;
+ }
+
+ public override void ToTxt(string filePath, string HOST)
+ {
+ //从url中加载
+ //第一页
+ HtmlAgilityPack.HtmlDocument doc = new HtmlWeb().LoadFromWebAsync(HOST + this.Url, Encoding.UTF8).Result;
+ if (doc == null)
+ {
+ return;
+ }
+
+ HtmlNodeCollection conNodes = doc.DocumentNode.SelectNodes("//article[@id=\"content\"]");
+ if (conNodes == null || conNodes.Count == 0)
+ {
+ return;
+ }
+
+ TxtUtil.Write(filePath,
+ " " + this.Label + "\n\n" +
+ conNodes[0].InnerHtml.Replace("", " ").Replace("
", "\n\n"));
+
+ //第二页
+ doc = new HtmlWeb().LoadFromWebAsync(HOST + this.Url.Replace(".html", "_2.html"), Encoding.UTF8).Result;
+ if (doc == null)
+ {
+ return;
+ }
+
+ conNodes = doc.DocumentNode.SelectNodes("//article[@id=\"content\"]");
+ if (conNodes == null || conNodes.Count == 0)
+ {
+ return;
+ }
+
+ TxtUtil.Write(filePath, conNodes[0].InnerHtml.Replace("", " ").Replace("
", "\n\n"));
+ }
+ }
+}
diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index de24ad8..2be8fc3 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -164,6 +164,7 @@ namespace HtmlToTxtWFA
"键盘小说网",
"乐文小说网",
"农夫小说网",
+ "泡泡中文",
"速读谷"});
this.platformComboBox.Location = new System.Drawing.Point(84, 7);
this.platformComboBox.Name = "platformComboBox";
diff --git a/MainForm.cs b/MainForm.cs
index 6046840..4cffbb7 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -19,6 +19,7 @@ namespace HtmlToTxtWFA
["键盘小说网"] = "http://www.janpn.info",
["乐文小说网"] = "https://www.xlewen.com/",
["农夫小说网"] = "https://www.nfxs.com",
+ ["泡泡中文"] = "https://www.paozw.com",
["速读谷"] = "https://www.sudugu.com",
};
@@ -125,6 +126,10 @@ namespace HtmlToTxtWFA
{
chapterList = new ChapterNfxsClass().ReadChapterList(host, serialNumber);
}
+ else if (platform.Equals("泡泡中文"))
+ {
+ chapterList = new ChapterPaozwClass().ReadChapterList(host, serialNumber);
+ }
else if (platform.Equals("速读谷"))
{
chapterList = new ChapterSuduguClass().ReadChapterList(host, serialNumber);
--
Gitee