rakshazi / local-content
从RSS/Atom源下载完整内容到本地文件,并用于离线使用
dev-master
2016-03-26 20:42 UTC
Requires
- fguillot/picofeed: ^0.1.19
- greg0/lazer-database: ^1.1
This package is auto-updated.
Last update: 2024-09-13 21:09:04 UTC
README
此库可以从rss/atom源下载内容(包括图片)到本地文件,并允许您将其用作偏好网站的离线副本。
安装
composer require rakshazi/local-content:dev-master
使用
<?php require 'vendor/autoload.php'; /** * Array of feeds. * Structure: array('FEED_URL' => 'FEED_CATEGORY'); */ $feeds = array('https://github.com/fguillot/picoFeed/commits/master.atom' => 'development'); //Grabber User-Agent. You can use default $useragent = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/48.0.2564.116 Safari/537.36'; /** * Grabber rules. * @link https://github.com/fguillot/picoFeed/blob/master/docs/grabber.markdown#how-to-write-a-grabber-rules-file */ $rules_dir = '/storage/rules/'; //here will be saved images $media_dir = '/storage/media/'; //here will be saved content from feeds in JSON db $database_dir = '/storage/database/'; //timezone for posts, you can use default. $timezone = 'UTC'; //Init LocalContent object $lc = new \Rakshazi\LocalContent; //Configure it $lc ->setRulesDir($rules_dir) ->setMediaDir($media_dir) ->setDatabaseDir($database_dir) ->setFeeds($feeds) ->setUserAgent($useragent) ->setTimezone($timezone); //Download content! $lc->download();