From 7342326a2a91583a6bf048db2f2acae43211ba2b Mon Sep 17 00:00:00 2001 From: Ethan Shen <42264778+nczitzk@users.noreply.github.com> Date: Sat, 27 Aug 2022 20:32:55 +0800 Subject: [PATCH] =?UTF-8?q?feat(route):=20add=20=E8=89=BE=E7=91=9E?= =?UTF-8?q?=E5=92=A8=E8=AF=A2=E5=91=A8=E5=BA=A6=E5=B8=82=E5=9C=BA=E8=A7=82?= =?UTF-8?q?=E5=AF=9F=20(#10626)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/other.md | 9 +++++++ lib/v2/iresearch/maintainer.js | 1 + lib/v2/iresearch/radar.js | 8 +++++- lib/v2/iresearch/router.js | 1 + lib/v2/iresearch/templates/weekly.art | 11 ++++++++ lib/v2/iresearch/weekly.js | 39 +++++++++++++++++++++++++++ 6 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 lib/v2/iresearch/templates/weekly.art create mode 100644 lib/v2/iresearch/weekly.js diff --git a/docs/other.md b/docs/other.md index 9eb8c156d..2a868d5d9 100644 --- a/docs/other.md +++ b/docs/other.md @@ -334,6 +334,15 @@ type 为 all 时,category 参数不支持 cost 和 free +### 周度市场观察 + + + +| 家电行业 | 服装行业 | 美妆行业 | 食品饮料行业 | +| ---- | ---- | ---- | ------ | + + + ## 爱 Q 生活网 ### 最近更新 diff --git a/lib/v2/iresearch/maintainer.js b/lib/v2/iresearch/maintainer.js index 407334da1..d743147c3 100644 --- a/lib/v2/iresearch/maintainer.js +++ b/lib/v2/iresearch/maintainer.js @@ -1,3 +1,4 @@ module.exports = { '/report': ['brilon', 'Fatpandac'], + '/weekly/:category?': ['nczitzk'], }; diff --git a/lib/v2/iresearch/radar.js b/lib/v2/iresearch/radar.js index e96a6e00d..aebb77f0e 100644 --- a/lib/v2/iresearch/radar.js +++ b/lib/v2/iresearch/radar.js @@ -4,10 +4,16 @@ module.exports = { www: [ { title: '研究报告', - docs: 'https://docs.rsshub.app/journal.html#ieee-xplore', + docs: 'https://docs.rsshub.app/other.html#ai-rui-chan-ye-yan-jiu-bao-gao', source: ['/report.shtml'], target: '/iresearch/report', }, + { + title: '周度市场观察', + docs: 'https://docs.rsshub.app/other.html#ai-rui-zhou-du-shi-chang-guan-cha', + source: ['/report.shtml?type=3', ''], + target: '/iresearch/weekly/:category', + }, ], }, }; diff --git a/lib/v2/iresearch/router.js b/lib/v2/iresearch/router.js index a7bfc0bbd..d2fdad0df 100644 --- a/lib/v2/iresearch/router.js +++ b/lib/v2/iresearch/router.js @@ -1,3 +1,4 @@ module.exports = function (router) { router.get('/report', require('./report')); + router.get('/weekly/:category?', require('./weekly')); }; diff --git a/lib/v2/iresearch/templates/weekly.art b/lib/v2/iresearch/templates/weekly.art new file mode 100644 index 000000000..ccf67d2b4 --- /dev/null +++ b/lib/v2/iresearch/templates/weekly.art @@ -0,0 +1,11 @@ +{{ if cover }} +{{ content }}

+{{ /if }} +{{ if pages }} +<% for (let i = 1; i <= pages; i++){ %> + +<% } %> +{{ /if }} \ No newline at end of file diff --git a/lib/v2/iresearch/weekly.js b/lib/v2/iresearch/weekly.js new file mode 100644 index 000000000..f0d516b4a --- /dev/null +++ b/lib/v2/iresearch/weekly.js @@ -0,0 +1,39 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const { art } = require('@/utils/render'); +const path = require('path'); + +module.exports = async (ctx) => { + const category = ctx.params.category ?? ''; + + const rootUrl = 'https://www.iresearch.com.cn'; + const currentUrl = `${rootUrl}/report.shtml?type=4`; + const apiUrl = `${rootUrl}/api/json/report/ireport.json`; + + const response = await got({ + method: 'get', + url: apiUrl, + }); + + const items = JSON.parse(response.data.slice(1)) + .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 200) + .filter((item) => (category ? item.classname === category : true)) + .map((item) => ({ + title: item.reportname, + pubDate: parseDate(item.addtime), + link: `${rootUrl}/report/detail?id=${item.id}`, + category: [item.classname].concat(item.keywords.split(',')), + description: art(path.join(__dirname, 'templates/weekly.art'), { + id: item.id, + cover: item.reportpic, + content: item.shortcoutent, + pages: item.PagesCount, + }), + })); + + ctx.state.data = { + title: '艾瑞咨询 - 周度市场观察', + link: currentUrl, + item: items, + }; +};