fix: /douban/movie/later
This commit is contained in:
parent
ece2824c5e
commit
ccf3f04292
|
|
@ -1,19 +1,32 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: 'https://api.douban.com/v2/movie/coming_soon?apikey=0df993c66c0c636e29ecbb5344252a4a',
|
||||
url: 'https://movie.douban.com/cinema/later/beijing/',
|
||||
});
|
||||
const movieList = response.data.subjects;
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const item = $('#showing-soon .item')
|
||||
.map((index, ele) => {
|
||||
const description = $(ele).html();
|
||||
const name = $('h3', ele).text().trim();
|
||||
const date = $('ul li', ele).eq(0).text().trim();
|
||||
const type = $('ul li', ele).eq(1).text().trim();
|
||||
const link = $('a.thumb', ele).attr('href');
|
||||
|
||||
return {
|
||||
title: `${date} - 《${name}》 - ${type}`,
|
||||
link,
|
||||
description,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
ctx.state.data = {
|
||||
title: '即将上映的电影',
|
||||
link: 'https://movie.douban.com/cinema/later/',
|
||||
item: movieList.map((item) => ({
|
||||
title: item.title,
|
||||
description: `标题:${item.title}<br> 影片类型:${item.genres.join(' | ')} <br>评分:${item.rating.stars === '00' ? '无' : item.rating.average} <br/> <img src="${item.images.large}">`,
|
||||
link: item.alt,
|
||||
})),
|
||||
item,
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue