Merge branch 'master' into master
This commit is contained in:
commit
7340a91fa8
|
|
@ -22,6 +22,14 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
|||
- 歌单
|
||||
- 掘金
|
||||
- 分类
|
||||
- 简书
|
||||
- 首页
|
||||
- 7日热门
|
||||
- 30日热门
|
||||
- 专题
|
||||
- 作者
|
||||
- 知乎
|
||||
- 收藏夹
|
||||
- 自如
|
||||
- 房源
|
||||
- 快递
|
||||
|
|
|
|||
|
|
@ -236,6 +236,17 @@ s
|
|||
|
||||
参数: id,作者 id,可在作者主页 URL 中找到
|
||||
|
||||
|
||||
### 知乎
|
||||
|
||||
#### 收藏夹
|
||||
|
||||
举例: https://rss.prprpr.me/zhihu/collection/26444956
|
||||
|
||||
路由: `/zhihu/collection/:id`
|
||||
|
||||
参数: id,收藏夹 id,可在收藏夹页面 URL 中找到
|
||||
|
||||
### 自如
|
||||
|
||||
#### 房源
|
||||
|
|
|
|||
|
|
@ -4,7 +4,7 @@ search: zh-Hans
|
|||
|
||||
# 赞助 RSSHub 的研发
|
||||
|
||||
RSSHub 是采用 MIT 许可的开源项目,使用完全免费。 但是随着项目规模的增长,也需要有相应的资金支持才能持续项目的维护的开发。
|
||||
RSSHub 是采用 MIT 许可的开源项目,使用完全免费。 但是随着项目规模的增长,也需要有相应的资金支持才能持续项目的维护与开发。
|
||||
|
||||
你可以通过下列的方法来赞助 RSSHub 的开发。
|
||||
|
||||
|
|
|
|||
5
index.js
5
index.js
|
|
@ -38,4 +38,7 @@ app.get('/jianshu/trending/monthly', require('./routes/jianshu/monthly'));
|
|||
app.get('/jianshu/collection/:id', require('./routes/jianshu/collection'));
|
||||
app.get('/jianshu/user/:id', require('./routes/jianshu/user'));
|
||||
|
||||
app.listen(1200);
|
||||
// 知乎
|
||||
app.get('/zhihu/collection/:id', require('./routes/zhihu/collection'));
|
||||
|
||||
app.listen(1200);
|
||||
|
|
@ -0,0 +1,42 @@
|
|||
const request = require('request');
|
||||
const art = require('art-template');
|
||||
const path = require('path');
|
||||
const cheerio = require('cheerio');
|
||||
const base = require('../base');
|
||||
const mix = require('../../utils/mix');
|
||||
|
||||
module.exports = (req, res) => {
|
||||
const id = req.params.id;
|
||||
|
||||
base({
|
||||
req: req,
|
||||
res: res,
|
||||
getHTML: (callback) => {
|
||||
request.get({
|
||||
url: `https://www.zhihu.com/collection/${id}`,
|
||||
headers: {
|
||||
'User-Agent': mix.ua,
|
||||
'Referer': `https://www.zhihu.com/collection/${id}`
|
||||
}
|
||||
}, (err, httpResponse, body) => {
|
||||
const $ = cheerio.load(body);
|
||||
const list = $('div.zm-item');
|
||||
const html = art(path.resolve(__dirname, '../../views/rss.art'), {
|
||||
title: $('title').text(),
|
||||
link: `https://www.zhihu.com/collection/${id}`,
|
||||
description: `${$('#zh-fav-head-description').text()}`,
|
||||
lastBuildDate: new Date().toUTCString(),
|
||||
item: list && list.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('.zm-item-title a').text(),
|
||||
description: `内容:${item.find('textarea').text()}`,
|
||||
link: `https://www.zhihu.com${item.find('.zm-item-title a').attr('href')}`
|
||||
};
|
||||
}).get(),
|
||||
});
|
||||
callback(html);
|
||||
});
|
||||
}
|
||||
});
|
||||
};
|
||||
Loading…
Reference in New Issue