diff --git a/docs/README.md b/docs/README.md index da55333bd4..f2117c27e3 100755 --- a/docs/README.md +++ b/docs/README.md @@ -462,6 +462,8 @@ RSSHub 提供下列 API 接口: + + ### pixiv diff --git a/lib/router.js b/lib/router.js index bf4bb8ffba..f437af2a3a 100755 --- a/lib/router.js +++ b/lib/router.js @@ -179,6 +179,7 @@ router.get('/zhihu/topic/:topicId', require('./routes/zhihu/topic')); router.get('/zhihu/people/pins/:id', require('./routes/zhihu/pin/people')); 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('/mzitu/home/:type?', require('./routes/mzitu/home')); diff --git a/lib/routes/zhihu/weekly.js b/lib/routes/zhihu/weekly.js new file mode 100644 index 0000000000..0b2a17a908 --- /dev/null +++ b/lib/routes/zhihu/weekly.js @@ -0,0 +1,43 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); +const url = require('url'); + +const host = 'https://www.zhihu.com'; + +module.exports = async (ctx) => { + const link = 'https://www.zhihu.com/pub/weekly'; + const response = await axios.get(link); + const $ = cheerio.load(response.data); + + const description = $('p.Weekly-description').text(); + const out = $('div.Card-section.PubBookListItem') + .slice(0, 10) + .map(function() { + const info = { + title: $(this) + .find('span.PubBookListItem-title') + .text(), + link: url.resolve( + host, + $(this) + .find('a.PubBookListItem-buttonWrapper') + .attr('href') + ), + description: $(this) + .find('div.PubBookListItem-description') + .text(), + author: $(this) + .find('span.PubBookListItem-author') + .text(), + }; + return info; + }) + .get(); + + ctx.state.data = { + title: '知乎周刊', + link: link, + description: description, + item: out, + }; +};