mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 14:40:23 +08:00
@@ -497,6 +497,8 @@ RSSHub 提供下列 API 接口:
|
|||||||
|
|
||||||
</route>
|
</route>
|
||||||
|
|
||||||
|
<route name="豆列" author="LogicJake" example="/douban/doulist/37716774" path="douban/doulist/:id" :paramsDesc="['豆列id']"/>
|
||||||
|
|
||||||
### Disqus
|
### Disqus
|
||||||
|
|
||||||
<route name="评论" author="DIYgod" example="/disqus/posts/diygod-me" path="/disqus/posts/:forum" :paramsDesc="['网站的 disqus name']"/>
|
<route name="评论" author="DIYgod" example="/disqus/posts/diygod-me" path="/disqus/posts/:forum" :paramsDesc="['网站的 disqus name']"/>
|
||||||
|
|||||||
@@ -226,6 +226,7 @@ router.get('/douban/event/hot/:locationId', require('./routes/douban/event/hot')
|
|||||||
router.get('/douban/commercialpress/latest', require('./routes/douban/commercialpress/latest'));
|
router.get('/douban/commercialpress/latest', require('./routes/douban/commercialpress/latest'));
|
||||||
router.get('/douban/bookstore', require('./routes/douban/bookstore'));
|
router.get('/douban/bookstore', require('./routes/douban/bookstore'));
|
||||||
router.get('/douban/book/rank/:type', require('./routes/douban/book/rank'));
|
router.get('/douban/book/rank/:type', require('./routes/douban/book/rank'));
|
||||||
|
router.get('/douban/doulist/:id', require('./routes/douban/doulist'));
|
||||||
|
|
||||||
// 煎蛋
|
// 煎蛋
|
||||||
router.get('/jandan/:sub_model', require('./routes/jandan/pic'));
|
router.get('/jandan/:sub_model', require('./routes/jandan/pic'));
|
||||||
|
|||||||
54
lib/routes/douban/doulist.js
Normal file
54
lib/routes/douban/doulist.js
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
const axios = require('../../utils/axios');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
const host = 'https://www.douban.com/doulist/';
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const id = ctx.params.id;
|
||||||
|
|
||||||
|
const link = url.resolve(host, id);
|
||||||
|
const response = await axios.get(link);
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
const title = $('#content h1')
|
||||||
|
.text()
|
||||||
|
.trim();
|
||||||
|
const description = $('div.doulist-about')
|
||||||
|
.text()
|
||||||
|
.trim();
|
||||||
|
const out = $('div.doulist-item')
|
||||||
|
.slice(0, 10)
|
||||||
|
.map(function() {
|
||||||
|
const title = $(this)
|
||||||
|
.find('div.bd.doulist-note div.title a')
|
||||||
|
.text()
|
||||||
|
.trim();
|
||||||
|
const link = $(this)
|
||||||
|
.find('div.bd.doulist-note div.title a')
|
||||||
|
.attr('href');
|
||||||
|
const date = $(this)
|
||||||
|
.find('div.ft div.actions time span')
|
||||||
|
.attr('title');
|
||||||
|
|
||||||
|
const description = $(this)
|
||||||
|
.find('div.bd.doulist-note div.abstract')
|
||||||
|
.text()
|
||||||
|
.trim();
|
||||||
|
const single = {
|
||||||
|
title: title,
|
||||||
|
link: link,
|
||||||
|
description: description,
|
||||||
|
pubDate: new Date(date).toUTCString(),
|
||||||
|
};
|
||||||
|
return single;
|
||||||
|
})
|
||||||
|
.get();
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: title,
|
||||||
|
link: link,
|
||||||
|
description: description,
|
||||||
|
item: out,
|
||||||
|
};
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user