将weburl的内容索引到elasticsearch/kiban

2024-05-15 12:56:36 发布

您现在位置:Python中文网/ 问答频道 /正文

我已经用beautiful soup+python删除了一个网站的500多个链接/子链接,现在我期待着在elasticsearch中索引这个url的所有内容/文本,有没有任何工具可以帮助我直接用elasticsearch/kibana堆栈进行索引。在

请帮我用指针,我试着在谷歌上搜索,找到了logstash,但似乎它适用于单个url。在


Tags: 工具文本url内容堆栈网站链接elasticsearch
1条回答
网友
1楼 · 发布于 2024-05-15 12:56:36

有关Logstash的参考请参见:https://www.elastic.co/guide/en/logstash/current/getting-started-with-logstash.html

否则,举一个例子,把你的爬虫输出放入一个文件,每个url有一行,你可以有下面的logstash配置,在这个例子中,logstash将读取一行作为消息,并将其发送到host1和host2上的弹性服务器。在

input {
    file {
        path => "/an/absolute/path" #The path has to be absolute
        start_position => beginning
     }
}

output {
    elasticsearch{
        hosts => ["host1:port1", "host2:port2"] #most of the time the host being the DNS name (localhost as the most basic one), the port is 9200
        index => "my_crawler_urls"
        workers => 4 #to define depending on your available resources/expected performance
    }
}

当然,您可能需要对爬虫程序的输出进行一些过滤、后处理,因此Logstash可以使用codecs和/或{a3}

相关问题 更多 >