feat(route): 中国国际航空公司服务公告 (#10187)
* feat(route): 中国国际航空公司服务公告 * Update lib/v2/airchina/index.js
This commit is contained in:
parent
d874a000b2
commit
45660efcc7
|
|
@ -146,6 +146,12 @@ path="/metmusem/exhibitions/:state?"
|
|||
|
||||
<Route author="chazeon" example="/mcachicago/exhibitions" path="/mcachicago/exhibitions" />
|
||||
|
||||
## 中国国际航空公司
|
||||
|
||||
### 服务公告
|
||||
|
||||
<Route author="LandonLi" example="/airchina/announcement" path="/airchina/announcement" radar="1" />
|
||||
|
||||
## 中国美术馆
|
||||
|
||||
### 美术馆新闻
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const buildData = require('@/utils/common-config');
|
||||
const baseUrl = 'https://www.airchina.com.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `${baseUrl}/cn/info/new-service/service_announcement.shtml`;
|
||||
ctx.state.data = await buildData({
|
||||
link,
|
||||
url: link,
|
||||
title: `%title%`,
|
||||
description: `%description%`,
|
||||
params: {
|
||||
title: '国航服务公告',
|
||||
description: '中国国际航空公司服务公告',
|
||||
},
|
||||
item: {
|
||||
item: '.serviceMsg li',
|
||||
title: `$('a').text()`,
|
||||
link: `$('a').attr('href')`,
|
||||
pubDate: `parseDate($('span').text(), 'YYYY-MM-DD')`,
|
||||
guid: Buffer.from(`$('a').attr('href')`).toString('base64'),
|
||||
},
|
||||
});
|
||||
|
||||
await Promise.all(
|
||||
ctx.state.data.item.map(async (item) => {
|
||||
const detailLink = baseUrl + item.link;
|
||||
item.description = await ctx.cache.tryGet(detailLink, async () => {
|
||||
const result = await got(detailLink);
|
||||
const $ = cheerio.load(result.data);
|
||||
return $('.serviceMsg').html();
|
||||
});
|
||||
})
|
||||
);
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/announcement': ['LandonLi'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'airchina.com.cn': {
|
||||
_name: '中国国际航空公司',
|
||||
www: [
|
||||
{
|
||||
title: '服务公告',
|
||||
docs: 'https://docs.rsshub.app/travel.html#zhong-guo-guo-ji-hang-kong-gong-si',
|
||||
source: '/',
|
||||
target: '/airchina/announcement',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/announcement', require('./index'));
|
||||
};
|
||||
Loading…
Reference in New Issue