예제 #1
0
        private string[] GetChapterPages(int ID)
        {
            var           Page  = GetChapterHtml(ID);
            List <string> Pages = new List <string>();

            var Scripts = Page.SelectNodes("//body//script[@type=\"text/javascript\"]");

            bool Found = false;

            foreach (var Node in Scripts)
            {
                if (!Node.InnerHtml.Contains("var images"))
                {
                    continue;
                }

                Found = true;

                string JS     = Node.InnerHtml.Substring("var images = ", "\"];") + "\"]";
                var    Result = (from x in JSTools.EvaluateScript <List <object> >(JS) select(string) x).ToArray();
                foreach (string PageHtml in Result)
                {
                    var PageUrl = PageHtml.Substring("src=", " ").Trim(' ', '\'', '"');
                    Pages.Add(PageUrl);
                }
            }

            if (!Found)
            {
                foreach (var Img in Page.SelectNodes("//section[@id='imageWrapper']//img"))
                {
                    Pages.Add(Img.GetAttributeValue("src", string.Empty));
                }
            }

            var Links = (from x in Pages select x.Replace(".webp", "").Replace("/images", "/mangas_files")).ToArray();

            if (Links.Where(x => string.IsNullOrEmpty(System.IO.Path.GetExtension(x))).Any())
            {
                return(Links.Select(x => x + ".webp").ToArray());
            }

            return(Links);
        }
예제 #2
0
        protected virtual void Extract()
        {
            try
            {
                Regex r = new Regex(ItemRegex, RegexOptions.Multiline);

                MatchCollection mc = r.Matches(PageHtml);

                if (mc.Count == 0)
                {
                    return;
                }

                string text = "";

                for (int i = 0; i < mc.Count; i++)
                {
                    if (i < mc.Count - 2)
                    {
                        text = PageHtml.Substring(mc[i].Index, mc[i + 1].Index - mc[i].Index);
                    }
                    else
                    {
                        text = PageHtml.Substring(mc[i].Index, PageHtml.IndexOf(LastItemEndTag, mc[i].Index) - mc[i].Index);
                    }

                    text = RemoveGarbage(text);

                    OnExtract(text);
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }