feat(route): add 法布财经 (#10808)
This commit is contained in:
parent
3428f88d76
commit
c9ccdb410b
|
|
@ -220,6 +220,16 @@ TokenInsight 官方亦有提供 RSS,可参考 <https://api.tokeninsight.com/re
|
|||
|
||||
<Route author="zidekuls" example="/eastmoney/ttjj/user/6551094298949188" path="/eastmoney/ttjj/user/:uid" :paramsDesc="['用户id, 可以通过天天基金App分享用户主页到浏览器,在相应的URL中找到']"/>
|
||||
|
||||
## 法布财经
|
||||
|
||||
### 新闻
|
||||
|
||||
<Route author="nczitzk" example="/fastbull/news" path="/fastbull/news"/>
|
||||
|
||||
### 快讯
|
||||
|
||||
<Route author="nczitzk" example="/fastbull/express-news" path="/fastbull/express-news"/>
|
||||
|
||||
## 富途牛牛
|
||||
|
||||
### 要闻
|
||||
|
|
|
|||
|
|
@ -0,0 +1,33 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'https://www.fastbull.cn';
|
||||
const currentUrl = `${rootUrl}/express-news`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const items = $('.news-list')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
|
||||
return {
|
||||
title: item.find('.title_name').text(),
|
||||
pubDate: parseDate(item.attr('data-date')),
|
||||
link: `${rootUrl}${item.find('.title_name').attr('href')}`,
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: '实时财经快讯 - FastBull',
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = {
|
||||
'/express-news': ['nczitzk'],
|
||||
'/news': ['nczitzk'],
|
||||
'/': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,57 @@
|
|||
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,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
module.exports = {
|
||||
'fastbull.cn': {
|
||||
_name: '法布财经',
|
||||
'.': [
|
||||
{
|
||||
title: '新闻',
|
||||
docs: 'https://docs.rsshub.app/finance.html#fa-bu-cai-jing-xin-wen',
|
||||
source: ['/news', '/'],
|
||||
target: '/fastbull/news',
|
||||
},
|
||||
{
|
||||
title: '快讯',
|
||||
docs: 'https://docs.rsshub.app/finance.html#fa-bu-cai-jing-kuai-xun',
|
||||
source: ['/express-news', '/'],
|
||||
target: '/fastbull/express-news',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/express-news', require('./express-news'));
|
||||
router.get('/news', require('./news'));
|
||||
router.get('/', require('./news'));
|
||||
};
|
||||
|
|
@ -0,0 +1,7 @@
|
|||
{{ if tips }}
|
||||
<b>摘要</b>:
|
||||
<p>{{ tips }}</p>
|
||||
{{ /if }}
|
||||
{{ if description }}
|
||||
{{@ description }}
|
||||
{{ /if }}
|
||||
Loading…
Reference in New Issue