flatgreen/rfrance

抓取 R A D I O F R A N C E

v1.3 2024-09-27 12:21 UTC

This package is auto-updated.

Last update: 2024-09-27 12:27:11 UTC


README

PHP 法语广播库。RFrance 是一个用于抓取和解析 r a d i o f r a n c e 的类

先决条件

  • php >= 8.1
  • cUrl 扩展推荐使用

安装

  • 使用包管理器 composer 安装 RFrance。
composer require flatgreen/rfrance
  • 可选:创建一个 'cache' 目录(具有读|写权限),默认情况下,缓存目录位于系统临时目录中。

使用方法

require_once 'vendor/autoload.php';
use Flatgreen\RFrance\RFrance;

实例化类,定义一个 URL 页面

$rf = new RFrance();
// optional in constructor, add a cache directory and cache duration for page, 1 day by default

$rf->extract(URL);
// optional:
// - force extract when rss exist : $force_rss (default: false)
// - set a limit $max_items (default: -1, all items)

读取信息

if (empty($rf->error)){
    $title = $rf->page->title;
    $all_items = $rf->all_items; // array of Item
}

两个输出助手

// RSS 2.0
header("Content-Type: text/xml; charset=UTF-8");
echo $FC->toRss();

// or

// youtube-dl|yt-dlp info.json like
header('Content-Type: application/json; charset=utf-8');
echo $FC->toInfoJson();

备注

不考虑非广播页面。

许可协议

RFrance 采用 MIT 许可协议(MIT)授权。有关更多信息,请参阅许可文件