diff --git a/docs/travel.md b/docs/travel.md index 0b18dd55c..d49fb611c 100644 --- a/docs/travel.md +++ b/docs/travel.md @@ -55,11 +55,11 @@ IATA 国际航空运输协会机场代码,参见[维基百科 国际航空运 ### 优惠信息 - + ### 信用卡 - + | 信用卡模块 | bank | | ---------- | ------------- | diff --git a/lib/router.js b/lib/router.js index 37c0aef3e..297ac7463 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1871,8 +1871,10 @@ router.get('/aiyanxishe/:id/:sort?', lazyloadRouteHandler('./routes/aiyanxishe/h router.get('/huodongxing/explore', lazyloadRouteHandler('./routes/hdx/explore')); // 飞客茶馆优惠信息 -router.get('/flyertea/preferential', lazyloadRouteHandler('./routes/flyertea/preferential')); -router.get('/flyertea/creditcard/:bank', lazyloadRouteHandler('./routes/flyertea/creditcard')); +router.get('/flyert/preferential', lazyloadRouteHandler('./routes/flyert/preferential')); +router.get('/flyert/creditcard/:bank', lazyloadRouteHandler('./routes/flyert/creditcard')); +router.get('/flyertea/preferential', lazyloadRouteHandler('./routes/flyert/preferential')); +router.get('/flyertea/creditcard/:bank', lazyloadRouteHandler('./routes/flyert/creditcard')); // 中国广播 router.get('/radio/:channelname/:name', lazyloadRouteHandler('./routes/radio/radio')); diff --git a/lib/routes/flyertea/creditcard.js b/lib/routes/flyert/creditcard.js similarity index 96% rename from lib/routes/flyertea/creditcard.js rename to lib/routes/flyert/creditcard.js index 8ebce4a8a..cad704834 100644 --- a/lib/routes/flyertea/creditcard.js +++ b/lib/routes/flyert/creditcard.js @@ -4,7 +4,7 @@ const util = require('./utils'); const iconv = require('iconv-lite'); const gbk2utf8 = (s) => iconv.decode(s, 'gbk'); -const host = 'https://www.flyertea.com'; +const host = 'https://www.flyert.com'; module.exports = async (ctx) => { const bank = ctx.params.bank; @@ -72,13 +72,14 @@ module.exports = async (ctx) => { }); const $ = cheerio.load(gbk2utf8(response.data)); + const list = $("[id*='normalthread']").get(); const result = await util.ProcessFeed(list, ctx.cache); ctx.state.data = { title: `飞客茶馆信用卡 - ${bankname}`, - link: 'https://www.flyertea.com/', + link: 'https://www.flyert.com/', description: `飞客茶馆信用卡 - ${bankname}`, item: result, }; diff --git a/lib/routes/flyertea/preferential.js b/lib/routes/flyert/preferential.js similarity index 92% rename from lib/routes/flyertea/preferential.js rename to lib/routes/flyert/preferential.js index b83aaa92e..4735b6220 100644 --- a/lib/routes/flyertea/preferential.js +++ b/lib/routes/flyert/preferential.js @@ -3,7 +3,7 @@ const cheerio = require('cheerio'); const iconv = require('iconv-lite'); const gbk2utf8 = (s) => iconv.decode(s, 'gbk'); -const host = 'https://www.flyertea.com'; +const host = 'https://www.flyert.com'; const target = `${host}/forum.php?mod=forumdisplay&sum=all&fid=all&catid=322`; module.exports = async (ctx) => { @@ -15,7 +15,7 @@ module.exports = async (ctx) => { const items = $('.comiis_wzli'); ctx.state.data = { title: '飞客茶馆优惠', - link: 'https://www.flyertea.com/', + link: 'https://www.flyert.com/', description: '飞客茶馆优惠', item: items && diff --git a/lib/routes/flyertea/utils.js b/lib/routes/flyert/utils.js similarity index 89% rename from lib/routes/flyertea/utils.js rename to lib/routes/flyert/utils.js index 814ca0320..12649498c 100644 --- a/lib/routes/flyertea/utils.js +++ b/lib/routes/flyert/utils.js @@ -32,15 +32,15 @@ async function load(link) { return { description }; } -const ProcessFeed = (list, caches) => { - const host = 'https://www.flyertea.com'; +const ProcessFeed = async (list, caches) => { + const host = 'https://www.flyert.com'; - return Promise.all( + return await Promise.all( list.map(async (item) => { const $ = cheerio.load(item); const $label = $(".comiis_common a[data-track='版块页主题分类']"); - const $title = $(".comiis_common a[data-track='版块页帖子']"); + const $title = $(".comiis_common a[data-track='版块页文章']"); // 还原相对链接为绝对链接 const itemUrl = url.resolve(host, $title.attr('href')); @@ -53,7 +53,7 @@ const ProcessFeed = (list, caches) => { // 使用tryGet方法从缓存获取内容。 // 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。 - const other = await caches.tryGet(itemUrl, () => load(itemUrl)); + const other = await caches.tryGet(itemUrl, async () => await load(itemUrl)); // 合并解析后的结果集作为该篇文章最终的输出结果 return Promise.resolve(Object.assign({}, single, other));