From 2f01aa6819c673fc18424c0d79cf7f16d2295810 Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Tue, 8 Mar 2022 21:52:16 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20BigQuant=E4=B8=93=E9=A2=98?= =?UTF-8?q?=E6=8A=A5=E5=91=8A=20(#9253)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/finance.md | 6 ++++++ lib/v2/bigquant/collections.js | 35 ++++++++++++++++++++++++++++++++++ lib/v2/bigquant/maintainer.js | 3 +++ lib/v2/bigquant/radar.js | 13 +++++++++++++ lib/v2/bigquant/router.js | 3 +++ 5 files changed, 60 insertions(+) create mode 100644 lib/v2/bigquant/collections.js create mode 100644 lib/v2/bigquant/maintainer.js create mode 100644 lib/v2/bigquant/radar.js create mode 100644 lib/v2/bigquant/router.js diff --git a/docs/finance.md b/docs/finance.md index e0442b6e1..214875a82 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -4,6 +4,12 @@ pageClass: routes # 金融 +## BigQuant + +### 专题报告 + + + ## CFD ### 每周股指派息调整 (GBP) diff --git a/lib/v2/bigquant/collections.js b/lib/v2/bigquant/collections.js new file mode 100644 index 000000000..41b1cb4d5 --- /dev/null +++ b/lib/v2/bigquant/collections.js @@ -0,0 +1,35 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const md = require('markdown-it')({ + html: true, +}); + +module.exports = async (ctx) => { + const rootUrl = 'https://bigquant.com'; + const currentUrl = `${rootUrl}/wiki/api/documents.list`; + + const response = await got({ + method: 'post', + url: currentUrl, + json: { + collectionId: 'c6874e5d-7f45-4e90-8cd9-5e43df3b44ef', + direction: 'DESC', + limit: 25, + offset: 0, + sort: 'publishedAt', + }, + }); + + const items = response.data.data.map((item) => ({ + title: item.title, + link: `${rootUrl}/wiki${item.url}`, + description: md.render(item.text), + pubDate: parseDate(item.publishedAt), + })); + + ctx.state.data = { + title: '专题报告 - AI量化知识库 - BigQuant', + link: `${rootUrl}/wiki/collections/c6874e5d-7f45-4e90-8cd9-5e43df3b44ef`, + item: items, + }; +}; diff --git a/lib/v2/bigquant/maintainer.js b/lib/v2/bigquant/maintainer.js new file mode 100644 index 000000000..ddde22489 --- /dev/null +++ b/lib/v2/bigquant/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/collections': ['nczitzk'], +}; diff --git a/lib/v2/bigquant/radar.js b/lib/v2/bigquant/radar.js new file mode 100644 index 000000000..947c8dee3 --- /dev/null +++ b/lib/v2/bigquant/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'bigquant.com': { + _name: 'BigQuant', + '.': [ + { + title: '专题报告', + docs: 'https://docs.rsshub.app/finance.html#bigquant-zhuan-ti-bao-gao', + source: '/', + target: '/bigquant/collections', + }, + ], + }, +}; diff --git a/lib/v2/bigquant/router.js b/lib/v2/bigquant/router.js new file mode 100644 index 000000000..e7f1bd46d --- /dev/null +++ b/lib/v2/bigquant/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/collections', require('./collections')); +};