java - Nutch - 解析自定义 HTML 元素
问题描述
我正在尝试抓取和索引(使用 Solr)我正在抓取的页面的特定部分。
到目前为止,使用所有默认配置,我正在抓取和索引我想要的页面,但在 Solr 中,我只有 2 个字段,标题和内容,其中包含我的页面文本,但它不完全是我想要的文本。
我想要实现的是拥有包含特定 div 内容的新字段。
<div class="myDiv"> Content I want to index </div>
到目前为止,我发现的是Extractor Plugin,这似乎是我想要的。
按照说明操作后,我无法解析数据,因为我收到以下错误并且我不明白出了什么问题。
我正在使用 Nutch 1.15
java.lang.Exception: java.lang.LinkageError: loader constraint violation: when resolving method "org.slf4j.impl.StaticLoggerBinder.getLoggerFactory()Lorg/slf4j/ILoggerFactory;" the class loader (instance of org/apache/nutch/plugin/PluginClassLoader) of the current class, org/slf4j/LoggerFactory, and the class loader (instance of sun/misc/Launcher$AppClassLoader) for the method's defining class, org/slf4j/impl/StaticLoggerBinder, have different Class objects for the type org/slf4j/ILoggerFactory used in the signature
at org.apache.hadoop.mapred.LocalJobRunner$Job.runTasks(LocalJobRunner.java:462)
at org.apache.hadoop.mapred.LocalJobRunner$Job.run(LocalJobRunner.java:522)
解决方案
似乎使用的 slf4j-api 是旧版本,与 Nutch 使用的不匹配。至少,我是这么理解的。
为了解决这个问题,我只是在/plugins/extractor/plugin.xml
删除这一行:<library name="slf4j-api-1.7.5.jar"/>
推荐阅读
- javascript - 如何根据屏幕大小动态设置div的宽度?
- dart - 当我更改另一个表时影响一个表
- query-string - 使用带有引号的查询字符串进行 EWS 搜索不适用于 Exchange 2016
- python - 在熊猫中使用正则表达式从多个括号中提取字符串
- javascript - 当背景图像为空时回退背景颜色
- docker - Cloud Run 上的容器内存管理和 OOM
- python - 在 Keras 中实现后期融合
- android - 进程意外退出,AAPT2错误
- regex - 是否可以制作一个正则表达式来删除每行超过 2 个单词
- javascript - 需要来自子目录的 Node JS 核心模块(在 NW JS 中)