From 67cc9c1dfcbe6e35ca90276e95a0924c2a92c983 Mon Sep 17 00:00:00 2001 From: fffonion Date: Mon, 30 Oct 2023 23:31:55 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=99=BB=E5=BD=95=E4=BF=A1?= =?UTF-8?q?=E6=81=AF=E8=A7=A3=E6=9E=90=EF=BC=8C=E5=9C=A8=E8=A7=A3=E6=9E=90?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E6=97=B6=E7=94=9F=E6=88=90=E8=B0=83=E8=AF=95?= =?UTF-8?q?=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Novel.cs | 40 +++++++++++++++++++++++++++++++++++--- Properties/AssemblyInfo.cs | 4 ++-- frmMain.cs | 4 +++- jjget.csproj | 1 + 4 files changed, 43 insertions(+), 6 deletions(-) diff --git a/Novel.cs b/Novel.cs index 3a1743a..66d3db4 100644 --- a/Novel.cs +++ b/Novel.cs @@ -7,6 +7,7 @@ using HtmlAgilityPack; using System.Text.RegularExpressions; using Newtonsoft.Json.Linq; +using System.IO.Compression; namespace jjget { @@ -28,6 +29,7 @@ class Novel private string cookiestr; public string userDetail; public bool hasLogin = false; + private string lastParsedHTML; private WebProxy proxy = null; private Action setProgressDelegate; private Action setVerifyCodeDelegate; @@ -269,14 +271,15 @@ private void getUserDetail() HtmlNode root = hd.DocumentNode; HtmlNode tb = root.SelectSingleNode("//table[@bgcolor='#009900']"); bool isWriter = false; - var detailTr = tb.SelectSingleNode("./tr[1]//font[@class='readerid']"); + var detailTr = tb.SelectSingleNode(".//tr//font[@class='readerid']"); if (detailTr == null) { detailTr = tb.SelectSingleNode("./tr[1]//div[1]"); isWriter = true; } - userDetail = "已登录 ID: " + detailTr.InnerText.Trim(); - string _nick = tb.SelectSingleNode("./tr[" + (isWriter? "3" : "2") + "]/td[2]/div").InnerText; + userDetail = "已登录 ID: " + (detailTr != null ? detailTr.InnerText.Trim(): "未知ID"); + var _nickInput = tb.SelectSingleNode("//input[@name='birthday']"); + string _nick = _nickInput == null ? _nickInput.GetAttributeValue("value", "未知昵称") : "未知昵称"; if (_nick != "您还没有设置昵称") userDetail += " " + _nick; // disable email for now @@ -413,6 +416,7 @@ public Chapter getSingleChapter(int chapter) //StreamReader sFile = new StreamReader(fs); //string html = sFile.ReadToEnd(); //setPrompt("分析中……", Color.Orange); + lastParsedHTML = html; HtmlAgilityPack.HtmlDocument hd = new HtmlAgilityPack.HtmlDocument(); hd.LoadHtml(html); HtmlNodeCollection hnc; @@ -472,6 +476,7 @@ public Chapter getSingleChapter(int chapter) { context[key] = getInputLabelValue(root, key); } + // jsid 就是用户ID Regex jsidRegex = new Regex(@"//my\.jjwxc\.net/backend/favorite\.php\?jsid=(\d+)"); var match = jsidRegex.Match(root.InnerHtml); if(!match.Success) @@ -634,5 +639,34 @@ public FontDecoder getFontDecoder() { return fontDecoder; } + + public void writeDebugInfo(string path) + { + using (var memoryStream = new MemoryStream()) + { + using (var archive = new ZipArchive(memoryStream, ZipArchiveMode.Create, true)) + { + using (var entryStream = archive.CreateEntry("singlePage.html").Open()) + using (var streamWriter = new StreamWriter(entryStream)) + { + streamWriter.Write(lastParsedHTML); + } + + using (var entryStream = archive.CreateEntry("config.txt").Open()) + using (var streamWriter = new StreamWriter(entryStream)) + { + streamWriter.WriteLine("novelid: " + novelid); + streamWriter.WriteLine("useMobileEdition: " + useMobileEdition); + streamWriter.WriteLine("hasLogin: " + hasLogin); + } + } + + using (var fileStream = new FileStream(path, FileMode.Create)) + { + memoryStream.Seek(0, SeekOrigin.Begin); + memoryStream.CopyTo(fileStream); + } + } + } } } diff --git a/Properties/AssemblyInfo.cs b/Properties/AssemblyInfo.cs index df7e8d1..2e2f17c 100644 --- a/Properties/AssemblyInfo.cs +++ b/Properties/AssemblyInfo.cs @@ -32,5 +32,5 @@ // 可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值, // 方法是按如下所示使用“*”: // [assembly: AssemblyVersion("1.0.*")] -[assembly: AssemblyVersion("1.4.4")] -[assembly: AssemblyFileVersion("1.4.4")] +[assembly: AssemblyVersion("1.4.5")] +[assembly: AssemblyFileVersion("1.4.5")] diff --git a/frmMain.cs b/frmMain.cs index 45200e4..58fbdf1 100644 --- a/frmMain.cs +++ b/frmMain.cs @@ -246,12 +246,14 @@ private void button1_Click(object sender, EventArgs e) break; } } + if (terminate) { this.Invoke(new Action(() => { btnStart.Text = "开始"; - setPrompt(("已中断下载"), Color.Red); + novel.writeDebugInfo("jjdebug.zip"); + setPrompt(("调试信息已经保存到jjdebug.zip,虽然其中不包含登录数据,但请勿公开分享"), Color.Red); })); return; } diff --git a/jjget.csproj b/jjget.csproj index 65d2f22..46d4e63 100644 --- a/jjget.csproj +++ b/jjget.csproj @@ -73,6 +73,7 @@ +