mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 21:18:57 +08:00
feat: add codeceo fulltext (#2648)
* feat: add codeceo fulltext * fix deploy error
This commit is contained in:
54
lib/routes/codeceo/home.js
Normal file
54
lib/routes/codeceo/home.js
Normal file
@@ -0,0 +1,54 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const parser = require('@/utils/rss-parser');
|
||||
const { addNoReferrer } = require('@/utils/common-utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const feed = await parser.parseURL('http://www.codeceo.com/feed');
|
||||
|
||||
const ProcessFeed = async (link) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
addNoReferrer($, '.article-entry');
|
||||
|
||||
$('.article-entry script').remove();
|
||||
$('.article-entry .adsbygoogle')
|
||||
.parent()
|
||||
.remove();
|
||||
|
||||
return $('.article-entry').html();
|
||||
};
|
||||
|
||||
const items = await Promise.all(
|
||||
feed.items.map(async (item) => {
|
||||
const cache = await ctx.cache.get(item.link);
|
||||
if (cache) {
|
||||
return Promise.resolve(JSON.parse(cache));
|
||||
}
|
||||
|
||||
const description = await ProcessFeed(item.link);
|
||||
|
||||
const single = {
|
||||
title: item.title,
|
||||
description,
|
||||
pubDate: item.pubDate,
|
||||
link: item.link,
|
||||
author: item.author,
|
||||
};
|
||||
ctx.cache.set(item.link, JSON.stringify(single));
|
||||
return Promise.resolve(single);
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: feed.title,
|
||||
link: feed.link,
|
||||
description: feed.description,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user