Marcelo, I set an example here for you to read the td
but you will need to make some negotiations that are commented in the code below:
HtmlAgilityPack.HtmlDocument htmlDoc = new HtmlAgilityPack.HtmlDocument()
{
OptionFixNestedTags = true
};
// TODO Carregar o HTML dinamicamente através de um requisição
htmlDoc.LoadHtml(@"
<div class=""col-12 col-lg-8"">
<div class=""data-table-full"">
<table id=""high"" class=""default-table active"">
<thead>
<tr>
<th>Ativo</th>
<th>Último (R$)</th>
<th>Var. Dia (%)</th>
<th>Val. Min (R$)</th>
<th>Val. Máx (R$)</th>
<th>Data</th>
</tr>
</thead>
<tr>
<td><a href=""https://www.infomoney.com.br/AZUL4"">AZUL4</a></td>
<td>52,90</td>
<td class=""positive"">1.13</td>
<td>52,46</td>
<td>53,55</td>
<td>11:01 25/10</td>
</tr>
<tr>
<td><a href=""https://www.infomoney.com.br/BBAS3"">BBAS3</a></td>
<td>47,30</td>
<td class=""positive"">0.76</td>
<td>47,12</td>
<td>48,05</td>
<td>11:01 25/10</td>
</tr>
</table>
</div>
</div>
");
var trs = htmlDoc
.GetElementbyId("high")
.ChildNodes
.Where(a => a.Name == "tr");
foreach(var tr in trs)
{
// TODO Aqui você precisará efetuar algumas tratativas:
// Se dentro do TD houver um outro elemento, você precisará
// descer mais um nível para pegar o innerText.
if (tr.ChildNodes[1].Name == "a")
{
// Tratar o anchor
var innerTextDoAnchor = tr.ChildNodes[0].ChildNodes[0].InnerText;
}
// Exemplo de como concatenar os InnerText
string valoresDosTdsConcatenados = string.Join(", ", tr.ChildNodes.Select(a => a.InnerText));
}
Xará, saved me legal... Gave right if code, thanks for the attention, was of great help.
– Marcelo Augusto Colombo