首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >提取Nutch2.x中的HTML元标记并让Solr4对其进行索引

问提取Nutch2.x中的HTML元标记并让Solr4对其进行索引
EN

Stack Overflow用户
提问于 2013-03-20 00:17:46
回答 4查看 4.1K关注 0票数 1

我正在使用Nutch2.0抓取一些网站,但我没有看到HTML元标签,如标题,描述被提取并存储在MySQL数据库中。你知道怎么才能让它工作吗?

谢谢Arash

EN

回答 4

Stack Overflow用户

回答已采纳

发布于 2013-03-21 01:48:24

确保在nutch-site.xml的plugin.includes定义中包含parse-metatags和index-metadata插件

然后添加metatags.names、index.parse.md和index.content.md属性,并将它们指向适当的标记。看看我的:

代码语言:javascript
复制
<property>
        <name>plugin.includes</name>
        <value>protocol-http|protocol-httpclient|urlfilter-regex|parse-(html|tika|metatags)|index-(basic|anchor|metadata)|scoring-opic|urlnormalizer-(pass|regex|basic)</value>
</property>
<property>
        <name>metatags.names</name>
        <value>*</value>
</property>
<property>
        <name>index.parse.md</name>
        <value>metatag.description,metatag.author,metatag.twitter:image</value>
</property>
<property>
        <name>index.content.md</name>
        <value>author,description,twitter:image</value>
</property>

测试您的配置。我在readwrite.com上的一篇文章中运行了这个测试:

代码语言:javascript
复制
bin/nutch indexchecker http://readwrite.com/2013/03/20/whats-behind-china-attacks-on-apple-and-android

输出将告诉您是否解析了正确的值。在我的例子中,我想要author、description和twitter:image

代码语言:javascript
复制
fetching: http://readwrite.com/2013/03/20/whats-behind-china-attacks-on-apple-and-android
parsing: http://readwrite.com/2013/03/20/whats-behind-china-attacks-on-apple-and-android
contentType: text/html
content :   What's Really Behind China's Attacks On Apple And Android? – ReadWrite Sections Sections Social Mobi
title : What's Really Behind China's Attacks On Apple And Android? – ReadWrite
host :  readwrite.com
metatag.author :    Brian S Hall
tstamp :    Wed Mar 20 13:33:38 EDT 2013
metatag.twitter:image : http://readwrite.com/files/styles/150_150sc/public/fields/China%20graphic%20brian%20final.jpg
metatag.description :   Repeated outbursts suggest China could be growing concerned over America's dominance in the smartpho
url :   http://readwrite.com/2013/03/20/whats-behind-china-attacks-on-apple-and-android

一个缺点是parse-metatags将只通过名称而不是属性来匹配标签。例如,<meta name="foo" content="bar">很好,而像<meta property="og:image" content="http://readwrite.com/sample.jpg" />这样的Open Graph标签将会被忽略。

票数 5
EN

Stack Overflow用户

发布于 2013-03-20 00:38:28

看看用于Nutch的IndexMetaTags插件,从1.5版开始可用。

这将允许您指定要解析和索引的meta标记。

注意:字段的名称必须以“metatags.”为前缀。

您可以使用Nutch indexchecker检查索引

票数 2
EN

Stack Overflow用户

发布于 2013-03-23 00:11:37

2.x系列中没有包含Index-Metatags插件。有关更多信息,请查看http://wiki.apache.org/nutch/Nutch2Plugins。这里有一个补丁,可以让这个插件在2.x系列下工作。

正如上述作者在评论中指出的那样,1.6是Nutch目前的稳定版本。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/15504828

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档