正好有点时间,总共连带调试大概花了 15 分钟左右
欢迎来学习 C# ,正好 30 行,可以直接运行
后面有些地方用了些 linq 的奇技淫巧,可能不太容易懂,你可以试着转为自己比较熟悉的 foreach 代码
```
using AngleSharp.Dom;
using AngleSharp.Html.Parser;
using Flurl.Http;
using AngleSharp.Html.Dom;
var url = "
https://www.aisixiang.com";
var stream = await url.GetStreamAsync();
var htmlParser = new HtmlParser();
var htmlDocument = htmlParser.ParseDocument(stream);
var menus = htmlDocument.QuerySelectorAll("div.menu-box > ul > li > a").OfType<IHtmlAnchorElement>();
menus.Where(i => i.Text != "首页")
.ToList()
.ForEach(async i =>
{
var pageDocument = htmlParser.ParseDocument(await (url + i.PathName).GetStreamAsync());
var persons = pageDocument.QuerySelectorAll("div.ablum > ul > li > a").OfType<IHtmlAnchorElement>();
persons.Select(async j =>
{
var personDocument = htmlParser.ParseDocument(await (url + j.PathName).GetStreamAsync());
var vote = personDocument.QuerySelector(".dig_clia").Text();
int.TryParse(vote, out var voteCount);
var name = j.Text;
return (name, voteCount);
})
.Where(task => task.Result.voteCount > 100)
.ToList()
.ForEach(task => Console.WriteLine($"推荐值:{task.Result.voteCount},姓名{
task.Result.name}"));
});
Console.ReadLine();
```