feat: add new route flyertea (#2431)

* feat: add new route flyertea

* fix: docs error fix
This commit is contained in:
howel52
2019-06-19 11:25:34 +08:00
committed by DIYgod
parent 1b632a3e8d
commit ad4faac0bb
3 changed files with 42 additions and 0 deletions

View File

@@ -45,6 +45,12 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
</Route>
## 飞客茶馆
### 优惠信息
<Route author="howel52" example="/flyertea/preferential" path="/flyertea/preferential" />
## 国家地理
### 分类

View File

@@ -1421,4 +1421,7 @@ router.get('/sixthtone/news', require('./routes/sixthtone/news'));
// AI研习社
router.get('/aiyanxishe/:id/:sort?', require('./routes/aiyanxishe/home'));
// 飞客茶馆优惠信息
router.get('/flyertea/preferential', require('./routes/flyertea/preferential'));
module.exports = router;

View File

@@ -0,0 +1,33 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const iconv = require('iconv-lite');
const gbk2utf8 = (s) => iconv.decode(s, 'gbk');
const host = 'https://www.flyertea.com';
const target = `${host}/forum.php?mod=forumdisplay&sum=all&fid=all&catid=322`;
module.exports = async (ctx) => {
const response = await got.get(target, {
responseType: 'buffer',
});
const $ = cheerio.load(gbk2utf8(response.data));
const items = $('.comiis_wzli');
ctx.state.data = {
title: '飞客茶馆优惠',
link: 'https://www.flyertea.com/',
description: '飞客茶馆优惠',
item:
items &&
items
.map((index, item) => {
item = $(item);
return {
title: item.find('.wzbt').text(),
description: item.find('.wznr > div:first-child').text(),
link: `${host}/${item.find('.wzbt a').attr('href')}`,
};
})
.get(),
};
};