feat: 添加活动行 (#3075)

* add huodongxing route

* add doc for huodongxing
This commit is contained in:
K.F.G.H
2019-09-15 12:38:32 +08:00
committed by DIYgod
parent 8863853a72
commit e8a40bc0d2
3 changed files with 52 additions and 0 deletions

View File

@@ -90,6 +90,11 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运
<Route author="fengkx" example="/natgeo/environment/article" path="/natgeo/:cat/:type?" :paramsDesc="['分类', '类型, 例如`https://www.natgeomedia.com/environment/photo/`对应 cat, type 分别为 environment, photo']"/>
## 活动行
### 最新活动
<Route author="kfgamehacker" example="/huodongxing/explore" path="/huodongxing/explore"/>
## 马蜂窝
### 游记

View File

@@ -1453,6 +1453,9 @@ router.get('/sixthtone/news', require('./routes/sixthtone/news'));
// AI研习社
router.get('/aiyanxishe/:id/:sort?', require('./routes/aiyanxishe/home'));
// 活动行
router.get('/huodongxing/explore', require('./routes/hdx/explore'));
// 飞客茶馆优惠信息
router.get('/flyertea/preferential', require('./routes/flyertea/preferential'));
router.get('/flyertea/creditcard/:bank', require('./routes/flyertea/creditcard'));

44
lib/routes/hdx/explore.js Normal file
View File

@@ -0,0 +1,44 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: 'https://www.huodongxing.com/eventlist',
});
const data = response.data;
const $ = cheerio.load(data);
const list = $('div.search-tab-content-item');
ctx.state.data = {
title: '活动行',
link: 'https://www.huodongxing.com/eventlist',
item:
list &&
list
.map((index, item) => {
item = $(item);
return {
title: item
.find('.item-title')
.text()
.trim(),
link: item.find('.item-title').attr('href'),
description:
item.find('.item-data').text() +
' ' +
item
.find('.item-dress')
.text()
.trim(),
author: item
.find('.user-name')
.text()
.trim(),
};
})
.get(),
};
};