31 мая 2012 г.

парсинг таблицы с хтмл страницы:

  Sub GetTable()
        Dim PageURL As String = "url"
        Dim TableID As String = "имя таблицы"
        Dim htmDoc As IHTMLDocument2 = New HTMLDocument()
        htmDoc.write(GetPageHTML(PageURL))
        Dim tables As IHTMLElementCollection = htmDoc.getElementsByTagName("table")
        For Each table As IHTMLElement In tables
            If table.id = TableID Then
                For Each r In table.rows
                    For Each c In r.cells
                        MsgBox(c.innerText)
                    Next
                Next
            End If
        Next
        MsgBox("done!")
    End Sub
    Public Function GetPageHTML(ByVal URL As String) As String
        Dim objWC As New System.Net.WebClient()
        'objWC.Credentials = CredentialCache.DefaultCredentials
        Return New System.Text.UTF8Encoding().GetString(objWC.DownloadData(URL))
    End Function