From 6aa42e2cf1dc22a85e9d1bdc1f2de2d8c5b6707f Mon Sep 17 00:00:00 2001 From: shaomingbo <100058976+shaomingbo@users.noreply.github.com> Date: Sun, 29 Jan 2023 22:13:26 +0800 Subject: [PATCH] feat(route): add route for Ke Research Institute (#11714) * feat(route): add route for Ke Research Institute Signed-off-by: shaomingbo * Update lib/v2/ke/results.js refactor: replace string template to normal string * Update lib/v2/ke/results.js refactor: replace string template to normal string * refactor: docs format Signed-off-by: shaomingbo * Update lib/v2/ke/results.js --------- Signed-off-by: shaomingbo --- docs/other.md | 6 ++++++ lib/v2/ke/maintainer.js | 3 +++ lib/v2/ke/radar.js | 13 +++++++++++++ lib/v2/ke/results.js | 36 ++++++++++++++++++++++++++++++++++++ lib/v2/ke/router.js | 3 +++ 5 files changed, 61 insertions(+) create mode 100644 lib/v2/ke/maintainer.js create mode 100644 lib/v2/ke/radar.js create mode 100644 lib/v2/ke/results.js create mode 100644 lib/v2/ke/router.js diff --git a/docs/other.md b/docs/other.md index c4c0b539e..b612a8da7 100644 --- a/docs/other.md +++ b/docs/other.md @@ -1003,3 +1003,9 @@ type 为 all 时,category 参数不支持 cost 和 free ### はてな匿名ダイアリー - 人気記事アーカイブ + +## 贝壳研究院 + +### 研究成果 + + diff --git a/lib/v2/ke/maintainer.js b/lib/v2/ke/maintainer.js new file mode 100644 index 000000000..f6ffb911e --- /dev/null +++ b/lib/v2/ke/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/researchResults': ['shaomingbo'], +}; diff --git a/lib/v2/ke/radar.js b/lib/v2/ke/radar.js new file mode 100644 index 000000000..37d587ea9 --- /dev/null +++ b/lib/v2/ke/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'research.ke.com': { + _name: '贝壳研究院 - 房地产行业研究报告', + www: [ + { + title: '研究成果', + docs: 'https://docs.rsshub.app/other.html#bei-ke-yan-jiu-yuan', + source: ['/researchResults'], + target: '/researchResults', + }, + ], + }, +}; diff --git a/lib/v2/ke/results.js b/lib/v2/ke/results.js new file mode 100644 index 000000000..779102be6 --- /dev/null +++ b/lib/v2/ke/results.js @@ -0,0 +1,36 @@ +const { parseDate } = require('@/utils/parse-date'); +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'post', + url: 'https://research.ke.com/apis/consumer-access/index/contents/page', + headers: { + Referer: 'https://research.ke.com/ResearchResults', + }, + json: { + pageIndex: 1, + pageSize: 9, + }, + }); + + const { status, statusMessage } = response; + if (status !== 200) { + throw new Error(statusMessage); + } + + const { list } = response.data.data; + + ctx.state.data = { + title: '房地产行业研究报告', + link: 'https://research.ke.com/ResearchResults', + description: '研究成果', + item: list.map((item) => ({ + title: item.title, + link: `https://research.ke.com/${item.contentTypeId}/ArticleDetail?id=${item.id}`, + author: item.author, + description: item.guideReading, + pubDate: parseDate(item.publishTime), + })), + }; +}; diff --git a/lib/v2/ke/router.js b/lib/v2/ke/router.js new file mode 100644 index 000000000..51749f41c --- /dev/null +++ b/lib/v2/ke/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/researchResults', require('./results')); +};