Skip to content

Commit

Permalink
feat(route): mrm (#14311)
Browse files Browse the repository at this point in the history
* feat(route): mrm

* fix: maintainer
  • Loading branch information
TonyRL authored Jan 23, 2024
1 parent 45fe530 commit 542d039
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 0 deletions.
42 changes: 42 additions & 0 deletions lib/v2/mrm/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const { category = 'zonghezixun3' } = ctx.params;
const baseUrl = 'http://www.mrm.com.cn';
const link = `${baseUrl}/${category}.html`;

const { data: response } = await got(link);
const $ = cheerio.load(response);

const list = $('#datalist_wap .li')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('a');
return {
title: a.text().trim(),
link: `${baseUrl}${a.attr('href')}`,
pubDate: parseDate(item.find('.d').text(), 'YYYY.MM.DD'),
};
});

const items = await Promise.all(
list.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const { data } = await got(item.link);
const $ = cheerio.load(data);

item.description = $('.article-cont').html();
return item;
})
)
);

ctx.state.data = {
title: $('head title').text(),
link,
item: items,
};
};
3 changes: 3 additions & 0 deletions lib/v2/mrm/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/:category?': ['TonyRL'],
};
13 changes: 13 additions & 0 deletions lib/v2/mrm/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'mrm.com.cn': {
_name: '华储网',
'.': [
{
title: '通知',
docs: 'https://docs.rsshub.app/finance#hua-chu-wang',
source: ['/:category'],
target: (params) => `/mrm/${params.category.replace('.html', '')}`,
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/mrm/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = (router) => {
router.get('/:category?', require('./index'));
};
10 changes: 10 additions & 0 deletions website/docs/routes/finance.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@ TokenInsight also provides official RSS, you can take a look at [https://api.tok
`http://www.nifd.cn/Research?categoryGuid=7a6a826d-b525-42aa-b550-4236e524227f` 对应 `/nifd/research/7a6a826d-b525-42aa-b550-4236e524227f`
</Route>

## 华储网 {#hua-chu-wang}

### 通知 {#hua-chu-wang-tong-zhi}

<Route author="TonyRL" example="/mrm" path="/mrm/:category?" paramDesc={['分类,见下表,默认为 `zonghezixun3`']} radar="1">
| 交易通知 | 政策规定 | 业务通知 |
| ------------ | -------------------- | ----------------- |
| zonghezixun3 | zhengceguiding\_list | yewutongzhi\_list |
</Route>

## 汇通网 {#hui-tong-wang}

### 7x24 小时快讯 {#hui-tong-wang-7x24-xiao-shi-kuai-xun}
Expand Down

0 comments on commit 542d039

Please sign in to comment.