// 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; }
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; }
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; }