diff --git a/lib/v2/theblockbeats/index.js b/lib/v2/theblockbeats/index.js new file mode 100644 index 0000000000..371c9327f7 --- /dev/null +++ b/lib/v2/theblockbeats/index.js @@ -0,0 +1,53 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const domain = 'theblockbeats.info'; +const rootUrl = `https://www.${domain}`; +const apiBase = `https://api.${domain}`; + +const channelMap = { + newsflash: { + title: '快讯', + link: `${rootUrl}/newsflash`, + api: `${apiBase}/v5/newsflash/select`, + }, + article: { + title: '文章', + link: `${rootUrl}/article`, + api: `${apiBase}/v5/Information/newsall`, + }, +}; + +module.exports = async (ctx) => { + const { channel = 'newsflash' } = ctx.params; + + const { data: response } = await got(channelMap[channel].api); + + const { data } = channel === 'newsflash' ? response.data : response; + let list = data.map((item) => ({ + title: item.title, + link: `${rootUrl}/${channel === 'newsflash' ? 'flash' : 'news'}/${item.id}`, + description: item.content ?? item.im_abstract, + pubDate: parseDate(item.add_time, 'X'), + })); + + if (channel !== 'newsflash') { + list = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: response } = await got(item.link); + const $ = cheerio.load(response); + item.description = $('div.news-content').html(); + return item; + }) + ) + ); + } + + ctx.state.data = { + title: `TheBlockBeats - ${channelMap[channel].title}`, + link: channelMap[channel].link, + item: list, + }; +}; diff --git a/lib/v2/theblockbeats/maintainer.js b/lib/v2/theblockbeats/maintainer.js new file mode 100644 index 0000000000..76c0d21495 --- /dev/null +++ b/lib/v2/theblockbeats/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:channel?': ['Fatpandac', 'jameshih'], +}; diff --git a/lib/v2/theblockbeats/radar.js b/lib/v2/theblockbeats/radar.js new file mode 100644 index 0000000000..c62887f263 --- /dev/null +++ b/lib/v2/theblockbeats/radar.js @@ -0,0 +1,19 @@ +module.exports = { + 'theblockbeats.info': { + _name: '律动', + rszhaopin: [ + { + title: '快讯', + docs: 'https://docs.rsshub.app/routes/finance#lv-dong', + source: ['/'], + target: '/theblockbeats/newsflash', + }, + { + title: '文章', + docs: 'https://docs.rsshub.app/routes/finance#lv-dong', + source: ['/'], + target: '/theblockbeats/article', + }, + ], + }, +}; diff --git a/lib/v2/theblockbeats/router.js b/lib/v2/theblockbeats/router.js new file mode 100644 index 0000000000..cf61ea5c7f --- /dev/null +++ b/lib/v2/theblockbeats/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/:channel?', require('./index')); +}; diff --git a/website/docs/routes/finance.mdx b/website/docs/routes/finance.mdx index 660fde0dc4..14dc2a2d3e 100644 --- a/website/docs/routes/finance.mdx +++ b/website/docs/routes/finance.mdx @@ -481,6 +481,16 @@ TokenInsight also provides official RSS, you can take a look at [https://api.tok +## 律动 {#lv-dong} + +### 新闻快讯 {#lv-dong-xin-wen-kuai-xun} + + + | 快讯 | 文章 | + | :-------: | :-----: | + | newsflash | article | + + ## 麦肯锡 {#mai-ken-xi} ### 洞见 {#mai-ken-xi-dong-jian}