uocnv/spatie-crawler-toolkit-for-laravel
Composer 安装命令:
composer require uocnv/spatie-crawler-toolkit-for-laravel
包简介
Handy classes for Spatie's crawler when using it with Laravel.
README 文档
README
PHP 8 should work, but is not extensively tested. Please report any issues you might find!
A set of classes to use Spatie's crawler with Laravel. Aim is to simplify building crawler applications or adding a crawler to an existing Laravel project. At the moment the following helper classes are implemented:
Cache Crawl Queue
The CacheCrawlQueue allows use the pre-configured Cache in Laravel to store the queue. It stores any actions performed on the queue directly to avoid the need to manually store the queue. You can add it directly to your crawler:
Crawler::create() ->setCrawlQueue(new \Spekulatius\SpatieCrawlerToolkit\Queues\CacheCrawlQueue($url)) ->startCrawling($url);
With this you can stop the crawl and restart at any time. This requires a cache-driver being configured in your .env file.
Crawl Logger
The Crawl Logger is an observer you can add to your crawler to enable logging of crawl events:
Crawler::create() ->setCrawlObserver(new \Spekulatius\SpatieCrawlerToolkit\Observers\CrawlLogger) ->startCrawling($url);
You can export the configuration (see below) to tweak which events are logged.
Crawl Events
The toolkit contains an observer to send you Laravel events allowing you to react to crawl events. This covers the following events:
By default, no events are emitted. To enable events, you will need to add the event observer to your crawler:
$event_observer = new \Spekulatius\SpatieCrawlerToolkit\Observers\CrawlEvents; Crawler::create() ->setCrawlObserver($event_observer) ->startCrawling($url);
An optional identifier can be passed to the crawl events to distinguish between different crawls:
$event_observer = new \Spekulatius\SpatieCrawlerToolkit\Observers\CrawlEvents('my-crawl');
Planned functionality
- Batched crawling using Laravel Queues.
For any suggestions on how to enhance this, please raise an issue.
Requirements & Install
Requirements
- Laravel 6, 7, or 8.
- Cache and Log configured in Laravel.
Installation
composer require spekulatius/spatie-crawler-toolkit-for-laravel
Optionally, you can publish the configuration file:
php artisan vendor:publish --tag=crawler-toolkit-config
Contributing
Please raise a PR or issue.
License
Released under the MIT license. Please see License File for more information.
uocnv/spatie-crawler-toolkit-for-laravel 适用场景与选型建议
uocnv/spatie-crawler-toolkit-for-laravel 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 34 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 08 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 uocnv/spatie-crawler-toolkit-for-laravel 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 uocnv/spatie-crawler-toolkit-for-laravel 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 34
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-08-17