如何将获取的 html 内容保存到 apache nutch 中的数据库?

How to save fetched html content to database in apache nutch?

我使用的是 1.8 版的 apache nutch。我想将抓取的 HTML 内容保存到 postgre 数据库来执行此操作,我将 FetcherThread.java class 修改如下。

  case ProtocolStatus.SUCCESS: // got a page
  pstatus = output(fit.url, fit.datum, content, status,
  CrawlDatum.STATUS_FETCH_SUCCESS, fit.outlinkDepth);
  updateStatus(content.getContent().length);              
  /*Added My code Here*/

但是我想使用插件系统而不是直接修改FetcherThread class。要使用插件系统,我需要使用哪些扩展点?

您可以编写自定义插件并实现 org.apache.nutch.indexer.IndexWriter 的扩展以将文档发送至 Postgres 作为索引步骤的一部分。您需要为需要 NUTCH-2032 的原始内容编制索引 - 这是 Nutch 1.11 中的内容,因此您需要升级您的 Nutch 版本。

或者,您可以编写自定义 MapReduce 作业,它将段作为输入,读取内容并在 reduce 步骤中将其发送到您的数据库。