public async Task <MoeItems> GetRealPageImagesAsyncFromXml(SearchPara para, CancellationToken token) { var client = new NetOperator(Settings).Client; var query = GetPageQuery(para); var xmlRes = await client.GetAsync(query, token); var xmlStr = await xmlRes.Content.ReadAsStreamAsync(); var xml = XDocument.Load(xmlStr); var imageItems = new MoeItems(); if (xml.Root == null) { return(imageItems); } foreach (var post in xml.Root.Elements()) { token.ThrowIfCancellationRequested(); var img = new MoeItem(this, para); var tags = post.Attribute("tags")?.Value ?? ""; foreach (var tag in tags.Split(' ')) { if (!tag.IsEmpty()) { img.Tags.Add(tag.Trim()); } } img.Id = post.Attribute("id")?.Value.ToInt() ?? 0; img.Width = post.Attribute("width")?.Value.ToInt() ?? 0; img.Height = post.Attribute("height")?.Value.ToInt() ?? 0; img.Uploader = post.Attribute("author")?.Value; img.Source = post.Attribute("source")?.Value; img.IsExplicit = post.Attribute("rating")?.Value.ToLower() != "s"; img.DetailUrl = GetDetailPageUrl(img); img.Date = post.Attribute("created_at")?.Value.ToDateTime(); if (img.Date == null) { img.DateString = post.Attribute("created_at")?.Value; } img.Score = post.Attribute("score")?.Value.ToInt() ?? 0; img.Urls.Add(1, $"{UrlPre}{post.Attribute("preview_url")?.Value}", GetThumbnailReferer(img)); img.Urls.Add(2, $"{UrlPre}{post.Attribute("sample_url")?.Value}", GetThumbnailReferer(img)); img.Urls.Add(3, $"{UrlPre}{post.Attribute("jpeg_url")?.Value}", GetThumbnailReferer(img)); img.Urls.Add(4, $"{UrlPre}{post.Attribute("file_url")?.Value}", img.DetailUrl); img.OriginString = $"{post}"; if (GetDetailTaskFunc != null) { img.GetDetailTaskFunc = async() => await GetDetailTaskFunc(img, para, token); } imageItems.Add(img); } var count = xml.Root.Attribute("count")?.Value.ToInt(); var offset = xml.Root.Attribute("offset")?.Value.ToInt(); Extend.ShowMessage($"共搜索到{count}张图片,当前第{offset+1}张,第{para.PageIndex}页,共{count / para.Count}页", null, Extend.MessagePos.InfoBar); return(imageItems); }