simgroep/concurrent-spider-bundle

此包已被弃用且不再维护。未建议替代包。

Symfony 扩展包,用于运行分布式网页爬虫

1.1.0 2017-05-26 06:30 UTC

This package is auto-updated.

Last update: 2022-02-01 12:47:28 UTC


README

Build Status Coverage Status

此扩展包提供了一组命令,用于运行分布式网页爬虫。爬取的网页将被保存到 Solr。

安装

使用 Composer 安装

composer require simgroep/concurrent-spider-bundle dev-master

然后将它添加到你的 AppKernel.php

new Simgroep\ConcurrentSpiderBundle\SimgroepConcurrentSpiderBundle(),

需要安装 http://www.foolabs.com/xpdf/ - 只需 pdftotext 真正从命令行使用

/path_to_command/pdftotext pdffile.pdf

配置

需要最少的配置。爬虫需要知道你在 Solr 中使用的映射,以便保存文档。配置中唯一必须的部分是 "mapping"。其他值是可选的

simgroep_concurrent_spider:
    http_user_agent: "PHP Concurrent Spider"

    rabbitmq.host: localhost
    rabbitmq.port: 5672
    rabbitmq.user: guest
    rabbitmq.password: guest

    queue.discoveredurls_queue: discovered_urls
    queue.indexer_queue: indexer

    solr.host: localhost
    solr.port: 8080
    solr.path: /solr

    mapping:
        id: #required
        title: #required
        content: #required
        url: #required
        tstamp: ~
        date: ~
        publishedDate: ~

它是如何工作的?

你可以通过以下方式启动爬虫

app/console simgroep:start-crawler https://github.com

这将向队列中添加一个任务以爬取网址 https://github.com。然后运行以下进程在后台开始爬取

app/console simgroep:crawl

建议使用工具来维护后台的爬虫进程。我们推荐使用 Supervisord。你可以运行尽可能多的线程(并且你的机器可以处理),但你应该小心不要淹没网站。每个线程都作为你正在爬取的网站的访问者。

架构

此扩展包使用 RabbitMQ 来跟踪包含要索引的网址的队列。它还使用 Solr 保存爬取的网页。