mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
增加:豆瓣热门图书排行 (#1016)
This commit is contained in:
@@ -468,6 +468,14 @@ RSSHub 提供下列 API 接口:
|
||||
|
||||
<route name="豆瓣书店" author="xyqfer" example="/douban/bookstore" path="/douban/bookstore"/>
|
||||
|
||||
<route name="热门图书排行" author="xyqfer" example="/douban/book/rank/fiction" path="/douban/book/rank/:type" :paramsDesc="['图书类型']">
|
||||
|
||||
| 虚构 | 非虚构 |
|
||||
| ------- | ---------- |
|
||||
| fiction | nonfiction |
|
||||
|
||||
</route>
|
||||
|
||||
### Disqus
|
||||
|
||||
<route name="评论" author="DIYgod" example="/disqus/posts/diygod-me" path="/disqus/posts/:forum" :paramsDesc="['网站的 disqus name']"/>
|
||||
|
||||
@@ -196,6 +196,7 @@ router.get('/douban/book/latest', require('./routes/douban/latest_book'));
|
||||
router.get('/douban/event/hot/:locationId', require('./routes/douban/event/hot'));
|
||||
router.get('/douban/commercialpress/latest', require('./routes/douban/commercialpress/latest'));
|
||||
router.get('/douban/bookstore', require('./routes/douban/bookstore'));
|
||||
router.get('/douban/book/rank/:type', require('./routes/douban/book/rank'));
|
||||
|
||||
// 煎蛋
|
||||
router.get('/jandan/:sub_model', require('./routes/jandan/pic'));
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
const axios = require('../../../utils/axios');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { type = 'fiction' } = ctx.params;
|
||||
const referer = `https://m.douban.com/subject_collection/book_${type}_hot_weekly`;
|
||||
|
||||
const response = await axios({
|
||||
method: 'get',
|
||||
url: `https://m.douban.com/rexxar/api/v2/subject_collection/book_${type}_hot_weekly/items?start=0&count=10`,
|
||||
headers: {
|
||||
Referer: referer,
|
||||
},
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `豆瓣热门图书-${type === 'fiction' ? '虚构类' : '非虚构类'}`,
|
||||
link: referer,
|
||||
description: '每周一更新',
|
||||
item: response.data.subject_collection_items.map(({ title, url, cover, info, rating }) => {
|
||||
const description = `<img referrerpolicy="no-referrer" src="${cover.url}"><br>
|
||||
${title}/${info}/${rating.value.toFixed(1)}分
|
||||
`;
|
||||
|
||||
return {
|
||||
title: `${title}-${info}`,
|
||||
description,
|
||||
link: url,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user