feat: 完成yi.tool.web爬虫
This commit is contained in:
@@ -0,0 +1,25 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Volo.Abp.Application.Services;
|
||||||
|
using Yi.Abp.Tool.Domain;
|
||||||
|
|
||||||
|
namespace Yi.Abp.Tool.Application
|
||||||
|
{
|
||||||
|
public class NueGetInfoService : ApplicationService
|
||||||
|
{
|
||||||
|
private NugetCrawlerManager _nugetCrawlerManager;
|
||||||
|
public NueGetInfoService(NugetCrawlerManager nugetCrawlerManager) { _nugetCrawlerManager = nugetCrawlerManager; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取爬虫结果
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
public NugetResult GetInfo()
|
||||||
|
{
|
||||||
|
return _nugetCrawlerManager.GetNugetResult();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
85
Yi.Abp.Net8/tool/Yi.Abp.Tool.Domain/NugetCrawlerManager.cs
Normal file
85
Yi.Abp.Net8/tool/Yi.Abp.Tool.Domain/NugetCrawlerManager.cs
Normal file
@@ -0,0 +1,85 @@
|
|||||||
|
using HtmlAgilityPack;
|
||||||
|
using Microsoft.Extensions.Caching.Distributed;
|
||||||
|
using Volo.Abp.Caching;
|
||||||
|
using Volo.Abp.DependencyInjection;
|
||||||
|
|
||||||
|
namespace Yi.Abp.Tool.Domain
|
||||||
|
{
|
||||||
|
public class NugetCrawlerManager : ITransientDependency
|
||||||
|
{
|
||||||
|
private const string NugetVersionUrl = "https://www.nuget.org/packages/Yi.Abp.Tool#versions-body-tab";
|
||||||
|
public NugetCrawlerManager(IDistributedCache<NugetResult> cache)
|
||||||
|
{
|
||||||
|
//缓存设置1分钟获取一次结果
|
||||||
|
this.NugetResult = cache.GetOrAdd("NugetResult", () =>
|
||||||
|
{
|
||||||
|
return InitData();
|
||||||
|
}, () =>
|
||||||
|
{
|
||||||
|
var options = new DistributedCacheEntryOptions();
|
||||||
|
options.AbsoluteExpiration = DateTimeOffset.Now.AddMinutes(1);
|
||||||
|
return options;
|
||||||
|
})!;
|
||||||
|
|
||||||
|
}
|
||||||
|
private HtmlDocument HtmlDoc { get; set; }
|
||||||
|
private NugetResult NugetResult { get; set; } = new NugetResult();
|
||||||
|
|
||||||
|
private NugetResult InitData()
|
||||||
|
{
|
||||||
|
NugetResult nugetResult = new NugetResult();
|
||||||
|
|
||||||
|
HtmlWeb web = new HtmlWeb();
|
||||||
|
this.HtmlDoc = web.Load(NugetVersionUrl);
|
||||||
|
nugetResult.Versions = GetVersionList();
|
||||||
|
nugetResult.DownloadNumberNumber = GetDownloadNumber();
|
||||||
|
|
||||||
|
return nugetResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public NugetResult GetNugetResult()
|
||||||
|
{
|
||||||
|
return this.NugetResult;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取版本号列表
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private List<string> GetVersionList()
|
||||||
|
{
|
||||||
|
List<string> versions = new List<string>();
|
||||||
|
|
||||||
|
var versionDoc = HtmlDoc.DocumentNode.SelectNodes("//*[@id=\"version-history\"]/table/tbody");
|
||||||
|
var trDoc = versionDoc.First().ChildNodes.Where(x => x.Name == "tr").ToList();
|
||||||
|
|
||||||
|
foreach (var tr in trDoc)
|
||||||
|
{
|
||||||
|
var version = tr.ChildNodes.Where(x => x.Name == "td").First().ChildNodes.Where(x => x.Name == "a").First().GetAttributes("title").First().Value;
|
||||||
|
|
||||||
|
versions.Add(version);
|
||||||
|
|
||||||
|
}
|
||||||
|
return versions;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 获取下载总数
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
private long GetDownloadNumber()
|
||||||
|
{
|
||||||
|
var spanDoc = HtmlDoc.DocumentNode.SelectNodes("//*[@id=\"skippedToContent\"]/section/div/aside/div[1]/div[2]/div[1]/span[2]");
|
||||||
|
var downLoadNumber = spanDoc.First().InnerText;
|
||||||
|
return long.Parse(downLoadNumber);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public class NugetResult
|
||||||
|
{
|
||||||
|
public long DownloadNumberNumber { get; set; }
|
||||||
|
public List<string> Versions { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -5,8 +5,13 @@
|
|||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
<ItemGroup>
|
||||||
|
<PackageReference Include="HtmlAgilityPack" Version="1.11.61" />
|
||||||
|
<PackageReference Include="Volo.Abp.Caching" Version="$(AbpVersion)" />
|
||||||
|
</ItemGroup>
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<ProjectReference Include="..\Yi.Abp.Tool.Domain.Shared\Yi.Abp.Tool.Domain.Shared.csproj" />
|
<ProjectReference Include="..\Yi.Abp.Tool.Domain.Shared\Yi.Abp.Tool.Domain.Shared.csproj" />
|
||||||
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
@@ -1,9 +1,11 @@
|
|||||||
using Yi.Abp.Tool.Web;
|
using Yi.Abp.Tool.Web;
|
||||||
|
|
||||||
|
|
||||||
var builder = WebApplication.CreateBuilder(args);
|
var builder = WebApplication.CreateBuilder(args);
|
||||||
builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]);
|
builder.WebHost.UseUrls(builder.Configuration["App:SelfUrl"]);
|
||||||
builder.Host.UseAutofac();
|
builder.Host.UseAutofac();
|
||||||
await builder.Services.AddApplicationAsync<YiAbpToolWebModule>();
|
await builder.Services.AddApplicationAsync<YiAbpToolWebModule>();
|
||||||
var app = builder.Build();
|
var app = builder.Build();
|
||||||
|
|
||||||
await app.InitializeApplicationAsync();
|
await app.InitializeApplicationAsync();
|
||||||
await app.RunAsync();
|
await app.RunAsync();
|
||||||
@@ -13,7 +13,13 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
public Task InvokerAsync(Dictionary<string, string> options, string[] args)
|
public Task InvokerAsync(Dictionary<string, string> options, string[] args)
|
||||||
{
|
{
|
||||||
List<string> delDirBlacklist = ["obj", "bin"];
|
List<string> delDirBlacklist = ["obj", "bin"];
|
||||||
DeleteObjBinFolders("./", delDirBlacklist);
|
options.TryGetValue("path", out var path);
|
||||||
|
|
||||||
|
if (string.IsNullOrEmpty(path))
|
||||||
|
{
|
||||||
|
path = "./";
|
||||||
|
}
|
||||||
|
DeleteObjBinFolders(path, delDirBlacklist);
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -24,7 +30,7 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
{
|
{
|
||||||
foreach (string subDir in Directory.GetDirectories(directory))
|
foreach (string subDir in Directory.GetDirectories(directory))
|
||||||
{
|
{
|
||||||
if (delDirBlacklist.Contains(subDir))
|
if (delDirBlacklist.Contains(Path.GetFileName( subDir)))
|
||||||
{
|
{
|
||||||
Directory.Delete(subDir, true);
|
Directory.Delete(subDir, true);
|
||||||
Console.WriteLine($"已删除文件夹:{subDir}");
|
Console.WriteLine($"已删除文件夹:{subDir}");
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ namespace Yi.Abp.Tool.Commands
|
|||||||
> new: 创建模块模板` yi-abp new <name> -t module -csf `
|
> new: 创建模块模板` yi-abp new <name> -t module -csf `
|
||||||
> new: 创建项目模板` yi-abp new <name> -csf `
|
> new: 创建项目模板` yi-abp new <name> -csf `
|
||||||
> add-module: 将内容添加到当前解决方案` yi-abp add-module <moduleName> [-modulePath <path>] [-s <slnPath>] `
|
> add-module: 将内容添加到当前解决方案` yi-abp add-module <moduleName> [-modulePath <path>] [-s <slnPath>] `
|
||||||
|
> clear: 清除当前目录及子目录下的obj、bin文件夹` yi-abp clear `
|
||||||
|
|
||||||
""");
|
""");
|
||||||
return Task.CompletedTask;
|
return Task.CompletedTask;
|
||||||
|
|||||||
@@ -16,7 +16,8 @@ class Program
|
|||||||
//args = ["12312"];
|
//args = ["12312"];
|
||||||
//args = ["new", "Acme.Book", "-t", "module", "-csf"];
|
//args = ["new", "Acme.Book", "-t", "module", "-csf"];
|
||||||
//args = ["new", "Acme.Book", "-t", "module"];
|
//args = ["new", "Acme.Book", "-t", "module"];
|
||||||
args = ["add-module", "Acme.Demo", "-s", "D:\\code\\csharp\\source\\Yi\\Yi.Abp.Net8", "-modulePath", "D:\\code\\csharp\\source\\Yi\\Yi.Abp.Net8\\module\\acme-demo"];
|
//args = ["add-module", "Acme.Demo", "-s", "D:\\code\\csharp\\source\\Yi\\Yi.Abp.Net8", "-modulePath", "D:\\code\\csharp\\source\\Yi\\Yi.Abp.Net8\\module\\acme-demo"];
|
||||||
|
args = ["clear", "-path", "D:\\code\\csharp\\source\\Yi\\Yi.Abp.Net8\\src"];
|
||||||
#endif
|
#endif
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<TargetFramework>net8.0</TargetFramework>
|
<TargetFramework>net8.0</TargetFramework>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<Version>0.8.0</Version>
|
<Version>1.0.0</Version>
|
||||||
<Authors>橙子老哥</Authors>
|
<Authors>橙子老哥</Authors>
|
||||||
<Description>yi-framework框架配套工具</Description>
|
<Description>yi-framework框架配套工具</Description>
|
||||||
<PackageProjectUrl>https://ccnetcore.com</PackageProjectUrl>
|
<PackageProjectUrl>https://ccnetcore.com</PackageProjectUrl>
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ const hanldeReadClick=async ()=>{
|
|||||||
}
|
}
|
||||||
|
|
||||||
const enterStart=()=>{
|
const enterStart=()=>{
|
||||||
alert("即将发布Yi.Abp.Tool,官方脚手架工具集,敬请期待!")
|
router.push("/start");
|
||||||
}
|
}
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|||||||
@@ -203,11 +203,10 @@ const getLastMessage = ((receiveId, isAll) => {
|
|||||||
|
|
||||||
<template>
|
<template>
|
||||||
<div style="position: absolute; top: 0;left: 0;">
|
<div style="position: absolute; top: 0;left: 0;">
|
||||||
<p>当前版本:1.1.0</p>
|
<p>当前版本:1.2.0</p>
|
||||||
<p>tip:官方学习交流群每次发送消息消耗 1 钱钱</p>
|
<p>tip:官方学习交流群每次发送消息消耗 1 钱钱</p>
|
||||||
<p>tip:点击聊天窗口右上角“X”可退出</p>
|
<p>tip:点击聊天窗口右上角“X”可退出</p>
|
||||||
<p>1.0.0:上线框架基础功能</p>
|
<p>tip:多人同时在聊天室时,左侧可显示其他成员</p>
|
||||||
<p>1.1.0:结合用户领域信息</p>
|
|
||||||
</div>
|
</div>
|
||||||
<div class="body">
|
<div class="body">
|
||||||
|
|
||||||
|
|||||||
@@ -86,7 +86,10 @@ onUnmounted(() => {
|
|||||||
<div class="start-body">
|
<div class="start-body">
|
||||||
|
|
||||||
<div class="content">
|
<div class="content">
|
||||||
<div class="content-title"><span>开始</span></div>
|
<div class="content-title"><span>开始</span>
|
||||||
|
|
||||||
|
<div class="version">Yi.Abp.Tool工具集,最新版本号 </div>
|
||||||
|
</div>
|
||||||
<div class="content-body">
|
<div class="content-body">
|
||||||
<div class="content-body-left">
|
<div class="content-body-left">
|
||||||
<h4>安装 Yi.Abp.Tool</h4>
|
<h4>安装 Yi.Abp.Tool</h4>
|
||||||
@@ -106,7 +109,7 @@ onUnmounted(() => {
|
|||||||
<h4>将你创建的模块添加到当前解决方案中</h4>
|
<h4>将你创建的模块添加到当前解决方案中</h4>
|
||||||
<p>在module文件夹内,命令行终端运行以下命令:</p>
|
<p>在module文件夹内,命令行终端运行以下命令:</p>
|
||||||
<CodeBox v-model="addModuleComputed" />
|
<CodeBox v-model="addModuleComputed" />
|
||||||
|
<p>模块创建后,可选择任意host主机进行模块依赖即可</p>
|
||||||
|
|
||||||
<h4>配置</h4>
|
<h4>配置</h4>
|
||||||
<p>您可以更改下面的解决方案配置。</p>
|
<p>您可以更改下面的解决方案配置。</p>
|
||||||
@@ -163,6 +166,13 @@ onUnmounted(() => {
|
|||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
|
||||||
|
.version{
|
||||||
|
height: 100%;
|
||||||
|
display: flex;
|
||||||
|
align-items: flex-end;
|
||||||
|
padding: 30px 10px;
|
||||||
|
color: darkgrey;
|
||||||
|
}
|
||||||
span {
|
span {
|
||||||
color: #292d33;
|
color: #292d33;
|
||||||
font-size: 48px;
|
font-size: 48px;
|
||||||
|
|||||||
Reference in New Issue
Block a user