Ejemplo n.º 1
0
        /// <summary>
        /// Implementação concreta do site fundsexplorer.com.br
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="B3Code"></param>
        /// <returns></returns>
        public T Fill <T>(string B3Code) where T : DadosBase, new()
        {
            return(Usefull.GetCache <T>(() =>
            {
                var fund = new FundsExplorerModel();
                var HtmlDocument = this.LoadUrl("url.site.fundsexplorer", B3Code);

                var indices = HtmlDocument.GetElementbyId("simulation")
                              .Descendants("div")
                              .Where(Usefull.PredicateFindValueClass("section-body"));

                var cotacao = HtmlDocument.GetElementbyId("stock-price").Descendants("span");

                fund.VariacaoCotacao = cotacao.First(p => p.GetAttributeValue("class", "").Contains("percentage ")).GetValueText();
                fund.Cotacao = cotacao.First(Usefull.PredicateFindValueClass("price")).GetValueText();

                fund.ComparacaoPoupanca = indices.First()
                                          .Descendants("div")
                                          .Where(Usefull.PredicateFindValueClass("col-md-6 col-xs-12")).ElementAt(1)
                                          .Descendants("li")
                                          .Last()
                                          .Descendants("span").ElementAt(1).InnerText.ClearText();


                return fund as T;
            }, B3Code));
        }
Ejemplo n.º 2
0
        public T Fill <T>(string B3Code) where T : DadosBase, new()
        {
            return(Usefull.GetCache <T>(() =>
            {
                var fund = new SiteFIIModel();
                var document = this.LoadUrl("url.site.fii", B3Code);

                var indices = document.GetElementbyId("informations--indexes")
                              .Descendants("span")
                              .Where(Usefull.PredicateFindValueClass("value")).ToList();

                fund.PercentualUltimoYeld = indices[INDICES_PERCENTUAL_ULTIMOYELD].GetValueText();
                fund.UltimoPagamento = indices[INDICES_VALOR_ULTIMOYELD].GetValueText();
                fund.PatrimonioFundo = indices[INDICES_PATRIMONIO_FUNDO].GetValueText();
                fund.PatrimonioPorCota = indices[INICES_PATRIMONIO_POR_COTA].GetValueText();


                fund.Cotacao = document.DocumentNode.Descendants("div")
                               .First(Usefull.PredicateFindValueClass("item quotation"))
                               .Descendants("span")
                               .Where(Usefull.PredicateFindValueClass("item"))
                               .First().GetValueText();

                var basicInformation = document.GetElementbyId("informations--basic")
                                       .Descendants("div")
                                       .Where(Usefull.PredicateFindValueClass("row")).ToList();


                var foundsInformation = basicInformation.First()
                                        .Descendants("div")
                                        .Where(Usefull.PredicateFindValueClass("item")).ToList();


                fund.Codigo = B3Code;
                fund.NomeFundo = foundsInformation[INFORMCOES_NOME].GetTextSpan();
                fund.TipoFundoB3 = foundsInformation[INFORMCOES_TIPO_FUNDO].GetTextSpan();
                fund.TipoFundoAnbima = foundsInformation[INFORMCOES_TIPO_FUNDO_ANBIMA].GetTextSpan();
                fund.DataRegistroCVM = DateTime.Parse(foundsInformation[INFORMCOES_DATA_CRIACAO_FUNDO].GetTextSpan());

                foundsInformation.Clear();

                foundsInformation = basicInformation.Last()
                                    .Descendants("div")
                                    .Where(Usefull.PredicateFindValueClass("item")).ToList();

                fund.TotalCotas = foundsInformation[INFORMCOES_TOTAL_COTAS].GetValueSpan();
                fund.TotalCotistas = foundsInformation[INFORMCOES_TOTAL_COTISTAS].GetValueSpan();
                fund.CNPJ = foundsInformation[INFORMCOES_CNPJ].GetTextSpan();

                return fund as T;
            }, B3Code));
        }