I'm using node-fetch and dom-parser to fetch a POST request and convert its result to a DOM Document. I'm using this:
var data = new FormData();
data.append("dataInicial", "01/01/2020");
data.append("dataFinal", "01/04/2020");
data.append("valorCorrecao", "100,00");
data.append("percentualCorrecao", "120,00");
data.append("percentualCorrecao", "120,00");
const response = await fetch('https://www3.bcb.gov.br/CALCIDADAO/publico/corrigirPeloCDI.do?method=corrigirPeloCDI', {
method: "post",
body: data,
})
const messageData = await response.text();
Printing with console.log(messageData),, I get the html code as a string:
https://gist.github.com/hofstede-matheus/4c9c10f0edc229dfece61f869f621301
But using when DOMParser to convert it to a DOM Document with:
const parser = new DOMParser();
const htmlDocument = parser.parseFromString(messageData, "text/html");
It returns a rawHTML whose I cant use a querySelector to crawl a string inside a table:
https://gist.github.com/hofstede-matheus/f173e3a3f66a277a1e43ed9711af53c7
I have also tried regex get the table with no success. There are other ways to archive what I'm trying to get