snippetify/laravel-sniptbot
Composer 安装命令:
composer require snippetify/laravel-sniptbot
包简介
Sniptbot for laravel
关键字:
README 文档
README
This repository implements a simple ServiceProvider that makes the instances of the Snippet Crawler and Sniffer easily accessible via a Facade in Laravel. See @Snippetify/Snippet-sniffer for more information about the PHP Snippet sniffing and its interfaces.
What it does
This library allows you
- To get code snippets using search engine api (Google)
- To get code snippets from any web page by crawling url seeds.
How to use it
$ composer require snippetify/laravel-sniptbot
php artisan vendor:publish --provider="Snippetify\Sniptbot\SniptbotServiceProvider"
Configuration
Open the created file in the config/sniptbot.php and customize the configuration options to your liking.
return [ // Search engine api configuration keys 'provider' => [ // Your google Search engine ID // https://developers.google.com/custom-search/v1/introduction 'cx' => env('SNIPTBOT_PROVIDER_CX', ''), // Your google API key // https://developers.google.com/custom-search/v1/overview#api_key 'key' => env('SNIPTBOT_PROVIDER_KEY', ''), 'name' => env('SNIPTBOT_PROVIDER_NAME', 'google'), // provider name (google) ], // Optional // Useful for adding meta information to each snippet 'app' => [ 'name' => env('SNIPTBOT_NAME', 'Sniptbot'), // your sniptbot name 'version' => env('SNIPTBOT_VERSION', '1.0.0'), // your sniptbot version ], // Optional // Useful for logging 'logger' => [ 'name' => env('SNIPTBOT_NAME', 'Sniptbot'), // logger name 'file' => storage_path('logs/sniptbot.log'), // logger file path ], // Optional // Useful for scraping 'html_tags' => [ 'index' => 'h1, h2, h3, h4, h5, h6, p, li', // Tags to index 'snippet' => 'pre[class] code, div[class] code, .highlight pre, code[class]', // Tags to fetch snippets ], // Optional // Useful for adding new scrapers // The name must be the website host without the scheme i.e. not https://foo.com but foo.com 'scrapers' => [ // 'scraper_name' => ScraperClass::class, // You can add as many as you want ], // Optional // Useful for adding new providers 'providers' => [ // 'provider_name' => ProviderClass::class, // You can add as many as you want ], // Optional // Useful for web crawling // Please follow the link below for more information as we use Spatie crawler // https://github.com/spatie/crawler 'crawler' => [ // 'langs' => ['en'], // 'profile' => Snippetify\SnippetSniffer\Profiles\CrawlSubdomainsAndUniqueUri::class, // 'user_agent' => Snippetify\SnippetSniffer\Core::CRAWLER_USER_AGENT, // 'concurrency' => 10, // 'ignore_robots' => false, // 'maximum_depth' => null, // 'execute_javascript' => false, // 'maximum_crawl_count' => null, // 'parseable_mime_types' => ['text/html'], // 'maximum_response_size' => 1024 * 1024 * 3, // 'delay_between_requests' => 250, ] ];
Sniffing from search engine api
use Snippetify\Sniptbot\Facades\Sniffer; // Important: You must set your search engine keys before using it // @return Snippetify\SnippetSniffer\Common\Snippet[] $snippets = Sniffer::fetch('js array contains value');
Crawl url seeds
use Snippetify\Sniptbot\Facades\Crawler; // @return Snippetify\SnippetSniffer\Common\MetaSnippetCollection[] $snippets = Crawler::fetch(['your urls']);
Changelog
Please see CHANGELOG for more information what has changed recently.
Testing
You must set the PROVIDER_NAME, PROVIDER_CX, PROVIDER_KEY, CRAWLER_URI, keys in phpunit.xml file before running tests.
Important: Those links must contains at least one snippet otherwise the tests will failed.
composer test
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
snippetify/laravel-sniptbot 适用场景与选型建议
snippetify/laravel-sniptbot 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 4 次下载、GitHub Stars 达 1, 最近一次更新时间为 2020 年 06 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「scraper」 「spider」 「crawler」 「crawling」 「scraping」 「sniffer」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 snippetify/laravel-sniptbot 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 snippetify/laravel-sniptbot 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 snippetify/laravel-sniptbot 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
A lightweight, dependency free PHP class that acts as wrapper for Crawlbase API
A tool for scraping URL resources (oEmbed, OpenGraph, Twitter cards, JSON-LD)
Sitemap crawler/generator. For the given URL it will return sitemap XML file with URLs and images.
Scrapes app data from Google Play store.
A new generation of multi-process async event-driven spider engine based on Workerman
统计信息
- 总下载量: 4
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 11
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-30