Me he descargado Html Agility Pack, pero antes de usarlo he buscado la forma de no depender de librerías externas. He encontrado esta forma usando System.Windows.Forms.HtmlDocument y algo tan viejo como la función InStr.
Antes de usar Instr es obtener las líneas <td class="Pais">*</td> mediante miembro OuterHtml de HtmlElement, luego mediante Instr determinar si estamos en "Num" o "Pais" y en cuyo caso se obtiene el InnerText, que sería el número o país.
Código
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click Dim doc As HtmlDocument = WebBrowser1.Document Dim divs As HtmlElementCollection = doc.GetElementsByTagName("div") Dim Tipo As String Label1.Text = "" For Each div As HtmlElement In divs If div.GetAttribute("id") = "contenedor-portadilla" Then Dim tables As HtmlElementCollection = doc.GetElementsByTagName("table") For Each table As HtmlElement In tables Dim tds As HtmlElementCollection = table.GetElementsByTagName("td") Dim tdText As String = String.Empty For Each td As HtmlElement In tds tdText = td.InnerText Tipo = td.OuterHtml 'Obtiene la columna "num" ' If InStr(Tipo, "num", CompareMethod.Text) > 0 Then ' Label1.Text = Label1.Text & tdText & vbCrLf ' End If 'Obtiene la columna "pais" If InStr(Tipo, "Pais", CompareMethod.Text) > 0 Then Label1.Text = Label1.Text & tdText & vbCrLf End If Next 'Obtiene la cabezera "Totales" Dim ths As HtmlElementCollection = table.GetElementsByTagName("th") Dim thText As String = String.Empty For Each th As HtmlElement In ths thText = th.InnerText Label1.Text = Label1.Text & thText & vbCrLf Next Next End If Next End Sub
Ignoraba que hacer esto se llama "parsear html", este termino me ha venido muy bien a la hora de buscar en la red sobre este tema y he encontrado otras formas que más adelante probaré.
Sl2