mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
Merge pull request #6588 from lonelykid/caixin
feat: add fulltext to the article route of caixin
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
@@ -12,15 +13,33 @@ module.exports = async (ctx) => {
|
||||
|
||||
const data = response.data.data.list;
|
||||
|
||||
const items = await Promise.all(
|
||||
data.map(async (item) => {
|
||||
const link = item.web_url;
|
||||
const summary = `<blockquote><p>${item.summary}</p></blockquote><img src="${item.pics}">`;
|
||||
|
||||
const fullText = await ctx.cache.tryGet(link, async () => {
|
||||
const result = await got.get(link);
|
||||
|
||||
const $ = cheerio.load(result.data);
|
||||
|
||||
return $('#Main_Content_Val').html();
|
||||
});
|
||||
|
||||
return {
|
||||
title: item.title,
|
||||
description: fullText ? summary + fullText : summary,
|
||||
link: link,
|
||||
pubDate: new Date(item.time * 1000),
|
||||
author: item.author_name,
|
||||
};
|
||||
})
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `财新网 - 首页`,
|
||||
link: `http://www.caixin.com/`,
|
||||
description: '财新网 - 首页',
|
||||
item: data.map((item) => ({
|
||||
title: item.title,
|
||||
description: `<p>${item.summary}</p><img src="${item.pics}">`,
|
||||
link: item.web_url,
|
||||
pubDate: new Date(item.time * 1000),
|
||||
})),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user