RssHub 部署

介紹

RSSHub 是一個(gè)開(kāi)源、簡(jiǎn)單易用、易于擴(kuò)展的 RSS 生成器,可以給任何奇奇怪怪的內(nèi)容生成 RSS 訂閱源。RSSHub 借助于開(kāi)源社區(qū)的力量快速發(fā)展中,目前已適配數(shù)百家網(wǎng)站的上千項(xiàng)內(nèi)容。
https://docs.rsshub.app/
https://docs.rsshub.app/

路由腳本

我其實(shí)對(duì)rss沒(méi)太大興趣,有人有需求我就順便看了下,挺有意思的,直接用郵箱(我用的是Foxmail)訂閱新消息很方便。路由腳本是使用Javascript寫的,我不會(huì),但是照貓畫老虎還是可以的。然后寫了三個(gè)給別人用了。

下面是寫的其中一個(gè) RSS http://loog.xyz:1200/loog_zyc/gggs

const got = require('@/utils/got');
const cheerio = require('cheerio');

async function getNewsDetail(link) {
    const res = await got.get(link);
    const $ = cheerio.load(res.data);
    return {
        author: $('.article .fun span').eq(2).text(),
        description: $('.article .det').html(),
    };
}

module.exports = async (ctx) => {
    const url = 'http://www.haedu.gov.cn/gggs/';
    const response = await got.get(url);
    const $ = cheerio.load(response.data);

    const out = await Promise.all(
        $('.list li')
            .slice(0, 10)
            .map(async (index, item) => {
                item = $(item);
                const link = $(item).find('li a').attr('href');
                const title = $(item).find('li a').text();
                const pubDate = $(item).find('li span').eq(0).text();
                const single = {
                    title,
                    link,
                    pubDate,
                };
                let other = {};
                const cache = await ctx.cache.get(link);
                if (cache) {
                    other = JSON.parse(cache);
                } else {
                    other = await getNewsDetail(link);
                    ctx.cache.set(link, JSON.stringify(other));
                }

                return Promise.resolve(Object.assign({}, single, other));
            })
            .get()
    );

    ctx.state.data = {
        title: '河南省教育廳--公告告示',
        link: url,
        description: '公告告示',
        item: out
           
    };
};

部署方式

我用的手動(dòng)部署,用npm或者yarn啟動(dòng)無(wú)法后臺(tái),最后用了PM2。

?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
【社區(qū)內(nèi)容提示】社區(qū)部分內(nèi)容疑似由AI輔助生成,瀏覽時(shí)請(qǐng)結(jié)合常識(shí)與多方信息審慎甄別。
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。

友情鏈接更多精彩內(nèi)容