mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add 华为心声社区华为家事 (#5777)
Co-authored-by: Henry Wang <hi@henry.wang>
This commit is contained in:
+20
@@ -429,6 +429,26 @@ pageClass: routes
|
||||
|
||||
<Route author="DIYgod" example="/mi/bbs/board/18066617" path="/mi/bbs/board/:boardId" :paramsDesc="['圈子 id,可在圈子 URL 找到']" radar="1"/>
|
||||
|
||||
## 华为心声社区
|
||||
|
||||
### 华为家事
|
||||
|
||||
<Route author="nczitzk" example="/huawei/xinsheng" path="/huawei/xinsheng/:caty?/:order?/:keyword?" :paramsDesc="['分区 ID, 见下表,默认为全部帖子', '排序方式, 见下表,默认为最新回复', '关键词,默认为空']">
|
||||
|
||||
分区 ID
|
||||
|
||||
| 全部帖子 | 公司文件 | 管理思考 | 产品改进 | 版务公告 |
|
||||
| -------- | -------- | -------- | -------- | -------- |
|
||||
| | 155 | 415 | 427 | 419 |
|
||||
|
||||
排序方式
|
||||
|
||||
| 最新发帖 | 最新回复 | 最多回复 | 最多点击 |
|
||||
| -------- | -------- | ---------- | --------- |
|
||||
| cTime | rTime | replycount | viewcount |
|
||||
|
||||
</Route>
|
||||
|
||||
## 一亩三分地
|
||||
|
||||
### 主题帖
|
||||
|
||||
@@ -3257,6 +3257,9 @@ router.get('/appsales/:caty?/:time?', require('./routes/appsales/index'));
|
||||
// CGTN
|
||||
router.get('/cgtn/top', require('./routes/cgtn/top'));
|
||||
|
||||
// 华为心声社区
|
||||
router.get('/huawei/xinsheng/:caty?/:order?/:keyword?', require('./routes/huawei/xinsheng/index'));
|
||||
|
||||
// 守望先锋
|
||||
router.get('/ow/patch', require('./routes/ow/patch'));
|
||||
|
||||
|
||||
@@ -0,0 +1,62 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.params.order = ctx.params.order || '';
|
||||
ctx.params.keyword = ctx.params.keyword || '';
|
||||
ctx.params.caty = ctx.params.caty || '';
|
||||
|
||||
const rootUrl = `http://xinsheng.huawei.com/cn/index.php?app=forum&mod=List&class=461&order=${ctx.params.order}&search=${ctx.params.keyword}&cate=${ctx.params.caty}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: rootUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
$('a[linktag="__subject_link__"]').remove();
|
||||
|
||||
const list = $('.bbs_list ul li .font_box .title p font a')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.attr('title'),
|
||||
link: item.attr('href'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
item.description = content('.bbs_info_right_text').eq(0).html();
|
||||
item.pubDate = new Date(content('span.fl').eq(0).text().trim() + ' GMT+8').toUTCString();
|
||||
item.author = content('.bbs_info_user_ a').eq(1).text();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
let title;
|
||||
|
||||
$('.bbs_list_box_title_wz ul li').each(function () {
|
||||
if ($(this).hasClass('on')) {
|
||||
title = $(this).text();
|
||||
return;
|
||||
}
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${title} - 华为家事 - 心声社区`,
|
||||
link: rootUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user