From 92a37a786533ccc8e3f1be10a8b0785b347d7420 Mon Sep 17 00:00:00 2001 From: imunnic Date: Mon, 17 Mar 2025 16:28:27 +0100 Subject: [PATCH] valor indice --- app/webscrapper.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/webscrapper.py b/app/webscrapper.py index aafde5b..bf6246b 100644 --- a/app/webscrapper.py +++ b/app/webscrapper.py @@ -217,14 +217,16 @@ def search_indice(indice): soup = BeautifulSoup(response.content, 'html.parser') # Buscar los valores dentro del HTML + chart_inner_title = soup.find("span", {"data-test": "chart-inner-title"}) price = soup.find("div", {"data-test": "instrument-price-last"}) price_change = soup.find("span", {"data-test": "instrument-price-change"}) price_change_percent = soup.find("span", {"data-test": "instrument-price-change-percent"}) porcentaje = price_change_percent.text.strip().replace("(", "").replace(")", "").replace("%", "") + indice_real = chart_inner_title.text.strip() if chart_inner_title else indice if price and price_change and price_change_percent: data = { - "indice": indice, + "indice": indice_real, "valorActual": price.text.replace(",", "").strip(), # Convertir a número "cambio": price_change.text.replace(",", "").strip(), # Convertir a número "porcentaje": porcentaje # Eliminar paréntesis