feat(route): 投中网 (#9593)

Co-authored-by: yuxinliu <yuxin2@mgtv.com>
This commit is contained in:
yuxinliu-alex
2022-04-22 19:41:23 +08:00
committed by GitHub
parent fa3428f8fc
commit bf156eb324
5 changed files with 94 additions and 0 deletions
+12
View File
@@ -3211,6 +3211,18 @@ column 为 third 时可选的 category:
</Route>
## 投中网
### 分类
<Route author="yunxinliu-alex" example="/chinaventure/news/78" path="/chinaventure/news/:id?" :paramsDesc="['分类,见下表,默认为推荐']">
| 推荐 | 商业深度 | 资本市场 | 5G | 健康 | 教育 | 地产 | 金融 | 硬科技 | 新消费 |
| -- | -- | -- | -- | --- | --- | --- | --- | --- | --- |
| | 78 | 80 | 83 | 111 | 110 | 112 | 113 | 114 | 116 |
</Route>
## 推酷
### 周刊
+63
View File
@@ -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,
};
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = {
'/news/:id?': ['yuxinliu-alex'],
};
+13
View File
@@ -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',
},
],
},
};
+3
View File
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/news/:id?', require('./index'));
};