从html页面获取内容 [英] get content from html pages
本文介绍了从html页面获取内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人可以告诉我如何从vb.net或c#的html页面中提取任何标记之间写入的数据吗?
例如:考虑一个像
的html文档
< html>
< head>
< title> dgdg</title>
</head>
< body>
< div id ="body">
< p>你好,这就是我想要的</p>
</div>
</body>
</html>
我想要< p>之间的文本标签???如何提取呢???我需要遍历每个标签才能到达那个特定标签吗?
任何解决方案-谢谢
can anybody tell me how to extract data written between any tag from html pages in vb.net or c#???
for eg: consider an html document like
<html>
<head>
<title>dgdg</title>
</head>
<body>
<div id="body">
<p>hello this is what i want</p>
</div>
</body>
</html>
i want the text between <p> tag??? how to extract it??? will i have to go through each tag to reach that particular tag??
any solution - thanks
推荐答案
您的VB.NET代码就是这样.
Your VB.NET Code will be something like this.
Dim first, last As String
first = "<p>"
last = "</p>"
Dim RE As New Regex(first + _
"(?<MYDATA>.*?(?=" + last + "))", _
RegexOptions.IgnoreCase Or RegexOptions.Singleline)
Dim m As Match = RE.Match(yourData)
'' got the result
Dim output As String
output = m.Groups("MYDATA").Value
使用正则表达式查找P标签并提取文本
Use a Regular Expression to find the P tags and extract the text
这篇关于从html页面获取内容的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文