GithubHelp home page GithubHelp logo

samons / rsshub-1 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ilay1678/rsshub

0.0 1.0 0.0 19 KB

Modified from RSSHub for PHPers.

Home Page: https://ifking.cn/p/276.html

License: MIT License

PHP 91.57% HTML 8.43%

rsshub-1's Introduction

RSSHub

RSSHub PHP Ver.

🍰 万物皆可 RSS

介绍

RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇怪怪的内容生成 RSS 订阅源

这是在PHP 版本的基础上修改而来的

修改内容: 增加通用参数 增加domcrawler组件支持,移除FeedWriter 重写rss生成方法 未定义路由将从原本rsshub获取

插件列表 Plugins.md

明知道开了坑也没生态但还要开的是不是应该叫傻子呢 (小声

参与我们

如果有任何想法或需求,可以在 issue 中告诉我们,同时我们欢迎各种 pull requests

提交新的 RSS 内容

  1. /plugins/ 里添加对应分类 (若不存在)

  2. /plugins/分类名 中添加获取 RSS 内容的脚本

  3. 更新文档: /Plugins.md

插件格式

基本

可参考 /plugins/example/example.php 范例插件

每个类的命名空间为 RSSHub\Plugins\分类名

属性

每个类都需要定义公开属性 $_info , 其中包括 routes 路由表, 如下

public $_info = [
        'routes' => [
            'test/:input1/:input2' => 'input',
        ],
    ];
  • test/:input1/:input2 代表在该插件分类中(example), 定义名为 test 的路由, 输入参数为 input1input2
  • input 代表处理该条请求的函数方法为 input 注意:该方法必须为静态方法且在该类中
  • 最终访问地址: https://xx.xx/分类名/test/input-value1/input-value2

内置方法

生成rss方式:返回以下数组,系统会自动根据数组内容格式化生成rss

  • 数组包含 title description image 以及 items
    • image 又包含 url src 以及 title , 该参数若不需要可直接忽略
    • items 是内容数组 , 格式如下
      • title 标题
      • link URL 链接
      • date 时间戳 (可选)
      • description 内容

RSSHub\Lib\Cache::getCache($md5,$func) 用于获取或新增缓存内容

  • 输入参数
    • $md5 : 唯一 id ,用于区分缓存内容
    • $func : callable 类型, 传递获取缓存内容的函数方法,无参数
  • 缓存时间: 默认 5 分钟
  • 使用方法: 如下
use RSSHub\Lib\Cache;
$data = Cache::getCache($md5,function () use ($var1)
        {
            $curl = new Curl();
            $curl->setOpt(CURLOPT_SSL_VERIFYPEER,0);
            $curl->setOpt(CURLOPT_SSL_VERIFYHOST,0);
            $data = json_decode(json_encode($curl->get("https://xx.xx/{$var1}")),true);
            return $data;
        });

Curl\Curl CURL 方法,本质为 php-curl-class/php-curl-class

错误处理

若在处理过程中遇到错误,直接抛出 RSSHub\Lib\Exception 异常即可,第一位输入参数为消息,第二位为等级(可选 warning 以及 error)

输出时会自动添加 XML header, 请勿重复添加

部署

  1. git clone https://github.com/iLay1678/RSSHub.git
  2. composer install
  3. 设置运行目录为 public
  4. 配置伪静态规则 (nginx 规则如下)
    if (!-e $request_filename) {
        rewrite ^(.*)$ /index.php?s=$1 last;
    }

Demo

演示站,可随意使用

rsshub-1's People

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.