获取特定div元素的内容? [英] Getting contents of specific div element?

查看:92
本文介绍了获取特定div元素的内容?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以从Web浏览器控件中获取标签的内容,如下所示:< div class =desc>内容< / div> 和然后去掉它的所有HTML字符?

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?

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

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>

并将其解压为:这些是我想要的内容

推荐答案

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

这篇关于获取特定div元素的内容?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆