VB 2012 - 尝试从网站获取ElementID的文本

时间:2016-06-16 06:32:35

标签: visual-studio visual-studio-2010 visual-studio-2012

我正在尝试从网站上的元素获取文本

网站元素代码:

<div class="info-box">
<span class="info-box-icon bg-yellow">
<i class="ion ion-ios-people-outline"></i>
</span>
<div class="info-box-content">
<span class="info-box-text">TOTAL MEMBERS</span>
<span class="info-box-number">34,396</span>
</div>
</div>

我试图从info-box-number获得34,396。

我需要从中获得4个这样的盒子。 它们都是相同的,除了Info-Box-Text和Info-Box-Number不同。

我尝试使用GetAttribute但是,我一直收到错误。

 Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
    Dim theElementCollection As System.Windows.Forms.HtmlElementCollection
    theElementCollection = WebBrowser1.Document.GetElementsByTagName("a")
    WebBrowser1.Document.GetElementsByTagName("info-text-box").GetAttribute("info-text-number").ToString()
End Sub

在我得到号码后,我希望它进入一个TextBox。

0 个答案:

没有答案