diff --git a/lib/routes/yystv/category.js b/lib/routes/yystv/category.js index ef48c0de2..67ce52195 100644 --- a/lib/routes/yystv/category.js +++ b/lib/routes/yystv/category.js @@ -39,9 +39,27 @@ module.exports = async (ctx) => { }) .get(); - ctx.state.data = { - title: '游研社-' + $('title').text(), - link: 'http://www.yystv.cn/b/recommend', - item: first_part.concat(second_part), - }; + const items = first_part.concat(second_part); + function getDescription(items) { + return Promise.all( + items.map(async function (currentValue) { + currentValue.description = await ctx.cache.tryGet(currentValue.link, async () => { + const r = await got({ + url: currentValue.link, + method: 'get', + }); + const $ = cheerio.load(r.data); + return $('.doc-content div').html(); + }); + return currentValue; + }) + ); + } + await getDescription(items).then(function () { + ctx.state.data = { + title: '游研社-' + $('title').text(), + link: `http://www.yystv.cn/b/${category}`, + item: items, + }; + }); };