简体   繁体   English

如何解析HTML页面,vb.net表单

[英]How to parse a html page, vb.net form

how can I parse this html code: 我如何解析此html代码:

<a href="http://member.20dollars2surf.com/points.php" class="bl" style="text-decoration:none">163 Punti</a><

I want to parse "163 Punti". 我想解析“ 163 Punti”。 I've tried to search on google but I didn't found nothing.. Someone could help me? 我曾尝试在Google上进行搜索,但没有找到任何内容。有人可以帮助我吗? Thanx 谢谢

The element doesn't have an ID . 元素没有ID So you can't get the element by using GetElementById method (which is the surest way to identify an element). 因此,您无法使用GetElementById方法(这是确定元素的最可靠方法)来获取元素。 However you can use other methods. 但是,您可以使用其他方法。

    Dim allLinks As HtmlElementCollection = WebBrowser1.Document.GetElementsByTagName("A")
    For Each link As HtmlElement In allLinks
        If link.GetAttribute("href") = "http://member.20dollars2surf.com/points.php" Then
            Dim linkText As String = link.InnerHtml
            MessageBox.Show(linkText)
        End If
    Next

The above code will work properly only if there is only one link on the page with that URL. 仅当页面上只有一个带有该URL的链接时,以上代码才能正常工作。 Otherwise you will need to further customize this code. 否则,您将需要进一步自定义此代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM