fix: add descriptions of rules in szes (#5563)
This commit is contained in:
parent
92ab0efacf
commit
29f2e73d70
|
|
@ -1,4 +1,3 @@
|
|||
const url = require('url');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
|
|
@ -16,15 +15,32 @@ module.exports = async (ctx) => {
|
|||
const s = item.find('script').html();
|
||||
return {
|
||||
title: s.match(/var curTitle ='(.*?)';/)[1],
|
||||
link: url.resolve(`http://www.szse.cn/lawrules/rule`, s.match(/var curHref = '..(.*?)';/)[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(
|
||||
async (item) =>
|
||||
await 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: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue