From e8a40bc0d2b25857e6c568f0ec920fbfc831d5c0 Mon Sep 17 00:00:00 2001 From: "K.F.G.H" Date: Sun, 15 Sep 2019 12:38:32 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=B7=BB=E5=8A=A0=E6=B4=BB=E5=8A=A8?= =?UTF-8?q?=E8=A1=8C=20(#3075)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * add huodongxing route * add doc for huodongxing --- docs/travel.md | 5 +++++ lib/router.js | 3 +++ lib/routes/hdx/explore.js | 44 +++++++++++++++++++++++++++++++++++++++ 3 files changed, 52 insertions(+) create mode 100644 lib/routes/hdx/explore.js diff --git a/docs/travel.md b/docs/travel.md index 032eda47f4..57f8c73d4c 100644 --- a/docs/travel.md +++ b/docs/travel.md @@ -90,6 +90,11 @@ IATA 国际航空运输协会机场代码, 参见[维基百科 国际航空运 +## 活动行 + +### 最新活动 + + ## 马蜂窝 ### 游记 diff --git a/lib/router.js b/lib/router.js index f9f296ccc2..6197f10b4e 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/hdx/explore.js b/lib/routes/hdx/explore.js new file mode 100644 index 0000000000..6c846a7f55 --- /dev/null +++ b/lib/routes/hdx/explore.js @@ -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(), + }; +};