feat(route): add 智通财经 (#10961)
* feat(route): add 智通财经 * fix: add vip and telegram digest
This commit is contained in:
parent
596ab12da9
commit
627ce33803
|
|
@ -627,6 +627,31 @@ TokenInsight 官方亦有提供 RSS,可参考 <https://api.tokeninsight.com/re
|
|||
|
||||
</Route>
|
||||
|
||||
## 智通财经网
|
||||
|
||||
### 推荐
|
||||
|
||||
<Route author="nczitzk" example="/zhitongcaijing" path="/zhitongcaijing/:id?/:category?" :paramsDesc="['栏目 id,可在对应栏目页 URL 中找到,默认为 recommend,即推荐', '分类 id,可在对应栏目子分类页 URL 中找到,默认为全部']">
|
||||
|
||||
| id | 栏目 |
|
||||
| ------------ | --- |
|
||||
| recommend | 推荐 |
|
||||
| hkstock | 港股 |
|
||||
| meigu | 美股 |
|
||||
| agu | 沪深 |
|
||||
| ct | 创投 |
|
||||
| esg | ESG |
|
||||
| aqs | 券商 |
|
||||
| ajj | 基金 |
|
||||
| focus | 要闻 |
|
||||
| announcement | 公告 |
|
||||
| research | 研究 |
|
||||
| shares | 新股 |
|
||||
| bazaar | 市场 |
|
||||
| company | 公司 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 中国人民银行
|
||||
|
||||
### 沟通交流
|
||||
|
|
|
|||
|
|
@ -0,0 +1,118 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { art } = require('@/utils/render');
|
||||
const path = require('path');
|
||||
|
||||
const ids = {
|
||||
recommend: {
|
||||
url: 'content/recommend',
|
||||
title: '推荐',
|
||||
},
|
||||
hkstock: {
|
||||
url: 'content/hkstock',
|
||||
title: '港股',
|
||||
},
|
||||
meigu: {
|
||||
url: 'content/meigu',
|
||||
title: '美股',
|
||||
},
|
||||
agu: {
|
||||
url: 'content/agu',
|
||||
title: '沪深',
|
||||
},
|
||||
ct: {
|
||||
url: 'content/ct',
|
||||
title: '创投',
|
||||
},
|
||||
esg: {
|
||||
url: 'content/esg',
|
||||
title: 'ESG',
|
||||
},
|
||||
aqs: {
|
||||
url: 'content/aqs',
|
||||
title: '券商',
|
||||
},
|
||||
ajj: {
|
||||
url: 'content/ajj',
|
||||
title: '基金',
|
||||
},
|
||||
focus: {
|
||||
url: 'focus',
|
||||
title: '要闻',
|
||||
},
|
||||
announcement: {
|
||||
url: 'announcement',
|
||||
title: '公告',
|
||||
},
|
||||
research: {
|
||||
url: 'research',
|
||||
title: '研究',
|
||||
},
|
||||
shares: {
|
||||
url: 'shares',
|
||||
title: '新股',
|
||||
},
|
||||
bazaar: {
|
||||
url: 'bazaar',
|
||||
title: '市场',
|
||||
},
|
||||
company: {
|
||||
url: 'company',
|
||||
title: '公司',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id ?? 'recommend';
|
||||
const category = ctx.params.category ?? '';
|
||||
|
||||
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 20;
|
||||
|
||||
const rootUrl = 'https://www.zhitongcaijing.com';
|
||||
const currentUrl = `${rootUrl}/${ids[id].url}.html${category === '' ? '' : `?category_key=${category}`}`;
|
||||
const apiUrl = `${rootUrl}/${ids[id].url}.html?data_type=1&page=1${category === '' ? '' : `&category_key=${category}`}`;
|
||||
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: apiUrl,
|
||||
});
|
||||
|
||||
let items = response.data.data.slice(0, limit).map((item) => ({
|
||||
title: item.title,
|
||||
link: `${rootUrl}${item.url}`,
|
||||
description: item.digest,
|
||||
author: item.author_info.author_name,
|
||||
pubDate: parseDate((item.create_time ?? parseInt(item.original_time)) * 1000),
|
||||
category: (item.keywords?.split(',') ?? []).concat([item.category_name ?? item.type_tag]),
|
||||
}));
|
||||
|
||||
items = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
content('#subscribe-vip-box').remove();
|
||||
content('#news-content').remove();
|
||||
|
||||
item.description = art(path.join(__dirname, 'templates/description.art'), {
|
||||
digest: content('.digetst-box').html() || content('.telegram-origin-contentn').html(),
|
||||
description: content('.news-body-content').html(),
|
||||
});
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `智通财经 - ${ids[id].title}`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:id?/:category?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,17 @@
|
|||
module.exports = {
|
||||
'zhitongcaijing.com': {
|
||||
_name: '智通财经',
|
||||
'.': [
|
||||
{
|
||||
title: '资讯',
|
||||
docs: 'https://docs.rsshub.app/finance.html#zhi-tong-cai-jing-zi-xun',
|
||||
source: ['/:category', '/'],
|
||||
target: (params, url) => {
|
||||
const id = new URL(url).toString().match(/\/(\w+)\.html/)[1];
|
||||
const category = new URL(url).searchParams.get('category_key');
|
||||
return `/zhitongcaijing/${id}${category ? `/${category}` : ''}`;
|
||||
},
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/:id?/:category?', require('./index'));
|
||||
};
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
{{ if digest }}
|
||||
{{@ digest }}
|
||||
{{ /if }}
|
||||
{{ if description }}
|
||||
{{@ description }}
|
||||
{{ /if }}
|
||||
Loading…
Reference in New Issue