从html页面获取内容

编程入门 行业动态 更新时间:2024-10-13 22:24:36
本文介绍了从html页面获取内容的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

有人可以告诉我如何从vb或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 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页面获取内容

本文发布于:2023-11-25 23:11:43,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1631727.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:页面   内容   html

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!