bstien /
使用此软件包搜索种子
0.1.0
2015-03-03 21:11 UTC
Requires
- guzzlehttp/guzzle: 5.2.0
- symfony/css-selector: ~2.6
- symfony/dom-crawler: ~2.6
Requires (Dev)
- illuminate/support: ~5.0
This package is not auto-updated.
Last update: 2024-09-28 16:05:11 UTC
README
这是一个用于Laravel 5爬取种子的软件包。
安装
将以下内容添加到您的composer.json
"require": { "bstien/laravel-torrent": "dev-master" }
在config/app.php中注册门面和ServiceProvider
'providers' => [ // ... 'Stien\Torrent\TorrentServiceProvider', ]; 'aliases' => [ // ... 'Torrent => 'Stien\Torrent\Facades\Torrent', ];
使用方法
常规搜索
如果找到匹配项,则返回包含Stien\Torrent\Result\Torrent-对象的数组。如果没有找到,则返回空数组。
use Stien\Torrent\Facades\Torrent; # You can register this to your facades-array in config/app.php if you like $torrents = Torrent::search("Modern Family"); foreach( $torrents as $torrent ) { echo $torrent->getTitle(); } # To search within a specific category, use any of the constants in # Stien\Torrent\Categories.
按类别搜索
将类别作为Torrent::search()的第二个参数。有关参考,请参阅Stien\Torrent\Categories中的常量。
如果没有指定任何类别,则默认为Categories::ALL。
use Stien\Torrent\Facades\Torrent; use Stien\Torrent\Categories as CAT; $torrents = Torrent::search("Die Hard", CAT::MOVIES_HD);
实现自己的适配器
要扩展此软件包以使用另一个适配器,创建一个新类并使其实现Stien\Torrent\TorrentAdapterInterface。
将适配器注册到爬取器中
use Stien\Torrent\Facades\Torrent; $myAdapter = new MyAdapter(); $myAdapter->setHttpClient(new \GuzzleHttp\Client); Torrent::addAdapter( $myAdapter );