在vb.net中解析没有id的表

时间:2013-05-14 21:56:10

标签: visual-studio-2010 parsing

我需要解析这个表的项目并在VB.NET中的各种TextBox控件中显示它。

<table class="forumline" border="0" width="90%">
    <th colspan="3">Information about ipaddress 173.194.40.144</th>
<tr>
    <td width="15%" align="right" colspan="1" class="row3"valign="top"><p align="center"><b>Provider Info</b></td>
    <td width-"15%" align="center" colspan="1" class="row3">Country Info</td>
    <td width="15%" align="center" colspan="1" class="row3"><b>Time info</b></td>
</tr>
<tr>
    <td align="center" class="row1" width="15%">IP address<br><input type="text" name="T1" size="20" value="173.194.40.144"> </td>
    <td align="center" class="row1" width="15%">Country<br><input type="text" name="T2" size="20" value="United States"></td>
    <td align="center" class="row1" width="15%">Continent<br><input type="text" name="T3" size="20" value="North America"></td>
</tr>
<tr>
    <td align="center" class="row2" width="15%">Hostname<br><input type="text" name="T4" size="20" value="par10s10-in-f16.1e100.net"></td>
    <td align="center" class="row2" width="15%">Region (code)<br><input type="text" name="T8" size="20" value="California (CA)"></td>
    <td align="center" class="row2" width="15%">Latitude<br><input type="text" name="T12" size="20" value="37.4192"></td>
</tr>
<tr>
    <td align="center" class="row1" width="15%">Organization<br><input type="text" name="T5" size="20" value="Google"></td>
    <td align="center" class="row1" width="15%">City<br><input type="text" name="T9" size="20" value="Mountain View"></td>
    <td align="center" class="row1" width="15%">Longitude<br><input type="text" name="T13" size="20" value="-122.0574"></td>
</tr>
<tr>
    <td align="center" class="row2" width="15%">ISP<br><input type="text" name="T7" size="20" value="Google"></td>
    <td align="center" class="row2" width="15%">Areacode<br><input type="text" name="T10" size="20" value="650"></td>
    <td align="center" class="row2" width="15%">Time zone<br><input type="text" name="T14" size="20" value="America/Los_Angeles"></td>
</tr>
<tr>
    <td align="center" class="row1" width="15%">Flag<br><img src="flags/us.gif"></td>
    <td align="center" class="row1" width="15%">Postalcode<br><input type="text" name="T11" size="20" value="94043"></td>
    <td align="center" class="row1" width="15%">GMT offset<br><input type="text" name="T15" size="20" value="-7"></td>
</tr>

当用户点击按钮时,我会获得数据(IP地址,国家/地区,大陆,... GMT偏移量)。

我尝试使用HtmlAgilityPack,但也许XPATH更好。当表没有id时,我不知道如何使用它。我想我必须使用td名称(前name="T1"),但是如何?

Private Sub NsButton1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles NsButton1.Click

    Dim url As String = ("http://www.iptrackeronline.com/index.php?ip_address=" & NsTextBox1.Text)
    Dim doc As New HtmlAgilityPack.HtmlDocument
    doc.LoadHtml(url)
    Dim node As HtmlAgilityPack.HtmlNode

0 个答案:

没有答案