/// <summary> /// 使用分析器,执行对首页小说分类列表的提取过程,并返回分类名称及地址的字典集 /// </summary> public Dictionary <string, string> GetNovelTypes() { if (string.IsNullOrEmpty(Analyzer.NovelSiteIndexUrl)) { throw new NullIndexUrlException(); } if (string.IsNullOrEmpty(Analyzer.NovelTypePattern)) { throw new NullPatternException(); } var indexHtml = HttpHelper.DownloadSource(Analyzer.NovelSiteIndexUrl, Analyzer.Encode); return(Analyzer.GetNovelTypesDic(indexHtml)); }
/// <summary> /// 使用分析器,执行对指定小说分类页面的小说信息的提取过程,并返回小说名称及其地址的字典集 /// </summary> /// <param name="typeUrl"></param> /// <param name="pageIndex">页码</param> public Dictionary <string, string> GetNovelUrls(string typeUrl, int pageIndex) { if (string.IsNullOrEmpty(typeUrl)) { throw new ArgumentNullException(nameof(typeUrl)); } if (string.IsNullOrEmpty(Analyzer.NovelNamePattern)) { throw new NullPatternException(); } typeUrl = HttpHelper.RelateToAbsolute(Analyzer.NovelSiteIndexUrl, typeUrl); var url = Analyzer.BuildNovelTypePageUrl(typeUrl, pageIndex); var pageHtml = HttpHelper.DownloadSource(url, Analyzer.Encode); return(Analyzer.GetNovelInfosDic(pageHtml)); }
public int GetTotalPageCount(string referenceUrl) { referenceUrl = HttpHelper.RelateToAbsolute(Analyzer.NovelSiteIndexUrl, referenceUrl); var html = HttpHelper.DownloadSource(referenceUrl, Analyzer.Encode); // 获取最大页码 var pageTotalCount = 1; if (!string.IsNullOrEmpty(Analyzer.TotalPagePattern)) { pageTotalCount = Analyzer.GetTotalPage(html); if (pageTotalCount <= 0) { pageTotalCount = 1; } } return(pageTotalCount); }
public Novel GetNovelInfo(string referenceUrl) { var html = HttpHelper.DownloadSource(referenceUrl, Analyzer.Encode); var author = Analyzer.GetAuthor(html); var desc = Analyzer.GetDescription(html); var cover = Analyzer.GetNovelCoverPath(html); var chaptersUrl = Analyzer.GetChaptersUrl(html); chaptersUrl = HttpHelper.RelateToAbsolute(referenceUrl, chaptersUrl); return(new Novel { Author = new Author { Name = author }, Description = desc, CoverUrl = cover, ChapterListUrl = chaptersUrl }); }
public string GetChapterContent(string chapterUrl) { var html = HttpHelper.DownloadSource(chapterUrl, Analyzer.Encode); return(Analyzer.GetChapterContent(html)); }
public Dictionary <string, string> GetChapterUrls(string chapterListUrl) { var html = HttpHelper.DownloadSource(chapterListUrl, Analyzer.Encode); return(Analyzer.GetChaptersDic(html)); }