定期解析HTMl标签 [英] regular experesstion for parsing the HTMl tags

查看:87
本文介绍了定期解析HTMl标签的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨...

我想解析HTML标签并将标签的内容存储在数据库中....但我不知道怎么做!!!

可以帮助我吗?

我想从新闻网站获取新闻日期,新闻名称,新闻标题和新闻内容的信息,这是如何工作的?

谢谢

Hi...
I want to parse HTML tags and store tag's contents in database....but I don't know how do it!!!
can help me?
I want to fetch information for example news's date,news's name,news's title and news's content from news sites,how do this work?
thanks

推荐答案

请参阅:

http:// stackoverflow .com / a / 590789 [ ^ ]

Please see:
http://stackoverflow.com/a/590789[^]

无法使用整个HTML解析正则表达式,因为它取决于匹配开头和结束标记,这是正则表达式无法实现的。



正则表达式只能匹配regul语言,但HTML是一种无上下文的语言。你可以用HTML上的regexp做的唯一的事情就是启发式,但这并不适用于所有条件。应该可以呈现一个HTML文件,该文件将被任何正则表达式错误地匹配。

Entire HTML parsing is not possible with regular expressions, since it depends on matching the opening and the closing tag which is not possible with regexps.

Regular expressions can only match regular languages but HTML is a context-free language. The only thing you can do with regexps on HTML is heuristics but that will not work on every condition. It should be possible to present a HTML file that will be matched wrongly by any regular expression.



使用 Html Agility Pack [ ^ ]来解析HTML。


Use the Html Agility Pack[^] to parse HTML.


这篇关于定期解析HTMl标签的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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