mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-08 22:19:40 +08:00
fix: gitchat new revision (#3941)
This commit is contained in:
@@ -1,38 +1,23 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
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();
|
||||
const category = ctx.params.category && ctx.params.category !== 'all' ? ctx.params.category : '';
|
||||
const selected = ctx.params.selected;
|
||||
|
||||
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();
|
||||
const response = await got(`https://gitbook.cn/activities?page=1&type=new&isSelected=${selected ? 'true' : 'false'}${category ? '&category=' + category : ''}`);
|
||||
const list = response.data.data;
|
||||
|
||||
const category_name = category ? list[0].category.categoryName : '';
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'GitChat-最新',
|
||||
link: 'https://gitbook.cn/gitchat/news',
|
||||
description: 'GitChat 是一款基于微信平台的知识分享产品。通过这款产品我们希望改变IT知识的学习方式。',
|
||||
item: resultItem,
|
||||
title: `GitChat ${category ? category_name + ' ' : ''}最新${selected ? '严选' : ''}`,
|
||||
link: 'https://gitbook.cn/',
|
||||
item: list.map((item) => ({
|
||||
title: item.title,
|
||||
author: item.authorId.customerName,
|
||||
description: `<p>${item.description}</p>`,
|
||||
pubDate: new Date(),
|
||||
link: `https://gitbook.cn/gitchat/activity/${item._id}`,
|
||||
})),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user