Skip to content

Commit

Permalink
v1.0.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
lvtx committed Sep 7, 2023
1 parent 0a868a2 commit 93f0250
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 63 deletions.
3 changes: 3 additions & 0 deletions ReadMe.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ C# WinRAR 简体中文-商业版 提取器

#### 更新日志

2023-09-07 发布v1.0.0.5
1. 因中文官网不公开最新版本信息,此版本直接使用原英文官网(www.win-rar.com)作为替代。

2023-06-30 发布v1.0.0.4
1. 增加版本日期递减枚举检测功能,以应付6.22版本生成日期与下载日期不同步问题。
(直接检测文件是否能正常下载,缺点是启动会稍微慢一点)
Expand Down
29 changes: 17 additions & 12 deletions WinRAR-Extractor/HttpWebHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,25 @@ public static class HttpWebHelper
/// <param name="userAgent">请求的客户端浏览器信息,可以为空</param>
/// <param name="cookies">随同HTTP请求发送的Cookie信息,如果不需要身份验证可以为空</param>
/// <returns></returns>
public static string GetHttpWebData(string url, int? timeout, string userAgent, bool lastModified = false)
public static string GetHttpWebData(string url, int? timeout, string userAgent = null, bool lastModified = false)
{
lock (_lotGetLocker)
{
//如果是发送HTTPS请求
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
// 请求前设置一下使用的安全协议类型
ServicePointManager.DefaultConnectionLimit = 512;
ServicePointManager.Expect100Continue = true;
ServicePointManager.CheckCertificateRevocationList = false;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3
| (SecurityProtocolType)12288 // SecurityProtocolType.Tls13
| SecurityProtocolType.Tls12
| SecurityProtocolType.Tls11
| SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
}

HttpWebRequest request = WebRequest.Create(url) as HttpWebRequest;
string WebData = string.Empty;
try
Expand All @@ -47,17 +62,7 @@ public static string GetHttpWebData(string url, int? timeout, string userAgent,
throw new ArgumentNullException("url");
}

//如果是发送HTTPS请求
if (url.StartsWith("https", StringComparison.OrdinalIgnoreCase))
{
// 请求前设置一下使用的安全协议类型
ServicePointManager.DefaultConnectionLimit = 512;
ServicePointManager.Expect100Continue = true;
ServicePointManager.CheckCertificateRevocationList = false;
ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3 | SecurityProtocolType.Tls12 | SecurityProtocolType.Tls11 | SecurityProtocolType.Tls;
ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult);
}

request.ProtocolVersion = HttpVersion.Version10;
request.Method = "GET";
request.UserAgent = DefaultUserAgent;
request.Accept = "text/html";
Expand Down
6 changes: 3 additions & 3 deletions WinRAR-Extractor/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("WinRAR-Extractor")]
[assembly: AssemblyCopyright("Copyright © 2021 - 2022")]
[assembly: AssemblyCopyright("Copyright © 2021 - 2023")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

Expand All @@ -32,5 +32,5 @@
//可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
// 方法是按如下所示使用“*”: :
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.0.0.4")]
[assembly: AssemblyFileVersion("1.0.0.4")]
[assembly: AssemblyVersion("1.0.0.5")]
[assembly: AssemblyFileVersion("1.0.0.5")]
67 changes: 19 additions & 48 deletions WinRAR-Extractor/frmExtractor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,93 +34,64 @@ private void frmExtractor_Load(object sender, EventArgs e)

private void btnRefresh_Click(object sender, EventArgs e)
{
string checkUrl = "https://www.winrar.com.cn/download.htm";
string html = HttpWebHelper.GetHttpWebData(checkUrl, 3000, null);
string checkUrl = "https://www.win-rar.com/download.html";
string html = HttpWebHelper.GetHttpWebData(checkUrl, 3000);
//Console.WriteLine(html);

int version = 0;
string freeUrl_x86 = string.Empty;
string freeUrl_x64 = string.Empty;

Match white14Link = Regex.Match(html,
"(?<=<a href=\")download-.+?(32|64)scp.html(?=\" target=\"_blank\" class=\"white14link\">(32|64)位下载</a>)",
RegexOptions.Multiline | RegexOptions.Singleline);
"(?<=<a href=\"https://www.win-rar.com/fileadmin/winrar-versions/winrar/)winrar-x(32|64)-[0-9]+sc.exe(?=\">WinRAR (.+?) Chinese Simplified (32|64) bit</a>)",
RegexOptions.Multiline | RegexOptions.Singleline);
//Console.WriteLine(white14Link.Groups.Count);

while (white14Link.Success)
{
//Console.WriteLine(white14Link.Value);
int result = 0, bit = 0;
Match versionLink = Regex.Match(white14Link.Value, "(?<=download-).+?(?=(32|64)scp.html)");
Match versionLink = Regex.Match(white14Link.Value, "(?<=winrar-x(32|64)-).+?(?=sc.exe)");
//Console.WriteLine(versionLink.Value);

if (int.TryParse(versionLink.Value, out result))
{
if (version <= result)
{
version = result;
Match bitLink = Regex.Match(white14Link.Value, $"(?<=download-{version}).+?(?=scp.html)");
Match bitLink = Regex.Match(white14Link.Value, $"(?<=winrar-x).+?(?=-{version}sc.exe)");
//Console.WriteLine(bitLink.Value);

string downloadUrl = $"https://www.winrar.com.cn/{white14Link.Value}";
//Console.WriteLine(downloadUrl);
string htmld = HttpWebHelper.GetHttpWebData(downloadUrl, 3000, null);
//Console.WriteLine(htmld);

Match downloadLink = Regex.Match(htmld, $"(?<=meta http-equiv=\"refresh\" content=\".+?;url=).*?(?=\")");
//Console.WriteLine(downloadLink.Value);

string downloadLink = white14Link.Value;
//Console.WriteLine(downloadLink);

if (int.TryParse(bitLink.Value, out bit) && bit != 64)
{
freeUrl_x86 = downloadLink.Value;
freeUrl_x86 = downloadLink;
}
else
{
freeUrl_x64 = downloadLink.Value;
freeUrl_x64 = downloadLink;
}
}
}
white14Link = white14Link.NextMatch();
}

Match lastSCname_x86 = Regex.Match(freeUrl_x86, "(?<=https://www.winrar.com.cn/download/).+?(?=scp.exe)");
string lastModified_x86 = HttpWebHelper.GetHttpWebData(freeUrl_x86, 3000, null, true);
string lastSCname_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/winrar/{freeUrl_x86}";
string lastModified_x86 = HttpWebHelper.GetHttpWebData(lastSCname_x86, 3000, null, true);
//Console.WriteLine(lastModified_x86);

Match lastSCname_x64 = Regex.Match(freeUrl_x64, "(?<=https://www.winrar.com.cn/download/).+?(?=scp.exe)");
string lastModified_x64 = HttpWebHelper.GetHttpWebData(freeUrl_x64, 3000, null, true);
string lastSCname_x64 = $"https://www.win-rar.com/fileadmin/winrar-versions/winrar/{freeUrl_x64}";
string lastModified_x64 = HttpWebHelper.GetHttpWebData(lastSCname_x64, 3000, null, true);
//Console.WriteLine(lastModified_x64);

int lmCheck = Convert.ToInt32(lastModified_x86);
while (lmCheck > 0)
{
if (!HttpWebHelper.GetHttpCheck($"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/rrlb/{lastSCname_x86.Value}sc.exe", 3000, null, true))
{
lmCheck--;
lastModified_x86 = lmCheck.ToString();
continue;
}
break;
}

lmCheck = Convert.ToInt32(lastModified_x64);
while (lmCheck > 0)
{
if (!HttpWebHelper.GetHttpCheck($"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/rrlb/{lastSCname_x64.Value}sc.exe", 3000, null, true))
{
lmCheck--;
lastModified_x64 = lmCheck.ToString();
continue;
}
break;
}

this.labVersion.Text = $"最新版本:[{version}],更新时间:[{lastModified_x86}]-[x86] / [{lastModified_x64}]-[x64] - [简体中文]";

string rrlb_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/rrlb/{lastSCname_x86.Value}sc.exe";
string rrlb_x64 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/rrlb/{lastSCname_x64.Value}sc.exe";
string wrr_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/wrr/{lastSCname_x86.Value}sc.exe";
string wrr_x64 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/wrr/{lastSCname_x64.Value}sc.exe";
string rrlb_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/rrlb/{freeUrl_x86}";
string rrlb_x64 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/rrlb/{freeUrl_x64}";
string wrr_x86 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x86}/wrr/{freeUrl_x86}";
string wrr_x64 = $"https://www.win-rar.com/fileadmin/winrar-versions/sc/sc{lastModified_x64}/wrr/{freeUrl_x64}";

this.tbrrlbx86.Text = rrlb_x86;
this.tbrrlbx64.Text = rrlb_x64;
Expand Down
Binary file modified WinRAR-Generate/WinRAR-Generate.rc
Binary file not shown.

0 comments on commit 93f0250

Please sign in to comment.