feat(route): add 东方财富网行业研究 (#12671)
* feat(route): add 东方财富研究报告 * feat(route): add 东方财富研究报告 * update: 东方财富研究报告文档 * feat(router): add 东方财富研究报告 * feat(router): add 东方财富研究报告 * fix:link add .jshtml suffix * feat(route):add 东方财富网行业研究 * chore: data link
This commit is contained in:
parent
5f9e6dc6be
commit
e9885dbf41
|
|
@ -302,9 +302,9 @@ TokenInsight 官方亦有提供 RSS,可参考 <https://api.tokeninsight.com/re
|
|||
|
||||
<Route author="syzq" example="/eastmoney/report/strategyreport" path="/eastmoney/report/:category" :paramsDesc="['研报类型']">
|
||||
|
||||
| 策略报告 | 宏观研究 | 券商晨报 |
|
||||
| -------------- | ----------- | ------------ |
|
||||
| strategyreport | macresearch | brokerreport |
|
||||
| 策略报告 | 宏观研究 | 券商晨报 | 行业研究 |
|
||||
| -------------- | ----------- | ------------ | -------- |
|
||||
| strategyreport | macresearch | brokerreport | industry |
|
||||
|
||||
</Route>
|
||||
|
||||
|
|
|
|||
|
|
@ -7,14 +7,16 @@ module.exports = async (ctx) => {
|
|||
const { category = 'strategyreport' } = ctx.params;
|
||||
|
||||
const reportType = {
|
||||
strategyreport: '策略报告',
|
||||
macresearch: '宏观研究',
|
||||
brokerreport: '券商晨报',
|
||||
industry: '行业研报',
|
||||
macresearch: '宏观研究',
|
||||
strategyreport: '策略报告',
|
||||
};
|
||||
const linkType = {
|
||||
strategyreport: 'zw_strategy',
|
||||
macresearch: 'zw_macresearch',
|
||||
brokerreport: 'zw_brokerreport',
|
||||
industry: 'zw_industry',
|
||||
macresearch: 'zw_macresearch',
|
||||
strategyreport: 'zw_strategy',
|
||||
};
|
||||
|
||||
const res = await got(`${baseUrl}/report/${category}`);
|
||||
|
|
@ -23,19 +25,31 @@ module.exports = async (ctx) => {
|
|||
const initData = JSON.parse(
|
||||
$('script')
|
||||
.text()
|
||||
.match(/var initdata = (.*?);/)[1]
|
||||
.match(/var initdata(.=?)(.*?);/)[2]
|
||||
);
|
||||
|
||||
const list = initData.data.map((item) => ({
|
||||
title: `【${item.orgSName}】- ${item.title}`,
|
||||
title: `[${item.orgSName}]${item.title}`,
|
||||
link: `${baseUrl}/report/${linkType[category]}.jshtml?encodeUrl=${item.encodeUrl}`,
|
||||
pubDate: parseDate(item.publishDate),
|
||||
author: Array.isArray(item.author) ? item.author.join('') : '',
|
||||
author: item.researcher,
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
item.link = $('.pdf-link').attr('href');
|
||||
item.description = $('.ctx-content').text();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `东方财富网 - ${reportType[category]}`,
|
||||
title: `东方财富网-${reportType[category]}`,
|
||||
link: baseUrl,
|
||||
item: list,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue