From eb0ec1525f3f8b7c5d7015d5555bb6b950061100 Mon Sep 17 00:00:00 2001 From: Laam Pui Date: Thu, 8 Oct 2020 22:11:44 +0800 Subject: [PATCH] feat: add route of 'zsnews.cn' (#5818) --- docs/traditional-media.md | 12 ++++++++++++ lib/router.js | 3 +++ lib/routes/zsnews/index.js | 18 ++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 lib/routes/zsnews/index.js diff --git a/docs/traditional-media.md b/docs/traditional-media.md index c7f924ea3..071f371ca 100644 --- a/docs/traditional-media.md +++ b/docs/traditional-media.md @@ -791,6 +791,18 @@ category 对应的关键词有 +## 中山网 + +### 中山网新闻 + + + +| 35 | 36 | 37 | 38 | 39 | +| ---- | ---- | ---- | ---- | ---- | +| 本地 | 镇区 | 热点 | 社会 | 综合 | + + + ## 中時電子報 ### 新聞 diff --git a/lib/router.js b/lib/router.js index 53165c732..7f4a630cd 100644 --- a/lib/router.js +++ b/lib/router.js @@ -3163,6 +3163,9 @@ router.get('/shiep/:type', require('./routes/universities/shiep/index')); router.get('/fjnews/:city/:limit', require('./routes/fjnews/fznews')); router.get('/fjnews/jjnews', require('./routes/fjnews/jjnews')); +// 中山网新闻 +router.get('/zsnews/index/:cateid', require('./routes/zsnews/index')); + // 孔夫子旧书网 router.get('/kongfz/people/:id', require('./routes/kongfz/people')); router.get('/kongfz/shop/:id/:cat?', require('./routes/kongfz/shop')); diff --git a/lib/routes/zsnews/index.js b/lib/routes/zsnews/index.js new file mode 100644 index 000000000..be0c2d49a --- /dev/null +++ b/lib/routes/zsnews/index.js @@ -0,0 +1,18 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + ctx.params.cateid = ctx.params.cateid || '35'; + + const response = await got.get(`http://www.zsnews.cn/api/mobile/getlist.html?cateid=${ctx.params.cateid}`); + + ctx.state.data = { + title: '中山新闻', + link: 'https://www.zsnews.cn/', + item: response.data.map((item) => ({ + guid: item.id, + title: item.title, + description: item.title, + link: item.url, + })), + }; +};