当前位置: 首页>>代码示例>>C#>>正文


C# HtmlNode.FirstChildClass方法代码示例

本文整理汇总了C#中HtmlAgilityPack.HtmlNode.FirstChildClass方法的典型用法代码示例。如果您正苦于以下问题:C# HtmlNode.FirstChildClass方法的具体用法?C# HtmlNode.FirstChildClass怎么用?C# HtmlNode.FirstChildClass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在HtmlAgilityPack.HtmlNode的用法示例。


在下文中一共展示了HtmlNode.FirstChildClass方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ParseBookItem

        // a href = "/book/detail?id=*"
        private static BookItem ParseBookItem(HtmlNode a)
        {
            var book = new BookItem();
            book.HyperLinkUri = a.GetAttributeValue("href", null);
            book.CoverImageUri = a.Element("img")?.GetAttributeValue("src", null);
            book.Title = a.FirstChildClass("title")?.InnerText;

            if (book.Title == null)
                book.Title = CleanText(a.InnerText);

            book.Subtitle = a.FirstChildClass("status")?.InnerText;
            book.SeriesId = ParseIDFromBookLink(book.HyperLinkUri);
            return book;
        }
开发者ID:fuchu,项目名称:LightNovelClientWindows,代码行数:15,代码来源:LightKindomHtmlClient.cs

示例2: ParseVolumeSection

        static Volume ParseVolumeSection(HtmlNode section)
        {
            Volume volume = new Volume();
            volume.CoverImageUri = section.FirstChildClass("cover").Element("img").GetAttributeValue("src", string.Empty);
            volume.Title = WebUtility.HtmlDecode(section.FirstChildClass("info").InnerText);
            volume.Label = ExtractLabel(volume.Title);
            volume.Title = RemoveLabel(volume.Title);
            volume.Chapters = section.Element("ul").Elements("li").Select(li =>
            {
                var cpt = new ChapterProperties();
                var a = li.Element("a");
                var pos = ParseIDFromReadLink(a.GetAttributeValue("href", String.Empty));
                cpt.Id = pos.ChapterId;
                cpt.ParentVolumeId = pos.VolumeId;
                cpt.ParentSeriesId = pos.SeriesId;
                cpt.Title = a.InnerText;
                return cpt;
            }).ToList();

            if (volume.Chapters.Count > 0)
            {
                volume.Id = volume.Chapters[0].ParentVolumeId;
                volume.ParentSeriesId = volume.Chapters[0].ParentSeriesId;
            }

            for (int chapterIdx = 0; chapterIdx < volume.Chapters.Count; chapterIdx++)
            {
                var chapter = volume.Chapters[chapterIdx];
                chapter.ChapterNo = chapterIdx;
                //chapter.ParentVolumeId = vol.Id;
                chapter.ParentVolumeId = volume.Id;
                if (chapterIdx > 0)
                {
                    //chapter.PrevChapter = vol.Chapters[chapterIdx - 1];
                    chapter.PrevChapterId = volume.Chapters[chapterIdx - 1].Id;
                }
                if (chapterIdx < volume.Chapters.Count - 1)
                {
                    //chapter.NextChapter = vol.Chapters[chapterIdx + 1];
                    chapter.NextChapterId = volume.Chapters[chapterIdx + 1].Id;
                }
            }
            return volume;
        }
开发者ID:fuchu,项目名称:LightNovelClientWindows,代码行数:44,代码来源:LightKindomHtmlClient.cs

示例3: ParseSearchItem

 private static ExtendedBookItem ParseSearchItem(HtmlNode li)
 {
     ExtendedBookItem book = new ExtendedBookItem();
     try
     {
         var cover = li.FirstChildClass("cover");
         book.CoverImageUri = cover.Element("img").GetAttributeValue("src", null);
         book.SeriesId = ParseIDFromBookLink(cover.GetAttributeValue("href", null));
         var info = li.FirstChildClass("info");
         book.Title = CleanText(WebUtility.HtmlDecode(info.FirstChildClass("title").InnerText));
         var desc = info.FirstChildClass("desc");
         book.Author = desc.Descendants("a").First(node => node.HasClass("author")).InnerText;
         book.Illustrator = desc.Descendants("a").First(node => node.HasClass("artist")).InnerText;
         book.Publisher = desc.Descendants("a").First(node => node.HasClass("publisher")).InnerText;
         var intro = desc.FirstChildClass("intro");
         book.Description = ParseDescription(intro);
     }
     catch (Exception excp)
     {
         throw new Exception("Parsing Error in search result item : " + excp.Message, excp);
     }
     return book;
 }
开发者ID:fuchu,项目名称:LightNovelClientWindows,代码行数:23,代码来源:LightKindomHtmlClient.cs


注:本文中的HtmlAgilityPack.HtmlNode.FirstChildClass方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。