Skip to content

Instantly share code, notes, and snippets.

@skrosoft
Created October 10, 2022 16:00
Show Gist options
  • Save skrosoft/70a00955764b8fd8730bfff2f4f43bc6 to your computer and use it in GitHub Desktop.
Save skrosoft/70a00955764b8fd8730bfff2f4f43bc6 to your computer and use it in GitHub Desktop.
Permite generar el BULK Request del registro de los valores UF con los valores del Banco Central de Chile
/**
* IR a: https://si3.bcentral.cl/Indicadoressiete/secure/IndicadoresDiarios.aspx
* IR a: "Unidad de Reajustabilidad" > "Unidad de fomento (UF)" > "Ver serie"
* Luego ejecutar el siguiente script en la consola del navegador:
*/
const year = parseInt(document.getElementById("lblAnioValor").innerText);
const output = { bulk: [] };
for (let month=1; month<=12; month++){
for(let day=1; day<=31; day++){
const element = document.querySelector("#gr > tbody > tr:nth-child(" + (day+1) + ") > td:nth-child(" + (month+1) + ")");
const value = parseFloat(element.innerText.replaceAll(".", "").replaceAll(",", "."));
const monthStr = (month < 10) ? "0" + month : month;
const dayStr = (day < 10) ? "0" + day : day;
if (!isNaN(value)) {
output.bulk.push({
date: year + "-" + monthStr + "-" + dayStr,
value: value
});
}
}
}
console.log(JSON.stringify(output));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment