简体   繁体   中英

How to parse a html page, vb.net form

how can I parse this html code:

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

I want to parse "163 Punti". I've tried to search on google but I didn't found nothing.. Someone could help me? Thanx

The element doesn't have an ID . So you can't get the element by using GetElementById method (which is the surest way to identify an element). 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. Otherwise you will need to further customize this code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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