From bf156eb3243a7fb011433378f103faf3be96f5b1 Mon Sep 17 00:00:00 2001 From: yuxinliu-alex Date: Fri, 22 Apr 2022 19:41:23 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20=E6=8A=95=E4=B8=AD=E7=BD=91=20(#?= =?UTF-8?q?9593)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: yuxinliu --- docs/new-media.md | 12 ++++++ lib/v2/chinaventure/index.js | 63 +++++++++++++++++++++++++++++++ lib/v2/chinaventure/maintainer.js | 3 ++ lib/v2/chinaventure/radar.js | 13 +++++++ lib/v2/chinaventure/router.js | 3 ++ 5 files changed, 94 insertions(+) create mode 100644 lib/v2/chinaventure/index.js create mode 100644 lib/v2/chinaventure/maintainer.js create mode 100644 lib/v2/chinaventure/radar.js create mode 100644 lib/v2/chinaventure/router.js diff --git a/docs/new-media.md b/docs/new-media.md index b8d884e85..17ad04645 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -3211,6 +3211,18 @@ column 为 third 时可选的 category: +## 投中网 + +### 分类 + + + +| 推荐 | 商业深度 | 资本市场 | 5G | 健康 | 教育 | 地产 | 金融 | 硬科技 | 新消费 | +| -- | -- | -- | -- | --- | --- | --- | --- | --- | --- | +| | 78 | 80 | 83 | 111 | 110 | 112 | 113 | 114 | 116 | + + + ## 推酷 ### 周刊 diff --git a/lib/v2/chinaventure/index.js b/lib/v2/chinaventure/index.js new file mode 100644 index 000000000..e4b71ba81 --- /dev/null +++ b/lib/v2/chinaventure/index.js @@ -0,0 +1,63 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +const rootUrl = 'https://www.chinaventure.com.cn'; + +const nodes = { + 78: '商业深度', + 80: '资本市场', + 83: '5G', + 111: '健康', + 110: '教育', + 112: '地产', + 113: '金融', + 114: '硬科技', + 116: '新消费', +}; + +module.exports = async (ctx) => { + const id = ctx.params.id; + const currentUrl = rootUrl.concat(id ? `/news/${id}.html` : '/index.html'); + + const response = await got({ + method: 'get', + url: currentUrl, + }); + const $ = cheerio.load(response.data); + const list = $('a', '.common_newslist_pc') + .filter(function () { + return $(this).attr('href'); + }) + .map((_, item) => ({ + link: rootUrl + $(item).attr('href'), + })) + .get() + .slice(0, ctx.query.limit ? (parseInt(ctx.query.limit) > 20 ? 20 : parseInt(ctx.query.limit)) : 20); + + const items = await Promise.all( + list.map((item) => + ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ + method: 'get', + url: item.link, + }); + const content = cheerio.load(detailResponse.data); + item.title = content('h1.maintitle_pc').text(); + item.description = content('div.article_slice_pc').html(); + item.author = content('div.source_author').text(); + item.pubDate = timezone(parseDate(content('div.releaseTime').text()), +8); + return item; + }) + ) + ); + + ctx.state.data = { + title: `${nodes[id] ?? '推荐'}-投中网`, + link: currentUrl, + description: '投中网是国内领先的创新经济信息服务平台,拥有立体化媒体矩阵,十多年行业深耕,为创新经济领域核心人群提供深入、独到的智识和洞见,在私募股权投资行业和创新商业领域均拥有权威影响力。', + language: 'zh-cn', + item: items, + }; +}; diff --git a/lib/v2/chinaventure/maintainer.js b/lib/v2/chinaventure/maintainer.js new file mode 100644 index 000000000..5718be002 --- /dev/null +++ b/lib/v2/chinaventure/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/news/:id?': ['yuxinliu-alex'], +}; diff --git a/lib/v2/chinaventure/radar.js b/lib/v2/chinaventure/radar.js new file mode 100644 index 000000000..064d150ae --- /dev/null +++ b/lib/v2/chinaventure/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'chinaventure.com.cn': { + _name: '投中网', + '.': [ + { + title: '分类', + docs: 'https://docs.rsshub.app/new-media.html#tou-zhong-wang', + source: ['/'], + target: '/chinaventure', + }, + ], + }, +}; diff --git a/lib/v2/chinaventure/router.js b/lib/v2/chinaventure/router.js new file mode 100644 index 000000000..487aaf425 --- /dev/null +++ b/lib/v2/chinaventure/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/news/:id?', require('./index')); +};