UNPKG

b3_insigths

Version:
25 lines 963 B
import { load } from "cheerio"; import FixedIncomeScraperBase from "./FixedIncomeScraperBase.js"; export default class IpcaScraper extends FixedIncomeScraperBase { constructor() { super(); this.URL = "https://www.tesourodireto.com.br/titulos/precos-e-taxas.htm"; } async getValue() { const html = await this.getPageHTML(); const $ = load(html); const taxes = []; const table = $(".td-invest-table")[0]; $("tbody", table).each((_, tbody) => { const cells = $("tr > td", tbody); const title = $(cells[0]).find("span").text(); if (title.includes("IPCA")) { const tax = $(cells[1]).find("span").text().replace(/\D/ig, ""); const numberTax = Number(tax) / 100; taxes.push(numberTax); } }); return `IPCA + ${Math.max(...taxes).toFixed(2)}%`; } } //# sourceMappingURL=IpcaScraper.js.map