diff --git a/lib/routes/dengekionline/new.js b/lib/routes/dengekionline/new.js index 06abf3c2f..5a7eaf072 100644 --- a/lib/routes/dengekionline/new.js +++ b/lib/routes/dengekionline/new.js @@ -64,21 +64,21 @@ module.exports = async (ctx) => { baseUrl: host, }); const data = response.data; - const link = response.link; + const link = response.url; // 过滤处理新闻列表数据 const $ = cheerio.load(data); - const list = $('ul.gNews_list').find('a'); + const list = $('a', 'ul.gNews_list'); const description = $('meta[name="description"]').attr('content'); // 整理信息 const item = await Promise.all( list .map(async (index, element) => { - const liArr = $(element).find('li'); - const date = $(element) - .find('time') - .attr('datetime'); + const liArr = $('li', element); + const date = $('time', element).attr('datetime'); const newLink = $(element).attr('href'); + // 新闻封面 + const cover = $('img', element); const category = liArr.map((index, li) => $(li).text()).get(); // 日本时区为东9区 const pubDate = new Date(`${date} GMT+0900`).toUTCString(); @@ -91,12 +91,8 @@ module.exports = async (ctx) => { }); const $ = cheerio.load(result.data); const title = $('.gEntry_title').text(); - const description = $('.gEntry_body') - .find('p') - .html(); - const author = $('.gEntry_athorList') - .find('dd') - .text(); + const description = $('p', '.gEntry_body').html(); + const author = $('dd', '.gEntry_athorList').text(); const info = { title: title, description: description, @@ -111,6 +107,13 @@ module.exports = async (ctx) => { link: newInfo.url, category: category, description: newInfo.description, + media: { + content: { + url: cover.attr('data-src'), + expression: 'full', + width: cover.attr('width'), + }, + }, author: newInfo.author, guid: newInfo.url, pubDate: pubDate,