How to grab website table data into listview control in

Grab Website Table Data

Here in this application I have added a simple html file contains a table with few records to show you how it works.

Code: How to grab website table data into listview control in

        Dim k As Integer
        Dim p As Integer
        Dim X As ListViewItem
        Dim outputstream1 As String
        Dim outputstream2 As String
        k = WebBrowser1.Document.GetElementsByTagName("tr").Count
        Dim tRow As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("tr")
        p = 0
        While (p <= k - 1)
            Dim pp As HtmlElementCollection = tRow.Item(p).GetElementsByTagName("td")
            'Because table has only 2 columns so no need to pass pp item index dynamically
            outputstream1 = pp.Item(0).InnerText
            outputstream2 = pp.Item(1).InnerText
            X = New ListViewItem(outputstream1)
            p = p + 1
        End While
        'Following line will remove table header

It is really easy to understand and useful to grab simple table data from website and this program can be easily modified to suit your need. You can download the complete source code here.

If you enjoyed this post, please like my blog