`
阿尔萨斯
  • 浏览: 4171418 次
社区版块
存档分类
最新评论

[Nutch]如何利用HTML页面中meta元素?

 
阅读更多
<iframe align="center" marginwidth="0" marginheight="0" src="http://www.zealware.com/csdnblog336280.html" frameborder="0" width="336" scrolling="no" height="280"></iframe>

[Nutch]如何利用HTML页面中meta元素?[郑昀]

1:假如说你的站点页面中有这么一句:

<meta name="robots" content="index,follow">

你利用Nutch抓取并分析时,如何得到这个meta数值并处理呢?

2:你可以从HtmlParseFilter扩展出一个RobotsParserFilter,用下面的代码得到meta值:

Properties generalMetaTags = metaTags.getGeneralTags();
String robots = generalMetaTags.getProperty("robots");

3:增加这个值到metadata中:

parse.getData().getMetadata().put("robots", robots);

4: robots属性还可以再次从 metadata获取:

String robots2 = parse.getData().get("robots");




分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics