mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-02 18:18:06 +08:00
fix(route): ft (#11071)
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
module.exports = {
|
||||
'/ft/myft/:key': ['HenryQW'],
|
||||
'/ft/:language/:channel?': ['HenryQW', 'xyqfer'],
|
||||
'/myft/:key': ['HenryQW'],
|
||||
'/:language/:channel?': ['HenryQW', 'xyqfer'],
|
||||
};
|
||||
|
||||
@@ -2,9 +2,9 @@ const got = require('@/utils/got');
|
||||
const parser = require('@/utils/rss-parser');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const ProcessFeed = ($, link) => {
|
||||
const ProcessFeed = (i, $, link) => {
|
||||
const title = $('h1').text();
|
||||
let content = $('div.story-container');
|
||||
let content = $('div.story-container').eq(i);
|
||||
|
||||
// 处理封面图片
|
||||
content.find('div.story-image > figure').each((_, e) => {
|
||||
@@ -59,17 +59,20 @@ const getData = async ({ site = 'www', channel, ctx }) => {
|
||||
}
|
||||
|
||||
const items = await Promise.all(
|
||||
feed.items.splice(0, 10).map((item) => {
|
||||
feed.items.map((item) => {
|
||||
item.link = item.link.replace('http://', 'https://');
|
||||
return ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got.get(`${item.link}?full=y&archive`);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const result = ProcessFeed($, item.link);
|
||||
const results = [];
|
||||
for (let i = 0; i < $('div.story-container').length; i++) {
|
||||
results.push(ProcessFeed(i, $, item.link));
|
||||
}
|
||||
|
||||
item.title = result.title;
|
||||
item.description = result.content;
|
||||
item.author = result.author;
|
||||
item.title = results[0].title;
|
||||
item.description = results.map((result) => result.content).join('');
|
||||
item.author = results[0].author;
|
||||
return item;
|
||||
});
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user