mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-15 01:30:33 +08:00
fix(route): 深圳证券交易所最新规则 (#8284)
This commit is contained in:
@@ -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'));
|
||||
|
||||
// 前端艺术家每日整理&&飞冰早报
|
||||
|
||||
@@ -1,45 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = `http://www.szse.cn/lawrules/rule/new/`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('ul.newslist li')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const s = item.find('script').html();
|
||||
return {
|
||||
title: s.match(/var curTitle ='(.*?)';/)[1],
|
||||
link: `http://www.szse.cn/lawrules/rule${s.match(/var curHref = '..(.*?)';/)[1]}`,
|
||||
pubDate: new Date(item.find('span.time').text().trim()).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
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: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
3
lib/v2/szse/maintainer.js
Normal file
3
lib/v2/szse/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = {
|
||||
'/rule': ['nczitzk'],
|
||||
};
|
||||
13
lib/v2/szse/radar.js
Normal file
13
lib/v2/szse/radar.js
Normal file
@@ -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
lib/v2/szse/router.js
Normal file
3
lib/v2/szse/router.js
Normal file
@@ -0,0 +1,3 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/rule', require('./rule'));
|
||||
};
|
||||
51
lib/v2/szse/rule.js
Normal file
51
lib/v2/szse/rule.js
Normal file
@@ -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,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user