diff --git a/docs/README.md b/docs/README.md index c3704c0ad7..b49973ff39 100644 --- a/docs/README.md +++ b/docs/README.md @@ -497,6 +497,8 @@ RSSHub 提供下列 API 接口: + + ### Disqus diff --git a/lib/router.js b/lib/router.js index ff1bb6151b..a7cc9e9a4d 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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/bookstore', require('./routes/douban/bookstore')); 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')); diff --git a/lib/routes/douban/doulist.js b/lib/routes/douban/doulist.js new file mode 100644 index 0000000000..1995a10069 --- /dev/null +++ b/lib/routes/douban/doulist.js @@ -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, + }; +};