diff --git a/lib/routes/aliyun-kernel/index.js b/lib/routes/aliyun-kernel/index.js index 13297f2fd9..c62fba1859 100644 --- a/lib/routes/aliyun-kernel/index.js +++ b/lib/routes/aliyun-kernel/index.js @@ -14,21 +14,20 @@ module.exports = async (ctx) => { const data = response.data; const $ = cheerio.load(data); const list = $('.container .post-item').get(); - const ProcessFeed = (data) => { const $ = cheerio.load(data); // 提取内容 - return $('.container .post-content').html(); + return { + desc: $('.container .post-content').html(), + publish_time: $('.post-meta > time').attr('datetime'), + }; }; - const items = await Promise.all( list.map(async (item) => { const $ = cheerio.load(item); const $a = $('.article-title > a'); const link = baseUrl + $a.attr('href'); - // const publish_time = $('.date-label').text(); - const cache = await ctx.cache.get(link); if (cache) { return Promise.resolve(JSON.parse(cache)); @@ -38,14 +37,15 @@ module.exports = async (ctx) => { method: 'get', url: link, }); - - const description = ProcessFeed(response.data); + const feed = ProcessFeed(response.data); + const description = feed.desc; + const pubDate = feed.publish_time; const single = { title: $a.text(), description, link: link, - // pubDate: publish_time, + pubDate: pubDate, }; ctx.cache.set(link, JSON.stringify(single)); return Promise.resolve(single);