From 7555cd685e83b76bd8a30f9d9b453d1be00e423f Mon Sep 17 00:00:00 2001 From: Ethan Shen Date: Tue, 12 May 2020 14:25:04 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20add=20=E9=A3=98=E8=8A=B1=E7=94=B5?= =?UTF-8?q?=E5=BD=B1=E7=BD=91=E9=A6=96=E9=A1=B5=E8=B5=84=E6=BA=90=20(#4747?= =?UTF-8?q?)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/multimedia.md | 6 ++++++ lib/router.js | 3 +++ lib/routes/piaohua/hot.js | 38 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 47 insertions(+) create mode 100644 lib/routes/piaohua/hot.js diff --git a/docs/multimedia.md b/docs/multimedia.md index 3d6c85400..e1167946b 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -383,6 +383,12 @@ pageClass: routes +## 飘花电影网 + +### 今日热门 + + + ## 蜻蜓 FM ### 专辑 diff --git a/lib/router.js b/lib/router.js index 6edb1ece1..e83204351 100644 --- a/lib/router.js +++ b/lib/router.js @@ -2664,4 +2664,7 @@ router.get('/qingting/channel/:id', require('./routes/qingting/channel')); // 金色财经 router.get('/jinse/lives', require('./routes/jinse/lives')); +// 飘花电影网 +router.get('/piaohua/hot', require('./routes/piaohua/hot')); + module.exports = router; diff --git a/lib/routes/piaohua/hot.js b/lib/routes/piaohua/hot.js new file mode 100644 index 000000000..a50ca384f --- /dev/null +++ b/lib/routes/piaohua/hot.js @@ -0,0 +1,38 @@ +const url = require('url'); +const got = require('@/utils/got'); +const cheerio = require('cheerio'); + +module.exports = async (ctx) => { + const link = 'https://www.piaohua.com/'; + const response = await got({ + method: 'get', + url: link, + }); + const $ = cheerio.load(response.data); + const list = $('ul.ul-imgtxt1.row li') + .map((_, item) => { + item = $(item); + return { + title: item.find('h3').text(), + link: url.resolve(link, item.find('a').attr('href')), + pubDate: new Date(item.find('span').text()).toUTCString(), + }; + }) + .get(); + + ctx.state.data = { + title: '飘花电影网 - 今日推荐', + link: link, + item: await Promise.all( + list.map( + async (item) => + await ctx.cache.tryGet(item.link, async () => { + const detailResponse = await got({ method: 'get', url: item.link }); + const content = cheerio.load(detailResponse.data); + item.description = content('div.m-text1').html(); + return item; + }) + ) + ), + }; +};