diff --git a/docs/finance.md b/docs/finance.md index 4d337d47b..f894967fa 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -302,9 +302,9 @@ TokenInsight 官方亦有提供 RSS,可参考 -| 策略报告 | 宏观研究 | 券商晨报 | -| -------------- | ----------- | ------------ | -| strategyreport | macresearch | brokerreport | +| 策略报告 | 宏观研究 | 券商晨报 | 行业研究 | +| -------------- | ----------- | ------------ | -------- | +| strategyreport | macresearch | brokerreport | industry | diff --git a/lib/v2/eastmoney/report/index.js b/lib/v2/eastmoney/report/index.js index fcfd2bb2e..76b244f0c 100644 --- a/lib/v2/eastmoney/report/index.js +++ b/lib/v2/eastmoney/report/index.js @@ -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, }; };