Getting contents of specific div element?

佐手、 提交于 2019-11-28 06:42:11

问题


is it possible to get the contents of a tag from a web browser control like this: <div class="desc">contents</div> and then strip all HTML characters from it?

say WebBrowser1 has a website loaded into it. I want to extract the source code from it and find this:

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

and extract it like this: these are the contents I want


回答1:


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


来源:https://stackoverflow.com/questions/20686488/getting-contents-of-specific-div-element

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!