private void procesaBallenas() { List <ballena> ballenas = new List <ballena>(); //string walletOrigen = "rGcyM8aFJwLEFajEeCJwtQJsCTYt9qXKsu"; string url = "https://xrpcharts.ripple.com/#/graph/"; SHDocVw.ShellWindows shellWindows; try { // 1. CERRAMOS TODAS LAS INSTANCIAS DE IE ABIERTAS shellWindows = new SHDocVw.ShellWindows(); foreach (SHDocVw.WebBrowser ie in shellWindows) { ie.Quit(); } List <string> cuentasBallenas = bdd.getCuentasBallenas(); foreach (string cuentaBallena in cuentasBallenas) { Process.Start("IExplore.exe", url + cuentaBallena); System.Threading.Thread.Sleep(5000); // ESPERAMOS CARGA shellWindows = new SHDocVw.ShellWindows(); foreach (SHDocVw.WebBrowser ie in shellWindows) { // 1. Obtenemos codigo fuente HTMLDocument doc = ie.Document as mshtml.HTMLDocument; if (doc != null) { string docBody = doc.body.outerHTML; docBody = doc.body.innerHTML; // 2. Parseamos resultados de html if (docBody != null) { int contCell = 0; HtmlAgilityPack.HtmlDocument hap = new HtmlAgilityPack.HtmlDocument(); hap.LoadHtml(docBody); if (hap.DocumentNode.SelectNodes("//table[@class='outertable']") != null) { foreach (HtmlNode table in hap.DocumentNode.SelectNodes("//table[@class='outertable']")) { if (!table.InnerHtml.ToString().Contains("toprow")) { foreach (HtmlNode tbody in table.SelectNodes("tbody")) { foreach (HtmlNode row in tbody.SelectNodes("tr")) { ballena b = new ballena(); b.walletOrigen = cuentaBallena; contCell = 0; foreach (HtmlNode cell in row.SelectNodes("th|td")) { if (contCell == 0) { if (cell.SelectNodes("//div[@title]") != null) { b.tipoPperacion = cell.SelectNodes("//div[@title]").LastOrDefault().Attributes["title"].Value; contCell++; } } else { foreach (HtmlNode span in cell.SelectNodes(".//span[@class]")) { string attributeValue = span.GetAttributeValue("class", ""); switch (attributeValue) { case "bold amount small": b.cantidad = span.InnerText.Replace(",", ""); if (b.cantidad.Contains("59899")) { } break; case "light small darkgray": b.moneda = span.InnerText; break; case "light small mediumgray date": //b.fecha = span.InnerText; string auxFecha = span.GetAttributeValue("title", ""); IFormatProvider enUsDateFormat = new CultureInfo("en-US").DateTimeFormat; DateTime aux = Convert.ToDateTime(auxFecha, enUsDateFormat); b.fecha = aux; break; case "light address right": b.walleDestino = span.InnerText; break; } } ballenas.Add(b); // SI LA TRANSACCION > 999.999 if (Convert.ToDouble(b.cantidad.Replace(".", ",")) > 999999) { // DAMOS DE ALTA LA CUENTA DESTINO EN CUENTAS BALLENA SI NO EXISTE bdd.altaBallena(b); // DAMOS DE ALTA LA TRANSACCION SI NO EXISTE bdd.altaTransaccion(b); lstBallenas.Items.Add("TRANSACCION DE " + b.cantidad + " XRP DESDE " + b.walletOrigen); } } } } } } } } } } ie.Quit(); } } } catch (Exception ex) { } }
private void testBallenas2() { List <ballena> ballenas = new List <ballena>(); try { string walletOrigen = "rGcyM8aFJwLEFajEeCJwtQJsCTYt9qXKsu"; string url = "https://xrpcharts.ripple.com/#/graph/" + walletOrigen; //Process.Start("IExplore.exe", url); SHDocVw.ShellWindows shellWindows = new SHDocVw.ShellWindows(); foreach (SHDocVw.WebBrowser ie in shellWindows) { // 1. Obtenemos codigo fuente HTMLDocument doc = ie.Document as mshtml.HTMLDocument; if (doc != null) { string docBody = doc.body.outerHTML; docBody = doc.body.innerHTML; // 2. Parseamos resultados de html if (docBody != null) { int contCell = 0; HtmlAgilityPack.HtmlDocument hap = new HtmlAgilityPack.HtmlDocument(); hap.LoadHtml(docBody); if (hap.DocumentNode.SelectNodes("//table[@class='outertable']") != null) { foreach (HtmlNode table in hap.DocumentNode.SelectNodes("//table[@class='outertable']")) { if (!table.InnerHtml.ToString().Contains("toprow")) { foreach (HtmlNode tbody in table.SelectNodes("tbody")) { foreach (HtmlNode row in tbody.SelectNodes("tr")) { ballena b = new ballena(); b.walletOrigen = walletOrigen; contCell = 0; foreach (HtmlNode cell in row.SelectNodes("th|td")) { if (contCell == 0) { if (cell.SelectNodes("//div[@title]") != null) { b.tipoPperacion = cell.SelectNodes("//div[@title]").LastOrDefault().Attributes["title"].Value; contCell++; } } else { foreach (HtmlNode span in cell.SelectNodes(".//span[@class]")) { string attributeValue = span.GetAttributeValue("class", ""); switch (attributeValue) { case "bold amount small": b.cantidad = span.InnerText; break; case "light small darkgray": b.moneda = span.InnerText; break; case "light small mediumgray date": //b.fecha = span.InnerText; //b.fecha = span.GetAttributeValue("title", ""); break; case "light address right": b.walleDestino = span.InnerText; break; } } ballenas.Add(b); } } } } } } } } } } } catch (Exception ex) { } }