如何获得的字数在网页上? [英] How to get number of words on a web page?

查看:115
本文介绍了如何获得的字数在网页上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要得到网页上的字的总数。我知道关于 System.Net.WebClient 类。但它的 DownloadString()方法返回整个HTML标记的地方为我所需要的仅仅是文本,以便我可以计算出的单词数。

I need to get total number of WORDS on a web page. I know about the System.Net.WebClient class. But it's DownloadString() method return the whole HTML markup where as what I need is only the TEXT so that I can figure out the number of words.

任何意见/建议表示欢迎。

Any ideas/suggestions welcome.

推荐答案

看看的 http://htmlagilitypack.codeplex.com/ 它可以让你XPath表达式应用到HTML文档。

Take a look at http://htmlagilitypack.codeplex.com/ It allows you to apply xpath expressions to a HTML document.

您想找到的所有文本节点,然后算的话。 //文本()是XPath获取所有文本节点。

You want find all text nodes and then count the words. //text() is the xpath to get all text nodes.

这篇关于如何获得的字数在网页上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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