使用HttpWebRequest获取网页的内容,然后通过SgmlReader转换成xml友好格式的html,载入到xmlDocument,就可以进行分析了.
但是有个问题,由于网页的html标签不区分大小写,各个网站的html标签有的大小有的小写,甚至大小写混杂,SgmlReader不会把html的标签都转成小写的,经过SgmlReader转换的html载入到xmlDocument,标签也可能是大小写混杂,而xml中的选择查找语句是大小写敏感的.这就给分析网页带来了困难.
SgmlReader是提供源码的,我试着在SgmlReader中把所有输出的字符都改成小写的,测试后发现,一旦html中含有"<![CDATA"这样的标签转成小写的后,载入到xmlDocument时就会出错,提示"'cdata' is an unexpected token. The expected token is 'CDATA['. Line 1, position 124."
似乎还不能把所有的标签都转成小写的,迷茫了,哪位有经验的朋友指点一下,多谢了!
但是有个问题,由于网页的html标签不区分大小写,各个网站的html标签有的大小有的小写,甚至大小写混杂,SgmlReader不会把html的标签都转成小写的,经过SgmlReader转换的html载入到xmlDocument,标签也可能是大小写混杂,而xml中的选择查找语句是大小写敏感的.这就给分析网页带来了困难.
SgmlReader是提供源码的,我试着在SgmlReader中把所有输出的字符都改成小写的,测试后发现,一旦html中含有"<![CDATA"这样的标签转成小写的后,载入到xmlDocument时就会出错,提示"'cdata' is an unexpected token. The expected token is 'CDATA['. Line 1, position 124."
似乎还不能把所有的标签都转成小写的,迷茫了,哪位有经验的朋友指点一下,多谢了!
我用的是1.6.2195.24675
一编译就说找不到StringComparison
查了一下,c#2.0中才有StringComparison
郁闷,不知道有没有用1.1做的
我问了一下java编程的人,他们都用HtmlParser,挺好用
现在也有这个.net版本的了
楼主可以看看这个网址:
http://www.netomatix.com/Products/DocumentManagement/HTMLParserNet.aspx
我在www.gotdotnet.com上面下的,只有1.6版,
我想以前的版本应该有支持.net1.1的
哪位知道告诉我一声,谢谢啦
We offer a community edition of the library for free download. This edition has all the features of professional edition version except support for mime types likes PDF, MS office documents, Xml etc. and multithreaded crawling capabilities. But if your needs are limited to text/html mime type then this is a great library to keep in your tool chest.Download Free Community Edition Version
可是现在找不到支持.net1.1的sgmlReader
三个解决方案中都用到了StringComparison
今天试用一下html parser看看什么效果