diff --git a/docs/finance.md b/docs/finance.md index 1ba35b041..69ca88423 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -220,6 +220,16 @@ TokenInsight 官方亦有提供 RSS,可参考 +## 法布财经 + +### 新闻 + + + +### 快讯 + + + ## 富途牛牛 ### 要闻 diff --git a/lib/v2/fastbull/express-news.js b/lib/v2/fastbull/express-news.js new file mode 100644 index 000000000..e381dbe57 --- /dev/null +++ b/lib/v2/fastbull/express-news.js @@ -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, + }; +}; diff --git a/lib/v2/fastbull/maintainer.js b/lib/v2/fastbull/maintainer.js new file mode 100644 index 000000000..bfc19847a --- /dev/null +++ b/lib/v2/fastbull/maintainer.js @@ -0,0 +1,5 @@ +module.exports = { + '/express-news': ['nczitzk'], + '/news': ['nczitzk'], + '/': ['nczitzk'], +}; diff --git a/lib/v2/fastbull/news.js b/lib/v2/fastbull/news.js new file mode 100644 index 000000000..597cb2e71 --- /dev/null +++ b/lib/v2/fastbull/news.js @@ -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, + }; +}; diff --git a/lib/v2/fastbull/radar.js b/lib/v2/fastbull/radar.js new file mode 100644 index 000000000..617ec11bf --- /dev/null +++ b/lib/v2/fastbull/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/fastbull/router.js b/lib/v2/fastbull/router.js new file mode 100644 index 000000000..a680adbfc --- /dev/null +++ b/lib/v2/fastbull/router.js @@ -0,0 +1,5 @@ +module.exports = function (router) { + router.get('/express-news', require('./express-news')); + router.get('/news', require('./news')); + router.get('/', require('./news')); +}; diff --git a/lib/v2/fastbull/templates/description.art b/lib/v2/fastbull/templates/description.art new file mode 100644 index 000000000..1458bc071 --- /dev/null +++ b/lib/v2/fastbull/templates/description.art @@ -0,0 +1,7 @@ +{{ if tips }} +摘要: +

{{ tips }}

+{{ /if }} +{{ if description }} +{{@ description }} +{{ /if }} \ No newline at end of file