From c79d6d5eeb1c8d37dcd4232eb0b55bcc8554f100 Mon Sep 17 00:00:00 2001 From: DIYgod Date: Wed, 25 Dec 2019 11:50:47 +0800 Subject: [PATCH] feat: add chouti top, close #3605 --- docs/new-media.md | 16 ++++++++++++++++ docs/other.md | 13 +------------ lib/router.js | 1 + lib/routes/chouti/top.js | 28 ++++++++++++++++++++++++++++ 4 files changed, 46 insertions(+), 12 deletions(-) create mode 100644 lib/routes/chouti/top.js diff --git a/docs/new-media.md b/docs/new-media.md index f77b73da4..f3a367337 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -256,6 +256,22 @@ pageClass: routes +## 抽屉新热榜 + +### 最新 + + + +| 热榜 | 42 区 | 段子 | 图片 | 挨踢 1024 | 你问我答 | +| ---- | ----- | ----- | ---- | --------- | -------- | +| hot | news | scoff | pic | tec | ask | + + + +### 最热榜 TOP10 + + + ## 创业邦 ### 作者 diff --git a/docs/other.md b/docs/other.md index 6829abdc8..352eed064 100644 --- a/docs/other.md +++ b/docs/other.md @@ -213,23 +213,12 @@ type 为 all 时,category 参数不支持 cost 和 free -## 抽屉 - -### 新热榜 - - - -| 热榜 | 42 区 | 段子 | 图片 | 挨踢 1024 | 你问我答 | -| ---- | ----- | ----- | ---- | --------- | -------- | -| hot | news | scoff | pic | tec | ask | - - - ## 电鸭社区 ### 工作机会 + ## 福利资源-met.red ### 福利资源-met.red diff --git a/lib/router.js b/lib/router.js index 47140ba6c..c63ad5d19 100644 --- a/lib/router.js +++ b/lib/router.js @@ -843,6 +843,7 @@ router.get('/dgtle/trade/:typeId?', require('./routes/dgtle/trade')); router.get('/dgtle/trade/search/:keyword', require('./routes/dgtle/keyword')); // 抽屉新热榜 +router.get('/chouti/top/:hour?', require('./routes/chouti/top')); router.get('/chouti/:subject?', require('./routes/chouti')); // 西安电子科技大学 diff --git a/lib/routes/chouti/top.js b/lib/routes/chouti/top.js new file mode 100644 index 000000000..2445fec5c --- /dev/null +++ b/lib/routes/chouti/top.js @@ -0,0 +1,28 @@ +const got = require('@/utils/got'); + +module.exports = async (ctx) => { + const hour = ctx.params.hour || '24'; + + const response = await got({ + method: 'get', + url: `https://dig.chouti.com/top/${hour}hr?_=${+new Date()}`, + headers: { + Referer: 'https://dig.chouti.com/', + }, + }); + + const resultItem = response.data.data.map((item) => ({ + title: item.title, + author: item.nick, + description: `${item.title}

评论`, + link: item.url, + pubDate: new Date(item.createdTime / 1000).toUTCString(), + })); + + ctx.state.data = { + title: `抽屉新热榜-${hour}小时最热榜`, + description: '抽屉新热榜,汇聚每日搞笑段子、热门图片、有趣新闻。它将微博、门户、社区、bbs、社交网站等海量内容聚合在一起,通过用户推荐生成最热榜单。看抽屉新热榜,每日热门、有趣资讯尽收眼底。', + link: 'https://dig.chouti.com/', + item: resultItem, + }; +};