From 8698bdd634c8847f9062eaecb918d691f8c19708 Mon Sep 17 00:00:00 2001
From: Fengshaoyuan <1914442689@qq.com>
Date: Thu, 23 May 2024 09:43:26 +0800
Subject: [PATCH] =?UTF-8?q?1.=E6=89=A9=E5=B1=95=205you8?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Classes/Chapter5you8Class.cs | 94 ++++++++++++++++++++++++++++++++++++
MainForm.Designer.cs | 1 +
MainForm.cs | 5 ++
3 files changed, 100 insertions(+)
create mode 100644 Classes/Chapter5you8Class.cs
diff --git a/Classes/Chapter5you8Class.cs b/Classes/Chapter5you8Class.cs
new file mode 100644
index 0000000..4cb7706
--- /dev/null
+++ b/Classes/Chapter5you8Class.cs
@@ -0,0 +1,94 @@
+using HtmlAgilityPack;
+using HtmlToTxtWFA.Utils;
+using System.Collections.Generic;
+using System.Text;
+
+namespace HtmlToTxtWFA.Classes
+{
+ ///
+ /// 章节 5you8
+ ///
+ public class Chapter5you8Class : ChapterClass
+ {
+ ///
+ /// 章节序号
+ ///
+ public string SerialNumber { get; set; }
+
+ public Chapter5you8Class() { }
+
+ public Chapter5you8Class(HtmlNode aElement, string serialNumber)
+ {
+ // 第一章梦
+ this.Label = aElement.InnerText;
+ this.Url = aElement.GetAttributeValue("href", "");
+ this.SerialNumber = serialNumber;
+ }
+
+ public override List ReadChapterList(string HOST, string serialNumber)
+ {
+ // 从url中加载
+ // http://www.5you8.net/76/76262
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+ HtmlAgilityPack.HtmlDocument doc = new HtmlWeb().LoadFromWebAsync(HOST + "/" + serialNumber + "/", Encoding.GetEncoding("GBK")).Result;
+ if (doc == null)
+ {
+ return new List();
+ }
+
+ HtmlNodeCollection conNodes = doc.DocumentNode.SelectNodes("//div[@class=\"ml_list\"]");
+ if (conNodes == null || conNodes.Count == 0)
+ {
+ return new List();
+ }
+
+ HtmlNodeCollection aNodes = conNodes[0].SelectNodes(".//a");
+ if (aNodes == null || aNodes.Count == 0)
+ {
+ return new List();
+ }
+
+ List chapterList = new List();
+ for (int c = 0; c < aNodes.Count; c++)
+ {
+ // 第一章梦
+ HtmlNode aNode = aNodes[c];
+ if (aNode == null)
+ {
+ continue;
+ }
+
+ Chapter5you8Class chapterClass = new Chapter5you8Class(aNode, serialNumber);
+ if (!chapterClass.IsNull())
+ {
+ chapterList.Add(chapterClass);
+ }
+ }
+
+ return chapterList;
+ }
+
+ public override void ToTxt(string filePath, string HOST)
+ {
+ // 从url中加载
+ // http://www.5you8.net/76/76262/33670603.html
+ Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
+ HtmlAgilityPack.HtmlDocument doc = new HtmlWeb().LoadFromWebAsync(HOST + "/" + this.SerialNumber + "/" + this.Url, Encoding.GetEncoding("GBK")).Result;
+ if (doc == null)
+ {
+ return;
+ }
+
+ HtmlNodeCollection conNodes = doc.DocumentNode.SelectNodes("//p[@id='articlecontent']");
+ if (conNodes == null || conNodes.Count == 0)
+ {
+ return;
+ }
+
+ TxtUtil.Write(filePath, " " + this.Label + "\n\n"
+ + conNodes[0].InnerHtml.Replace(" ", " ").Replace("
", "")
+ + "\n\n"
+ );
+ }
+ }
+}
diff --git a/MainForm.Designer.cs b/MainForm.Designer.cs
index 04dd883..480c182 100644
--- a/MainForm.Designer.cs
+++ b/MainForm.Designer.cs
@@ -161,6 +161,7 @@ namespace HtmlToTxtWFA
"3Q读书网",
"3Q中文网",
"4020电子书下载",
+ "5笔趣阁",
"7小说",
"i笔趣阁",
"qiu笔趣阁",
diff --git a/MainForm.cs b/MainForm.cs
index 3d868ea..13991a1 100644
--- a/MainForm.cs
+++ b/MainForm.cs
@@ -16,6 +16,7 @@ namespace HtmlToTxtWFA
["3Q读书网"] = "https://sk.3qdu.com",
["3Q中文网"] = "https://sk.3qxsw.org",
["4020电子书下载"] = "https://www.iwurexs.net",
+ ["5笔趣阁"] = "http://www.5you8.net",
["7小说"] = "https://www.7qs.org",
["i笔趣阁"] = "http://www.ibiquge.cc",
["qiu笔趣阁"] = "https://www.qiubiquge.com",
@@ -120,6 +121,10 @@ namespace HtmlToTxtWFA
{
chapterList = new ChapterIwurexsClass().ReadChapterList(host, serialNumber);
}
+ else if (platform.Equals("5笔趣阁"))
+ {
+ chapterList = new Chapter5you8Class().ReadChapterList(host, serialNumber);
+ }
else if (platform.Equals("7小说"))
{
chapterList = new Chapter7qsClass().ReadChapterList(host, serialNumber);
--
Gitee