我正在寻找一个框架来抓取文章,然后我找到了Nutch 2.1。这是我的计划和每个计划的问题:
1
将文章列表页面添加到 url/seed.txt
这里有一个问题。我真正想要索引的是文章页面,而不是文章列表页面。但是,如果我不允许列表页面被索引,Nutch 将不会执行任何操作,因为列表页面是入口。那么,如何只索引文章页面而不索引列表页面呢?
2
编写一个插件来解析 html 中的“作者”、“日期”、“文章正文”、“标题”以及其他信息。
Nutch 2.1 中的“Parser”插件接口是:
解析 getParse(字符串 url, 网页页面)
'WebPage' 类有一些预定义的属性:
public class WebPage extends PersistentBase {
// ...
private Utf8 baseUrl;
// ...
private ByteBuffer content; // <== This becomes null in IndexFilter
// ...
private Utf8 title;
private Utf8 text;
// ...
private Map<Utf8,Utf8> headers;
private Map<Utf8,Utf8> outlinks;
private Map<Utf8,Utf8> inlinks;
private Map<Utf8,Utf8> markers;
private Map<Utf8,ByteBuffer> metadata;
// ...
}
So, as you can see, there are 5 maps I can put my specified attributes in. But, 'headers', 'outlinks', 'inlinks' seem not used for this. Maybe I could put those information into markers or metadata. Are they designed for this purpose?
BTW, the Parser in trunk looks like: 'public ParseResult getParse(Content content)', and seems more reasonable for me.
3
将文章索引到 Solr 后,另一个应用程序可以按“日期”查询它,然后将文章信息存储到 Mysql 中。
我这里的问题是:Nutch可以将文章直接存储到Mysql中吗?或者我可以编写一个插件来指定索引行为吗?
对于我的目的来说,Nutch 是一个不错的选择吗?如果没有,你们能为我推荐另一个高质量的框架/库吗?
感谢您的帮助。