From a2e551164b6774deebb098fb2ad59976ec3f795f Mon Sep 17 00:00:00 2001 From: SDchao Date: Sat, 4 Apr 2020 12:09:48 +0800 Subject: [PATCH] =?UTF-8?q?=E6=8E=92=E9=99=A4=E6=B3=A8=E9=87=8Asign?= =?UTF-8?q?=E5=BD=B1=E5=93=8D=EF=BC=8C=E4=BF=AE=E5=A4=8D=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E8=A7=A3=E6=9E=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AutoVsCEnv_WPF/Operators/LanzouLinkResolutor.cs | 16 +++++++++++----- AutoVsCEnv_WPF/Operators/UpdateChecker.cs | 2 +- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/AutoVsCEnv_WPF/Operators/LanzouLinkResolutor.cs b/AutoVsCEnv_WPF/Operators/LanzouLinkResolutor.cs index 018ebb2..db51895 100644 --- a/AutoVsCEnv_WPF/Operators/LanzouLinkResolutor.cs +++ b/AutoVsCEnv_WPF/Operators/LanzouLinkResolutor.cs @@ -32,7 +32,7 @@ private static string SolveDownloadUrl(string downloadPageUrl) string data = ""; // 获取data值 - Regex dataRegex = new Regex("[^/][^/]data : (.*?,'sign':(.*?),.*?})"); + Regex dataRegex = new Regex("[^/]{2}data : (.*?,'sign':(.*?),.*?})"); Match dataMatch = dataRegex.Match(content); if (dataMatch.Success) @@ -41,13 +41,13 @@ private static string SolveDownloadUrl(string downloadPageUrl) sign = dataMatch.Groups[2].Value; //根据Sign获取Sign值 - Regex signRegex = new Regex("var " + sign + " *?= *?'(.*?)';"); + Regex signRegex = new Regex("[^/]{2}var " + sign + " *?= *?'(.*?)';"); Match signMatch = signRegex.Match(content); if(signMatch.Success) { signValue = signMatch.Groups[1].Value; - data = data.Replace(sign, "'" + signValue + "'"); + data = data.Replace("'sign':" + sign, "'sign':'" + signValue + "'"); } else { @@ -60,10 +60,16 @@ private static string SolveDownloadUrl(string downloadPageUrl) } //转化data为键值对 - data = Json2FormData(data); + try + { + data = Json2FormData(data); + } + catch (Exception) + { + throw new Exception("无法转化data为Json:\n" + data + "\n" + sign + ": " + signValue); + } data = Encoding.UTF8.GetString(Encoding.Default.GetBytes(data)); - string phpContent = PostAjax(data, downloadPageUrl); string finalUrl = ""; Regex domRegex = new Regex("\"dom\":\"(.*)\",\"url\""); diff --git a/AutoVsCEnv_WPF/Operators/UpdateChecker.cs b/AutoVsCEnv_WPF/Operators/UpdateChecker.cs index 6ba3d1b..aceb711 100644 --- a/AutoVsCEnv_WPF/Operators/UpdateChecker.cs +++ b/AutoVsCEnv_WPF/Operators/UpdateChecker.cs @@ -7,7 +7,7 @@ namespace AutoVsCEnv_WPF.Operators { internal class UpdateChecker { - private const string version = "1.94"; + private const string version = "1.95"; private const string checkPage = "https://gitee.com/SDchao/AutoVsCEnv_WPF/raw/master/AutoVsCEnv_WPF/Operators/UpdateChecker.cs"; public static bool HasUpdate()