From e9885dbf41a12d713463527685d2609c6aa05af6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=A3=9E=E9=A3=9E=E9=B1=BC?= Date: Thu, 15 Jun 2023 15:51:58 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E4=B8=9C=E6=96=B9?= =?UTF-8?q?=E8=B4=A2=E5=AF=8C=E7=BD=91=E8=A1=8C=E4=B8=9A=E7=A0=94=E7=A9=B6?= =?UTF-8?q?=20(#12671)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * feat(route): add 东方财富研究报告 * feat(route): add 东方财富研究报告 * update: 东方财富研究报告文档 * feat(router): add 东方财富研究报告 * feat(router): add 东方财富研究报告 * fix:link add .jshtml suffix * feat(route):add 东方财富网行业研究 * chore: data link --- docs/finance.md | 6 +++--- lib/v2/eastmoney/report/index.js | 32 +++++++++++++++++++++++--------- 2 files changed, 26 insertions(+), 12 deletions(-) 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, }; };