增加: GitChat (#1088)

日常翻车系列 🌚
This commit is contained in:
凉凉
2018-11-07 21:17:07 +08:00
committed by DIYgod
parent 622995a649
commit c7fbc389f0
3 changed files with 47 additions and 0 deletions

View File

@@ -736,6 +736,12 @@ GitHub 官方也提供了一些 RSS:
<route name="最新分享" author="xyqfer" example="/blogread/newest" path="/blogread/newest"/> <route name="最新分享" author="xyqfer" example="/blogread/newest" path="/blogread/newest"/>
### GitChat
<route name="最新" author="xyqfer" example="/gitchat/newest" path="/gitchat/newest"/>
> GitChat 需要付费订阅, RSS 仅做更新提醒, 不含付费内容.
## 直播 ## 直播
### 哔哩哔哩直播 ### 哔哩哔哩直播

View File

@@ -770,4 +770,7 @@ router.get('/itjuzi/merge', require('./routes/itjuzi/merge'));
// 探物 // 探物
router.get('/tanwu/products', require('./routes/tanwu/products')); router.get('/tanwu/products', require('./routes/tanwu/products'));
// GitChat
router.get('/gitchat/newest', require('./routes/gitchat/newest'));
module.exports = router; module.exports = router;

38
routes/gitchat/newest.js Normal file
View File

@@ -0,0 +1,38 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await axios({
method: 'get',
url: 'https://gitbook.cn/gitchat/news/0/20?searchKey=',
});
const $ = cheerio.load(response.data.data);
const resultItem = $('.col-md-12')
.map((index, item) => {
item = $(item);
const author = item.find('.chat_info_author').text();
return {
title: item.find('.chat_info_title').text(),
description:
`作者: ${author}<br><br>` +
item
.find('.chat_info_desc')
.text()
.replace(/\n/g, '<br>'),
link: `https://gitbook.cn${item
.find('a')
.eq(0)
.attr('href')}`,
author,
};
})
.get();
ctx.state.data = {
title: 'GitChat-最新',
link: 'https://gitbook.cn/gitchat/news',
description: 'GitChat 是一款基于微信平台的知识分享产品。通过这款产品我们希望改变IT知识的学习方式。',
item: resultItem,
};
};