feat(route): 中国国际航空公司服务公告 (#10187)

* feat(route): 中国国际航空公司服务公告

* Update lib/v2/airchina/index.js
This commit is contained in:
LandonLi 2022-07-12 21:26:54 +08:00 committed by GitHub
parent d874a000b2
commit 45660efcc7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 61 additions and 0 deletions

View File

@ -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" />
## 中国美术馆
### 美术馆新闻

36
lib/v2/airchina/index.js Normal file
View File

@ -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();
});
})
);
};

View File

@ -0,0 +1,3 @@
module.exports = {
'/announcement': ['LandonLi'],
};

13
lib/v2/airchina/radar.js Normal file
View File

@ -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',
},
],
},
};

View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/announcement', require('./index'));
};