コード例 #1
0
        public override ComicInfo GetComicInfo(string response)
        {
            HtmlNode  node;
            ComicInfo comicInfo;

            comicInfo = new ComicInfo();
            HtmlDocument doc = new HtmlDocument();
            Dictionary <string, string> dict;

            doc.LoadHtml(response);
            dict = new Dictionary <string, string>();

            try
            {
                node = doc.DocumentNode.SelectSingleNode("//div[@class='sectioninfo allfloatleft gray']");
                HtmlNodeCollection collect = node.SelectNodes("./p");
                comicInfo.Author      = collect[1].SelectSingleNode("./span/a").InnerText;
                comicInfo.HasFinished = AnalyseTool.ReplacePunctuation(collect[2].SelectSingleNode("./span/a").InnerText);
                comicInfo.Tag         = collect[3].SelectSingleNode("./span/a").InnerText;
                node = doc.DocumentNode.SelectSingleNode("//div[@id='mhlist']");

                if (node == null)
                {
                    comicInfo.Description   = "因版权、国家法规等原因,动漫在线暂停提供此漫画的在线观看,欢迎大家继续观看其他精彩漫画,此漫画恢复情况请关注动漫在线";
                    comicInfo.URLDictionary = new Dictionary <string, string>();
                    return(comicInfo);
                }

                collect = node.SelectNodes("./ul/li/a");

                foreach (HtmlNode temp in collect)
                {
                    if (dict.ContainsKey(temp.Attributes["title"].Value) == false)
                    {
                        dict.Add(temp.Attributes["title"].Value, temp.Attributes["href"].Value);
                    }
                }

                node = doc.DocumentNode.SelectSingleNode("//div[@id='mh_smalltext']");
                comicInfo.Description   = node.InnerText;
                comicInfo.URLDictionary = dict;
            }
            catch (Exception ex)
            {
                comicInfo.Description   = "该漫画已下架";
                comicInfo.URLDictionary = new Dictionary <string, string>();
                return(comicInfo);
            }
            return(comicInfo);
        }
コード例 #2
0
ファイル: JingMingYan.cs プロジェクト: schyjxy/ComicDownLoad
        public override ComicInfo GetComicInfo(string response)
        {
            ComicInfo comicInfo = new ComicInfo();
            Dictionary <string, string> dict;

            dict = new Dictionary <string, string>();
            var comicStr  = AnalyseTool.GetTag(response, @"<div class=""cShuoMing"">", "</div>");
            var descrtion = AnalyseTool.GetTag(response, @"<div class=""cInfoArea"">", "</div>");

            descrtion = AnalyseTool.ReplacePunctuation(descrtion);
            Regex[] regex = new Regex[6];
            regex[0] = new Regex(@"""cInfoArea"">\s*(?<descr>[\w+“”,。!]*)");
            regex[1] = new Regex(@"<span\sclass=""cInfoLianWan"">(?<status>[\w\s]*)");             //连载状态
            regex[2] = new Regex(@"<a\starget=_blank\s*href='[?./\w=%]*'>(?<author>\w+)</a></td"); //作者及相关作品
            regex[3] = new Regex(@"<a\s*href='[/\w-]*'>(?<tag>\w+)</a>");                          //漫画标签
            regex[4] = new Regex(@"<a\s*target='_blank'\s*href='(?<href>[\w/]*)'>(?<title>[\w\s().]*)");
            regex[5] = new Regex(@"img\s*src='(?<url>[\w:/._]*)");

            comicInfo.Description = regex[0].Match(descrtion).Groups["descr"].Value;
            comicInfo.HasFinished = regex[1].Match(comicStr).Groups["status"].Value.Replace("\r\n", "").Replace(" ", "");
            comicInfo.Author      = regex[2].Match(comicStr).Groups["author"].Value;
            comicInfo.Tag         = regex[3].Match(comicStr).Groups["tag"].Value;
            comicInfo.Year        = "略";

            MatchCollection collect = regex[4].Matches(response);

            foreach (Match m in collect)
            {
                if (dict.ContainsKey(m.Groups["title"].Value) == false)
                {
                    dict.Add(m.Groups["title"].Value, hostName + m.Groups["href"].Value);
                }
            }

            comicInfo.URLDictionary = dict;
            comicInfo.CoverImgUrl   = regex[5].Match(response).Groups["url"].Value;
            return(comicInfo);
        }
コード例 #3
0
        public override ComicInfo GetComicInfo(string response)
        {
            HtmlDocument                doc;
            HtmlNodeCollection          tempCollect;
            ComicInfo                   info = new ComicInfo();
            Dictionary <string, string> dict;

            dict = new Dictionary <string, string>();
            doc  = new HtmlDocument();
            doc.LoadHtml(response);

            tempCollect      = doc.DocumentNode.SelectNodes("//dl[@class='mh-detail']/dd/p");
            info.Author      = tempCollect[0].SelectSingleNode("./a").InnerText;
            info.HasFinished = tempCollect[1].SelectSingleNode("./a").InnerText;

            tempCollect      = doc.DocumentNode.SelectNodes("//div[@class='mh-introduce']/p");
            info.Description = AnalyseTool.ReplacePunctuation(tempCollect[1].InnerText);

            tempCollect = doc.DocumentNode.SelectNodes("//ul[@class='b1']");

            foreach (HtmlNode temp in tempCollect)
            {
                HtmlNodeCollection collect = temp.SelectNodes("./li/a");

                foreach (HtmlNode node in collect)
                {
                    if (dict.ContainsKey(node.Attributes["title"].Value) == false)
                    {
                        dict.Add(node.Attributes["title"].Value, node.Attributes["href"].Value);
                    }
                }
            }

            info.URLDictionary = dict;
            return(info);
        }