获取特定div元素的内容?

时间:2013-12-19 16:15:02

标签: html vb.net webbrowser-control

是否可以从Web浏览器控件中获取标记的内容,如下所示:<div class="desc">contents</div>然后从中删除所有HTML字符?

说WebBrowser1已经加载了一个网站。我想从中提取源代码并找到它:

<div class="desc"><b>these are the contents I want</b></div>

并像这样提取:these are the contents I want

1 个答案:

答案 0 :(得分:2)

Dim divs = WebBrowser1.Document.Body.GetElementsByTagName("div")

For Each d As HtmlElement In divs
    If d.GetAttribute("className") = "desc" Then
        Return d.InnerText
    End If
Next