fix(route): add `Spotlight News` into CNA list. (#13160)
* fix(route): add `Spotlight News` into CNA list. * refactor: migrate to v2 ---------
This commit is contained in:
parent
05bb835014
commit
64839f022b
|
|
@ -2039,7 +2039,7 @@ router.get('/anki/changes', lazyloadRouteHandler('./routes/anki/changes'));
|
|||
router.get('/abc/:id?', lazyloadRouteHandler('./routes/abc'));
|
||||
|
||||
// 台湾中央通讯社
|
||||
router.get('/cna/:id?', lazyloadRouteHandler('./routes/cna/index'));
|
||||
// router.get('/cna/:id?', lazyloadRouteHandler('./routes/cna/index'));
|
||||
|
||||
// 华为心声社区
|
||||
router.get('/huawei/xinsheng/:caty?/:order?/:keyword?', lazyloadRouteHandler('./routes/huawei/xinsheng/index'));
|
||||
|
|
|
|||
|
|
@ -1,15 +1,17 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.params.id = ctx.params.id || 'aall';
|
||||
const id = ctx.params.id || 'aall';
|
||||
|
||||
let rootUrl;
|
||||
|
||||
if (/^\d+$/.test(ctx.params.id)) {
|
||||
rootUrl = `https://www.cna.com.tw/topic/newstopic/${ctx.params.id}.aspx`;
|
||||
if (/^\d+$/.test(id)) {
|
||||
rootUrl = `https://www.cna.com.tw/topic/newstopic/${id}.aspx`;
|
||||
} else {
|
||||
rootUrl = `https://www.cna.com.tw/list/${ctx.params.id}.aspx`;
|
||||
rootUrl = `https://www.cna.com.tw/list/${id}.aspx`;
|
||||
}
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
|
|
@ -17,17 +19,17 @@ module.exports = async (ctx) => {
|
|||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('#jsMainList li a div h2')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
const list = $('.mainList li a div h2')
|
||||
.slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 10)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.text(),
|
||||
link: item.parents('a').attr('href'),
|
||||
pubDate: new Date(item.next().text() + ' GMT+8').toUTCString(),
|
||||
pubDate: timezone(parseDate(item.next().text()), +8),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/:id?': ['nczitzk'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'cna.com.tw': {
|
||||
_name: '中央通訊社',
|
||||
'.': [
|
||||
{
|
||||
title: '分类',
|
||||
docs: 'https://docs.rsshub.app/routes/traditional-media#zhong-yang-tong-xun-she',
|
||||
source: ['/list/:id', '/topic/newstopic/:id'],
|
||||
target: (params) => `/cna/${params.id.replace('.aspx', '')}`,
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/:id?', require('./'));
|
||||
};
|
||||
|
|
@ -2339,18 +2339,6 @@ category 对应的关键词有
|
|||
|
||||
</Route>
|
||||
|
||||
## 台湾中央通讯社 {#tai-wan-zhong-yang-tong-xun-she}
|
||||
|
||||
### 分类 {#tai-wan-zhong-yang-tong-xun-she-fen-lei}
|
||||
|
||||
<Route author="nczitzk" example="/cna/aall" path="/cna/:id?" paramsDesc={['分类 id 或新闻专题 id。分类 id 见下表,新闻专题 id 為 https://www.cna.com.tw/list/newstopic.aspx 中,連結的數字部份。此參數默认为 aall']}>
|
||||
|
||||
| 即時 | 政治 | 國際 | 兩岸 | 產經 | 證券 | 科技 | 生活 | 社會 | 地方 | 文化 | 運動 | 娛樂 |
|
||||
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
||||
| aall | aipl | aopl | acn | aie | asc | ait | ahel | asoc | aloc | acul | aspt | amov |
|
||||
|
||||
</Route>
|
||||
|
||||
## 天下雜誌 {#tian-xia-za-zhi}
|
||||
|
||||
### 最新上線 {#tian-xia-za-zhi-zui-xin-shang-xian}
|
||||
|
|
@ -2772,6 +2760,18 @@ category 对应的关键词有
|
|||
|
||||
</Route>
|
||||
|
||||
## 中央通讯社 {#zhong-yang-tong-xun-she}
|
||||
|
||||
### 分类 {#zhong-yang-tong-xun-she-fen-lei}
|
||||
|
||||
<Route author="nczitzk" example="/cna/aall" path="/cna/:id?" paramsDesc={['分类 id 或新闻专题 id。分类 id 见下表,新闻专题 id 為 https://www.cna.com.tw/list/newstopic.aspx 中,連結的數字部份。此參數默认为 aall']}>
|
||||
|
||||
| 即時 | 政治 | 國際 | 兩岸 | 產經 | 證券 | 科技 | 生活 | 社會 | 地方 | 文化 | 運動 | 娛樂 |
|
||||
| ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
||||
| aall | aipl | aopl | acn | aie | asc | ait | ahel | asoc | aloc | acul | aspt | amov |
|
||||
|
||||
</Route>
|
||||
|
||||
## 组织人事报 {#zu-zhi-ren-shi-bao}
|
||||
|
||||
### 电子报 {#zu-zhi-ren-shi-bao-dian-zi-bao}
|
||||
|
|
|
|||
Loading…
Reference in New Issue