Example #1
0
        public override Queue <BasicComicInfo> GetTopComic(string response)
        {
            Queue <BasicComicInfo> comicQueue;
            BasicComicInfo         basic;

            comicQueue = new Queue <BasicComicInfo>();
            response   = AnalyseTool.GetTag(response, @"<div class=""cmt-cont cf""", "</div>");
            var             pattern      = @"href=""(?<href>[/\w]*)""\s*title=""(?<title>[\w\s;!♀♂&【】&]*)""><img\s*(src|data-src)=""(?<url>[:\w/.]*)""";
            Regex           regex        = new Regex(pattern);
            MatchCollection matchCollect = regex.Matches(response);

            var count = 0;

            foreach (Match i in matchCollect)
            {
                basic             = new BasicComicInfo();
                basic.ComicName   = i.Groups["title"].Value;
                basic.ComicImgUrl = i.Groups["url"].Value;
                basic.ComicHref   = host + i.Groups["href"].Value;
                comicQueue.Enqueue(basic);
                count++;
            }

            return(comicQueue);
        }
Example #2
0
        public override CategoryCollect FindComicByCategory(string cateGoryStr)//通过漫画分类获取漫画
        {
            var basicInfo    = new BasicComicInfo();
            var comicCollect = new CategoryCollect();
            var bookList     = AnalyseTool.GetTag(cateGoryStr, @"<div class=""book-list"">", "</div>");

            comicCollect.Count = 0;

            Regex regex      = new Regex(@"href=""(?<href>[/\w]*)""\stitle=""(?<title>[\w\&!!,s]*)""><img\s*(data-src|src)=""(?<url>[:\w./]*)""");
            var   comicQueue = new Queue <BasicComicInfo>();

            foreach (Match i in regex.Matches(bookList))
            {
                basicInfo             = new BasicComicInfo();
                basicInfo.ComicHref   = host + i.Groups["href"].Value;
                basicInfo.ComicName   = i.Groups["title"].Value;
                basicInfo.ComicImgUrl = i.Groups["url"].Value;
                comicQueue.Enqueue(basicInfo);
            }


            var pageInfo = AnalyseTool.GetTag(cateGoryStr, @"<div class=""pager-cont"">", "</div>");

            regex = new Regex(@"href=""(?<href>[/\w._]*)""\s*\w+=""[\w-:;]*"">下一页");
            comicCollect.NextPageUrl = homePage + regex.Match(cateGoryStr).Groups["href"].Value;
            comicCollect.Count       = comicQueue.Count;
            comicCollect.ComicQueue  = comicQueue;
            return(comicCollect);
        }
Example #3
0
        public override ComicInfo GetComicInfo(string response)
        {
            string subMsg = "";
            ComicInfo comicInfo = new ComicInfo();
            Dictionary<string,string> comicDic;
            Regex regex;
            HtmlDocument doc = new HtmlDocument();
            doc.LoadHtml(response);

            comicDic = new Dictionary<string,string>();
            regex = new Regex(@"src='(?<imgurl>[\w:/.]*)'");

            HtmlNodeCollection nodeCollection = doc.DocumentNode.SelectNodes("//a[@class='l_s']");
            
            foreach (HtmlNode node in nodeCollection)
            {
                if (comicDic.ContainsKey(node.Attributes["title"].Value) == false)
                {
                    comicDic.Add(node.Attributes["title"].Value, hostAttach + node.Attributes["href"].Value);
                }
            }

            HtmlNode currentNode = doc.DocumentNode.SelectSingleNode("//div[@id='about_kit']");
            nodeCollection = currentNode.SelectNodes("./ul/li");
            
            subMsg = AnalyseTool.GetTag(response, @"<div id=""about_style"">","</div>");
            comicInfo.CoverImgUrl = regex.Match(subMsg).Groups["imgurl"].Value;
            comicInfo.otherWork = "";
            comicInfo.Author = nodeCollection[1].InnerText.Trim().Replace("作者:","");
            comicInfo.HasFinished = nodeCollection[2].InnerText.Trim().Replace("状态:","");
            comicInfo.Description = nodeCollection[nodeCollection.Count - 1].InnerText.Trim().Replace("简介:","");
            comicInfo.URLDictionary = comicDic;
            return comicInfo;
        }
Example #4
0
        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);
        }
Example #5
0
        public override CategoryCollect FindComicByCategory(string cateGoryStr)
        {
            CategoryCollect cateCollect = new CategoryCollect();
            var             dat         = AnalyseTool.GetTag(cateGoryStr, @"<div class=""cComicList""", @"<div class=""cComicPageChange2");
            Regex           regex       = new Regex(@"href=['""](?<href>[/\w-]*)['""]\s*class=['""][\w_]*['""]\stitle=['""](?<title>[\w-!!\s,。]*)['""]><img\salt=['""][\w-!,。\s,]*['""]\s*src=['""](?<url>[\w:/.-]*)");
            var             basicInfo   = new BasicComicInfo();
            var             comicQueue  = new Queue <BasicComicInfo>();

            foreach (Match i in regex.Matches(dat))
            {
                basicInfo             = new BasicComicInfo();
                basicInfo.ComicHref   = hostName + i.Groups["href"].Value;
                basicInfo.ComicName   = i.Groups["title"].Value;
                basicInfo.ComicImgUrl = i.Groups["url"].Value;
                comicQueue.Enqueue(basicInfo);
            }

            dat   = AnalyseTool.GetTag(cateGoryStr, "<span class='cPageChangeLink'>", "</span>");
            regex = new Regex(@"<a\s*href='(?<url>[\w-/]*)'>下一页");
            cateCollect.NextPageUrl     = hostName + regex.Match(dat).Groups["url"].Value;
            cateCollect.ComicQueue      = comicQueue;
            cateCollect.PagesCollection = new Dictionary <string, string>();
            return(cateCollect);
        }