从vb.net读取网站表

时间:2015-08-15 19:37:44

标签: vb.net html-table

我正在中创建一个从网页获取数据的应用程序: http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.7.10.html

在该页面上,单击"显示所有下载"按钮和一个表出现,我想从该表中获取数据,特别是只有"版本"列,然后将其添加到列表视图。 为此,我使用以下代码:

Private Sub files()
    Dim source As String = New Net.WebClient().DownloadString("http://files.minecraftforge.net/maven/net/minecraftforge/forge/index_1.7.10.html")
    Dim recentSource As String = GetTagContents(source, "<table class=""downloadsTable"" id=""downloadsTable"">", "</table>")(0)
    Dim lvi As New ListViewItem
    For Each title As String In GetTagContents(recentSource, "<li>", "</li>")
        If Not title.Contains("http:") Then
            lvi.Text = title
            ListView1.Items.Add(lvi)
        End If
    Next
End Sub

Private Function GetTagContents(ByVal Source As String, ByVal startTag As String, ByVal endTag As String) As List(Of String)
    Dim StringsFound As New List(Of String)
    Dim Index As Integer = Source.IndexOf(startTag) + startTag.Length
    While Index <> startTag.Length - 1
        StringsFound.Add(Source.Substring(Index, Source.IndexOf(endTag, Index) - Index))
        Index = Source.IndexOf(startTag, Index) + startTag.Length
    End While
    Return StringsFound
End Function

问题是它只显示表格中的第一个值&#34; 10.13.4.1492&#34;。 该程序不会继续使用表格的以下几行,只保留在那里。

0 个答案:

没有答案