feat: add chouti top, close #3605

This commit is contained in:
DIYgod
2019-12-25 11:50:47 +08:00
parent 55abd0e0e5
commit c79d6d5eeb
4 changed files with 46 additions and 12 deletions

View File

@@ -256,6 +256,22 @@ pageClass: routes
<Route author="kt286" example="/bishijie/kuaixun" path="/bishijie/kuaixun"/>
## 抽屉新热榜
### 最新
<Route author="xyqfer" example="/chouti/hot" path="/chouti/:subject?" :paramsDesc="['主题名称']">
| 热榜 | 42 区 | 段子 | 图片 | 挨踢 1024 | 你问我答 |
| ---- | ----- | ----- | ---- | --------- | -------- |
| hot | news | scoff | pic | tec | ask |
</Route>
### 最热榜 TOP10
<Route author="DIYgod" example="/chouti/top/24" path="/chouti/top/:hour?" :paramsDesc="['排行榜周期,可选 24 72 168 三种,默认 24']" />
## 创业邦
### 作者

View File

@@ -213,23 +213,12 @@ type 为 all 时category 参数不支持 cost 和 free
<Route author="LogicJake" example="/kpmg/insights" path="/kpmg/insights" />
## 抽屉
### 新热榜
<Route author="xyqfer" example="/chouti/hot" path="/chouti/:subject?" :paramsDesc="['主题名称']">
| 热榜 | 42 区 | 段子 | 图片 | 挨踢 1024 | 你问我答 |
| ---- | ----- | ----- | ---- | --------- | -------- |
| hot | news | scoff | pic | tec | ask |
</Route>
## 电鸭社区
### 工作机会
<Route author="sfyumi" example="/eleduck/jobs" path="/eleduck/jobs"/>
## 福利资源-met.red
### 福利资源-met.red

View File

@@ -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'));
// 西安电子科技大学

28
lib/routes/chouti/top.js Normal file
View File

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