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