feat: add 飘花电影网首页资源 (#4747)
This commit is contained in:
parent
f3acba5f9e
commit
7555cd685e
|
|
@ -383,6 +383,12 @@ pageClass: routes
|
|||
|
||||
<Route author="greatcodeeer" example="/pianyuan" path="/pianyuan" radar="1"/>
|
||||
|
||||
## 飘花电影网
|
||||
|
||||
### 今日热门
|
||||
|
||||
<Route author="nczitzk" example="/piaohua/hot" path="/piaohua/hot" />
|
||||
|
||||
## 蜻蜓 FM
|
||||
|
||||
### 专辑
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
})
|
||||
)
|
||||
),
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue