paip.Winista HTMLParser文本结点的获取
作者Attilax , EMAIL:1466519819@qq.com
---------主要代码如下
//NodeFilter filter = new NodeClassFilter( typeof( Winista.Text.HtmlParser.Tags.Div ) );
//Winista.Text.HtmlParser.Nodes.TextNode
//NodeFilter filter = new StringFilter("www.xinlg.com");
NodeFilter filter = new StringFilter(flagTitle);
-----------------函数方法如下
public string getFlag(string html,string flagTitle)
{
Lexer lexer = new Lexer(html);
Parser parser = new Parser(lexer);
//NodeFilter filter = new NodeClassFilter( typeof( Winista.Text.HtmlParser.Tags.Div ) );
//Winista.Text.HtmlParser.Nodes.TextNode
//NodeFilter filter = new StringFilter("www.xinlg.com");
NodeFilter filter = new StringFilter(flagTitle);
NodeList lks = parser.Parse(filter);
for (int i = 0; i < lks.Count; i++)
{
INode htmlNode = lks[i];
if (htmlNode is Winista.Text.HtmlParser.Nodes.TextNode)
if(htmlNode.ToPlainTextString().Trim().Equals(flagTitle))
return htmlNode.NextSibling.ToPlainTextString();
// Response.Write(htmlNode.NextSibling.ToPlainTextString() + "--\r\n<p>");
//ATag AT = ((Winista.Text.HtmlParser.Tags.ATag)(htmlNode));
//if (AT.StringText.Trim().Equals("手机未验证"))
//{
// return "0";
//}
}
return "-1";
}
参考:
.net HTMLParser详细使用说明 强大的Filter类 解析HTML文档如此简单 - IT技术博客 - 秋色园.htm
使用HtmlParser解析HTML (C#版) - piao8163的日志 - 网易博客.htm
paip.Winista HTMLParser文本结点的获取
最新推荐文章于 2024-09-04 09:54:48 发布