web-crawler - 如何使用stormcrawler从网站抓取特定数据
问题描述
我正在使用stormcrawler(v 1.16)抓取新闻网站并将数据存储在Elasticsearch(v 7.5.0)上。我的 crawler-conf 文件是Stormcrawler 文件。我使用 kibana 进行可视化。我的问题是
- 在抓取新闻网站时,我只想要文章内容的 url,但我也得到了广告的 url,网站上的其他选项卡。我必须在哪里以及在哪里进行更改 Kibana 链接
- 如果我只能从 URL 中获取特定的东西(比如只有标题或只有内容),我们该怎么做。
编辑:我正在考虑在内容索引中添加一个字段。所以我在 src/main/resources/parsefilter.json 、ES_IndecInit.sh 和 Crawler-conf.yaml 中进行了更改。我添加的 XPATH 是正确的。我已添加为
"parse.pubDate":"//META[@itemprop=\"datePublished\"]/@content"
在解析过滤器中。
parse.pubDate =PublishDate
在 crawler-conf 中并添加
PublishDate": {
"type": "text",
"index": false,
"store": true}
在 ES_IndexInit.sh 的属性中。但我仍然没有在 kibana 或 elasticsearch 中获得任何名为 PublishDate 的字段。ES_IndexInit.sh 映射如下:
{
"mapping": {
"_source": {
"enabled": false
},
"properties": {
"PublishDate": {
"type": "text",
"index": false,
"store": true
},
"content": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"description": {
"type": "text",
"store": true
},
"domain": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"host": {
"type": "keyword",
"store": true
},
"keywords": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"title": {
"type": "text",
"store": true
},
"url": {
"type": "keyword",
"store": true
}
}
}
}
解决方案
仅索引站点中的新闻页面的一种方法是依赖站点地图,但并非所有站点都会提供这些。
或者,您需要一种机制作为解析的一部分,可能在 ParseFilter 中,以确定页面是新闻项目,并根据索引期间元数据中存在的键/值进行过滤。
在CommonCrawl的新闻抓取数据集中完成的方式是种子 URL 是站点地图或 RSS 提要。
要不索引内容,只需注释掉
indexer.text.fieldname: "content"
在配置中。
推荐阅读
- sql - 从具有超集值的表中排除子集
- amazon-web-services - 解决 aws ec2 上下载速度慢的问题
- python - 如果值是数组而不是单个值,则在熊猫数据框中删除行
- java - 在 Java 中,当我发送错误的 XML(XSLT 中没有提到标签的 XML)时,在执行 XSLT 转换时不会抛出 TransformerException
- python - 如何修复 AttributeError:部分初始化模块“numpy1”?
- javascript - 通过js添加内容时Chrome自动滚动页面
- python - Python如何在达到某些条件后停止添加到列表中
- node.js - 如何让 Jest --watch 在更改 JSON/YAML 文件时运行?
- elasticsearch - Kibana:如果数据结果为空,则进行 vega-lite 可视化
- java - 我怎么知道我正在使用什么 jaxrs 实现?