diff --git a/docs/travel.md b/docs/travel.md index 5908301a7..1fa3acc37 100644 --- a/docs/travel.md +++ b/docs/travel.md @@ -146,6 +146,12 @@ path="/metmusem/exhibitions/:state?" +## 中国国际航空公司 + +### 服务公告 + + + ## 中国美术馆 ### 美术馆新闻 diff --git a/lib/v2/airchina/index.js b/lib/v2/airchina/index.js new file mode 100644 index 000000000..803b82f54 --- /dev/null +++ b/lib/v2/airchina/index.js @@ -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(); + }); + }) + ); +}; diff --git a/lib/v2/airchina/maintainer.js b/lib/v2/airchina/maintainer.js new file mode 100644 index 000000000..8dff2f3db --- /dev/null +++ b/lib/v2/airchina/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/announcement': ['LandonLi'], +}; diff --git a/lib/v2/airchina/radar.js b/lib/v2/airchina/radar.js new file mode 100644 index 000000000..6168dcea6 --- /dev/null +++ b/lib/v2/airchina/radar.js @@ -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', + }, + ], + }, +}; diff --git a/lib/v2/airchina/router.js b/lib/v2/airchina/router.js new file mode 100644 index 000000000..cd6219b90 --- /dev/null +++ b/lib/v2/airchina/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/announcement', require('./index')); +};