mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-04 19:59:54 +08:00
feat(route): add 消費者委員會 (#8743)
This commit is contained in:
@@ -3295,6 +3295,26 @@ column 为 third 时可选的 category:
|
|||||||
|
|
||||||
</Route>
|
</Route>
|
||||||
|
|
||||||
|
## 消费者委员会
|
||||||
|
|
||||||
|
### 文章
|
||||||
|
|
||||||
|
<Route author="nczitzk" example="/consumer" path="/consumer/:category?/:language?/:keyword?" :paramsDesc="['分类,见下表,默认为測試及調查', '语言,见下表,默认为繁体中文', '关键字,默认为空']">
|
||||||
|
|
||||||
|
分类
|
||||||
|
|
||||||
|
| 测试及调查 | 生活资讯 | 投诉实录 | 议题评论 |
|
||||||
|
| ---------- | -------- | --------- | -------- |
|
||||||
|
| test | life | complaint | topic |
|
||||||
|
|
||||||
|
语言
|
||||||
|
|
||||||
|
| 简体中文 | 繁体中文 |
|
||||||
|
| -------- | -------- |
|
||||||
|
| sc | tc |
|
||||||
|
|
||||||
|
</Route>
|
||||||
|
|
||||||
## 辛華社
|
## 辛華社
|
||||||
|
|
||||||
### 首页
|
### 首页
|
||||||
|
|||||||
55
lib/v2/consumer/index.js
Normal file
55
lib/v2/consumer/index.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
const got = require('@/utils/got');
|
||||||
|
const cheerio = require('cheerio');
|
||||||
|
const { parseDate } = require('@/utils/parse-date');
|
||||||
|
|
||||||
|
module.exports = async (ctx) => {
|
||||||
|
const category = ctx.params.category ?? 'test';
|
||||||
|
const language = ctx.params.language ?? 'tc';
|
||||||
|
const keyword = ctx.params.keyword ?? '';
|
||||||
|
|
||||||
|
const rootUrl = 'https://www.consumer.org.hk';
|
||||||
|
const currentUrl = `${rootUrl}/${language}/free-article/free-article-${category}?category=free-article-${category}&q=${keyword}`;
|
||||||
|
|
||||||
|
const response = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: currentUrl,
|
||||||
|
});
|
||||||
|
|
||||||
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
|
let items = $('.half-img-blk__title, .img-plate-blk__title')
|
||||||
|
.find('a')
|
||||||
|
.toArray()
|
||||||
|
.map((item) => {
|
||||||
|
item = $(item);
|
||||||
|
|
||||||
|
return {
|
||||||
|
title: item.text(),
|
||||||
|
link: `${rootUrl}${item.attr('href')}`,
|
||||||
|
pubDate: parseDate(item.parent().prev().find('li').first().text(), 'YYYY.MM'),
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
|
items = await Promise.all(
|
||||||
|
items.map((item) =>
|
||||||
|
ctx.cache.tryGet(item.link, async () => {
|
||||||
|
const detailResponse = await got({
|
||||||
|
method: 'get',
|
||||||
|
url: item.link,
|
||||||
|
});
|
||||||
|
|
||||||
|
const content = cheerio.load(detailResponse.data);
|
||||||
|
|
||||||
|
item.description = content('.ckec').html();
|
||||||
|
|
||||||
|
return item;
|
||||||
|
})
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
ctx.state.data = {
|
||||||
|
title: $('title').text(),
|
||||||
|
link: currentUrl,
|
||||||
|
item: items,
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/consumer/maintainer.js
Normal file
3
lib/v2/consumer/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/:category?/:language?/:keyword?': ['nczitzk'],
|
||||||
|
};
|
||||||
13
lib/v2/consumer/radar.js
Normal file
13
lib/v2/consumer/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'consumer.org.hk': {
|
||||||
|
_name: '消费者委员会',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '文章',
|
||||||
|
docs: 'https://docs.rsshub.app/new-media.html#xiao-fei-zhe-wei-yuan-hui-wen-zhang',
|
||||||
|
source: ['/'],
|
||||||
|
target: '/consumer/:category?/:language?/:keyword?',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/consumer/router.js
Normal file
3
lib/v2/consumer/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/:category?/:language?/:keyword?', require('./index'));
|
||||||
|
};
|
||||||
Reference in New Issue
Block a user