mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-10 23:34:38 +08:00
58 lines
1.6 KiB
JavaScript
58 lines
1.6 KiB
JavaScript
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
const { art } = require('@/utils/render');
|
|
const path = require('path');
|
|
|
|
module.exports = async (ctx) => {
|
|
const rootUrl = 'https://www.fastbull.cn';
|
|
const currentUrl = `${rootUrl}/news`;
|
|
|
|
const response = await got({
|
|
method: 'get',
|
|
url: currentUrl,
|
|
});
|
|
|
|
const $ = cheerio.load(response.data);
|
|
|
|
let items = $('.trending_type')
|
|
.toArray()
|
|
.map((item) => {
|
|
item = $(item);
|
|
|
|
return {
|
|
title: item.find('.title').text(),
|
|
link: `${rootUrl}${item.attr('href')}`,
|
|
author: item.find('.resource').text(),
|
|
pubDate: parseDate(item.find('.new_time').attr('data-date')),
|
|
description: item.find('.tips').text(),
|
|
};
|
|
});
|
|
|
|
items = await Promise.all(
|
|
items.map((item) =>
|
|
ctx.cache.tryGet(item.link, async () => {
|
|
const detailResponse = await got({
|
|
method: 'get',
|
|
url: item.link,
|
|
});
|
|
|
|
const content = cheerio.load(detailResponse.data);
|
|
|
|
item.description = art(path.join(__dirname, 'templates/description.art'), {
|
|
tips: item.description,
|
|
description: content('.news-detail-content').html(),
|
|
});
|
|
|
|
return item;
|
|
})
|
|
)
|
|
);
|
|
|
|
ctx.state.data = {
|
|
title: '财经头条、财经新闻、最新资讯 - FastBull',
|
|
link: currentUrl,
|
|
item: items,
|
|
};
|
|
};
|