diff --git a/docs/social-media.md b/docs/social-media.md index d4ff76d2d..02a01239a 100644 --- a/docs/social-media.md +++ b/docs/social-media.md @@ -1114,6 +1114,16 @@ rule +### 知乎分类热榜 + + + +| 全站 | 国际 | 科学 | 汽车 | 视频 | 时尚 | 时事 | 数码 | 体育 | 校园 | 影视 | +| ----- | ----- | ------- | ---- | ------ | ------- | ----- | ------- | ----- | ------ | ---- | +| total | focus | science | car | zvideo | fashion | depth | digital | sport | school | film | + + + ### 知乎想法热榜 diff --git a/lib/router.js b/lib/router.js index 3f2665492..9e7177507 100644 --- a/lib/router.js +++ b/lib/router.js @@ -159,6 +159,7 @@ router.get('/zhihu/bookstore/newest', require('./routes/zhihu/bookstore/newest') router.get('/zhihu/pin/daily', require('./routes/zhihu/pin/daily')); router.get('/zhihu/weekly', require('./routes/zhihu/weekly')); router.get('/zhihu/timeline', require('./routes/zhihu/timeline')); +router.get('/zhihu/hot/:category?', require('./routes/zhihu/hot')); // 妹子图 router.get('/mzitu/home/:type?', require('./routes/mzitu/home')); diff --git a/lib/routes/zhihu/hot.js b/lib/routes/zhihu/hot.js new file mode 100644 index 000000000..2a35d244a --- /dev/null +++ b/lib/routes/zhihu/hot.js @@ -0,0 +1,37 @@ +const got = require('@/utils/got'); + +const titles = { + total: '全站', + focus: '国际', + science: '科学', + car: '汽车', + zvideo: '视频', + fashion: '时尚', + depth: '时事', + digital: '数码', + sport: '体育', + school: '校园', + film: '影视', +}; + +module.exports = async (ctx) => { + const category = ctx.params.category || 'total'; + + const response = await got({ + method: 'get', + url: `https://www.zhihu.com/api/v3/feed/topstory/hot-lists/${category}?limit=50`, + }); + + const items = response.data.data.map((item) => ({ + link: item.target.url, + title: item.target.title, + pubDate: new Date(item.target.created * 1000).toUTCString(), + description: item.target.excerpt ? `

${item.target.excerpt}

` : '', + })); + + ctx.state.data = { + title: `知乎热榜 - ${titles[category]}`, + link: `https://www.zhihu.com/hot?list=${category}`, + item: items, + }; +};