示例#1
0
        private async void getManga(string url)
        {
            string st = await getPage(url);
            string[] HtmlResp;

            List<ResultadoHtml> RespList = new List<ResultadoHtml>();
            List<ResultadoHtml> RespListInfo = new List<ResultadoHtml>();
            
            HtmlResp = st.Split(new string[] { "\r\n", "\n" }, StringSplitOptions.None);

            foreach (string s in HtmlResp)
            {
                RespList.Add(new ResultadoHtml() { resultado = s });
                RespListInfo.Add(new ResultadoHtml() { resultado = s });
            }

            
            Regex filtro = new Regex(@"^(<div id=""mangaimg"">|<div id=""mangaproperties"">|<h1>(.*?)</h1>|<td class=""propertytitle"">|<h2 class=""aname"">|<td class=""propertytitle"">|<td>|<div id=""readmangasum"">|<h2>(.*?)</h2>|<p>(.*?)</p)");

            RespListInfo = RespListInfo.Where(a => filtro.IsMatch(a.resultado)).ToList();

            im = nInfoM();
            string cr = "";
            im.Info.EndImagem = Regex.Replace(RespListInfo[0].resultado, "(^(<d)(.*?)(c=\"))|((\" alt)(.*?)(v>))", "");
            im.Info.Titulo += Regex.Replace(RespListInfo[2].resultado, "(<h1>)|(</h1>)", "");
            im.Info.Nome += Regex.Replace(RespListInfo[5].resultado, "(<h2)(.*?)(e\">)|(</h2>)", "");
            im.Info.ANome += Regex.Replace(RespListInfo[7].resultado, "(<td>)|(</td>)", "");
            im.Info.Ano += Regex.Replace(RespListInfo[9].resultado, "(<td>)|(</td>)", "");
            im.Info.Status += Regex.Replace(RespListInfo[11].resultado, "(<td>)|(</td>)", "");
            im.Info.Autor += Regex.Replace(RespListInfo[13].resultado, "(<td>)|(</td>)", "");
            im.Info.Artista += Regex.Replace(RespListInfo[15].resultado, "(<td>)|(</td>)", "");
            im.Info.DirecaoLeitura += Regex.Replace(RespListInfo[17].resultado, "(<td>)|(</td>)", "");

            im.Info.Generos += Regex.Replace(RespListInfo[19].resultado, "(</a>)|(</span>)|(<td>)|(</td>)|(<a href=)(.*?)(\">)|(<span )(.*?)(\">)", "");

            im.Info.Descricao1 = Regex.Replace(RespListInfo[27].resultado, "(<h2>)|(</h2>)", "");
            im.Info.Descricao2 = Regex.Replace(RespListInfo[28].resultado, "(<p>)|(</p>)", "");

            List<Capitulos> ctl = new List<Capitulos>();
            
            filtro = new Regex("^(<div class=\"chico_manga\"></div>|(<a href=\"/)|((<td>)([0-9]{2}/[0-9]{2}/[0-9]{4})(</td>)))");


            RespList = RespList.Where(a => filtro.IsMatch(a.resultado)).ToList();

            grdInfoManga.DataContext = im;

            Regex filtroDiv, filtroHref, filtroTd;
            filtroDiv = new Regex("^(<div )");
            filtroHref = new Regex("^(<a href=)");
            filtroTd = new Regex("^(<td>)");

            int i = 0;
            for (int x = 0; x < RespList.Count(); x++)
            {
                if (filtroDiv.IsMatch(RespList[x].resultado) && filtroHref.IsMatch(RespList[x + 1].resultado) && filtroTd.IsMatch(RespList[x + 2].resultado))
                {
                    i++;
                    ctl.Add(new Capitulos()
                    {                        
                        Endereco = Regex.Replace(RespList[x + 1].resultado, "(<a href=\")|(\">)(.*?)*(</td>)", ""),
                        Numero = Convert.ToInt32(Regex.Replace(RespList[x + 1].resultado, "(^(<a )(.*?)(\">)|(</a>)(.*?)*(</td>))|(\\D+)", "")),
                        nome = Regex.Replace(RespList[x + 1].resultado, "^(<a )(.*?)( : )|(</td>)", ""),
                        Data = Regex.Replace(RespList[x + 2].resultado, "(<td>)|(</td>)", ""),
                    });

                }
            }

            im.Caps = ctl.OrderByDescending(t => t.Numero).ToList();
            lstCap.ItemsSource = im.Caps;
            grdInfoManga.DataContext = im;
            lstAll.IsEnabled = true;
        }
示例#2
0
 private InfoManga nInfoM()
 {
     Mangas mg = new Mangas()
     {
         Titulo = "",
         Nome = "Nome: ",
         ANome = "Nome Alternativo: ",
         Ano = "Ano de Lançamento: ",
         Status = "Status: ",
         Autor = "Autor: ",
         Artista = "Artista: ",
         DirecaoLeitura = "Direção de Leitura: ",
         Generos = "Generos: "
     };
     InfoManga im = new InfoManga();
     im.Info = mg;
     return im;
 }