Skip to content

Commit

Permalink
fix(route): 深圳证券交易所最新规则 (#8284)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ethan Shen authored Nov 27, 2021
1 parent 62d0e09 commit 713253b
Show file tree
Hide file tree
Showing 6 changed files with 70 additions and 46 deletions.
1 change: 0 additions & 1 deletion lib/router.js
Original file line number Diff line number Diff line change
Expand Up @@ -2166,7 +2166,6 @@ router.get('/sse/disclosure/:query?', lazyloadRouteHandler('./routes/sse/disclos
// 深圳证券交易所
router.get('/szse/notice', lazyloadRouteHandler('./routes/szse/notice'));
router.get('/szse/inquire/:type', lazyloadRouteHandler('./routes/szse/inquire'));
router.get('/szse/rule', lazyloadRouteHandler('./routes/szse/rule'));
router.get('/szse/projectdynamic/:type?/:stage?/:status?', lazyloadRouteHandler('./routes/szse/projectdynamic'));

// 前端艺术家每日整理&&飞冰早报
Expand Down
45 changes: 0 additions & 45 deletions lib/routes/szse/rule.js

This file was deleted.

3 changes: 3 additions & 0 deletions lib/v2/szse/maintainer.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
'/rule': ['nczitzk'],
};
13 changes: 13 additions & 0 deletions lib/v2/szse/radar.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
module.exports = {
'szse.cn': {
_name: '深圳证券交易所',
'.': [
{
title: '最新规则',
docs: 'https://docs.rsshub.app/other.html#shen-zhen-zheng-quan-jiao-yi-suo-zui-xin-gui-ze',
source: ['/lawrules/rule/new', '/'],
target: '/szse/rule',
},
],
},
};
3 changes: 3 additions & 0 deletions lib/v2/szse/router.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/rule', require('./rule'));
};
51 changes: 51 additions & 0 deletions lib/v2/szse/rule.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');

module.exports = async (ctx) => {
const rootUrl = 'http://www.szse.cn';
const currentUrl = `${rootUrl}/api/search/content`;

const response = await got({
method: 'post',
url: currentUrl,
form: {
keyword: '',
time: 0,
range: 'title',
'channelCode[]': 'szserulesAllRulesBuss',
currentPage: 1,
pageSize: 30,
scope: 0,
},
});

const list = response.data.data.map((item) => ({
title: item.doctitle,
link: item.docpuburl,
pubDate: parseDate(item.docpubtime),
}));

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.description = content('#desContent').html();

return item;
})
)
);

ctx.state.data = {
title: '最新规则 - 深圳证券交易所',
link: `${rootUrl}/lawrules/rule/new`,
item: items,
};
};

0 comments on commit 713253b

Please sign in to comment.