mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
feat: 增加 福利资源 - met.red (#2059)
This commit is contained in:
@@ -505,6 +505,10 @@ type 为 all 时,category 参数不支持 cost 和 free
|
|||||||
|
|
||||||
<Route name="马良行" author="junfengP" example="/mlhang" path="/mlhang" />
|
<Route name="马良行" author="junfengP" example="/mlhang" path="/mlhang" />
|
||||||
|
|
||||||
|
## 福利资源-met.red
|
||||||
|
|
||||||
|
<Route name="福利资源-met.red" author="junfengP" example="/metred/fuli" path="/metred/fuli" />
|
||||||
|
|
||||||
## 毕马威
|
## 毕马威
|
||||||
|
|
||||||
<Route name="洞察" author="LogicJake" example="/kpmg/insights" path="/kpmg/insights" />
|
<Route name="洞察" author="LogicJake" example="/kpmg/insights" path="/kpmg/insights" />
|
||||||
|
|||||||
@@ -1297,6 +1297,9 @@ router.get('/mlhang', require('./routes/mlhang/latest'));
|
|||||||
// PlayStation Store
|
// PlayStation Store
|
||||||
router.get('/ps/list/:gridName', require('./routes/ps/list'));
|
router.get('/ps/list/:gridName', require('./routes/ps/list'));
|
||||||
|
|
||||||
|
// 福利资源-met.red
|
||||||
|
router.get('/metred/fuli', require('./routes/metred/fuli'));
|
||||||
|
|
||||||
// MIT
|
// MIT
|
||||||
router.get('/mit/graduateadmissions/:type/:name', require('./routes/universities/mit/graduateadmissions'));
|
router.get('/mit/graduateadmissions/:type/:name', require('./routes/universities/mit/graduateadmissions'));
|
||||||
|
|
||||||
|
|||||||
56
lib/routes/metred/fuli.js
Normal file
56
lib/routes/metred/fuli.js
Normal file
@@ -0,0 +1,56 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const host = 'https://met.red';
|
||||||
|
const mainPage = 'https://met.red/h/weal/list#';
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
async function load(link, ctx) {
|
||||||
|
const cache = await ctx.cache.get(link);
|
||||||
|
if (cache) {
|
||||||
|
return cache;
|
||||||
|
}
|
||||||
|
const response = await axios.get(link);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
const images = $('img');
|
||||||
|
for (let k = 0; k < images.length; k++) {
|
||||||
|
$(images[k]).replaceWith(`<img src="${url.resolve(host, $(images[k]).attr('src'))}" referrerpolicy="no-referrer" />`);
|
||||||
|
}
|
||||||
|
const couponUrl = $('.layui-btn.layui-btn.layui-btn-lg').attr('href');
|
||||||
|
let eventHtml;
|
||||||
|
if (!couponUrl || couponUrl === undefined) {
|
||||||
|
eventHtml = '<div><p>活动链接:无</p></div>';
|
||||||
|
} else {
|
||||||
|
eventHtml = `<div><a href="${couponUrl}">点我前往活动</a></div>`;
|
||||||
|
}
|
||||||
|
const description = eventHtml + $('.p-detail-html').html();
|
||||||
|
await ctx.cache.set(link, description);
|
||||||
|
return { description };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const response = await axios({
|
||||||
|
method: 'get',
|
||||||
|
url: mainPage,
|
||||||
|
});
|
||||||
|
const data = response.data;
|
||||||
|
const $ = cheerio.load(data);
|
||||||
|
const list = $('h4 > a').get();
|
||||||
|
const process = await Promise.all(
|
||||||
|
list.map(async (item) => {
|
||||||
|
const itemUrl = host + $(item).attr('href');
|
||||||
|
const single = {
|
||||||
|
title: $(item).text(),
|
||||||
|
link: itemUrl,
|
||||||
|
guid: itemUrl,
|
||||||
|
};
|
||||||
|
const other = await load(itemUrl, ctx);
|
||||||
|
return Promise.resolve(Object.assign({}, single, other));
|
||||||
|
})
|
||||||
|
);
|
||||||
|
ctx.state.data = {
|
||||||
|
title: '福利资源-met.red',
|
||||||
|
link: mainPage,
|
||||||
|
description: '福利资源更新提醒',
|
||||||
|
item: process,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user