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; + }) + ) + ), + }; +};