介紹
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。