From 97b651e924b5f72434c887f8d51c2cda51fa3d71 Mon Sep 17 00:00:00 2001 From: StevenRCE0 <40051361+StevenRCE0@users.noreply.github.com> Date: Thu, 8 Dec 2022 19:37:32 +0800 Subject: [PATCH] =?UTF-8?q?fix(route):=20=E4=BF=AE=E5=A4=8D=E6=9C=BA?= =?UTF-8?q?=E6=A0=B8=E7=BD=91=E8=B5=84=E8=AE=AF=20(#11412)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix(route): gcores/news * fix(route): gcores/category/news --- lib/v2/gcores/category.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/lib/v2/gcores/category.js b/lib/v2/gcores/category.js index eb63e6d8a..627d67929 100644 --- a/lib/v2/gcores/category.js +++ b/lib/v2/gcores/category.js @@ -12,16 +12,26 @@ module.exports = async (ctx) => { const $ = cheerio.load(data); const feedTitle = $('title').text(); - const list = $('.original.am_card.original-normal') - .map(function () { + let list; + if (category === 'news') { + list = $('a.news').map(function () { + const item = { + url: $(this).attr('href'), + title: $(this).find('.news_content>h3').text(), + }; + return item; + }); + } else { + list = $('.original.am_card.original-normal').map(function () { const item = { url: $(this).find('.am_card_inner>a').attr('href'), title: $(this).find('h3.am_card_title').text(), category: $(this).find('span.original_category>a').text(), }; return item; - }) - .get(); + }); + } + list = list.get(); if (list.length > 0 && list.every((item) => item.url === undefined)) { throw new Error('Article URL not found! Please submit an issue on GitHub.'); @@ -85,13 +95,13 @@ module.exports = async (ctx) => { $('.story_hidden').replaceWith(''); const content = $('.story.story-show').html(); - return { + const basicItem = { title: item.title, description: cover + content, - category: item.category, link: articleUrl, guid: articleUrl, }; + return category === 'news' ? basicItem : { ...basicItem, category: item.category }; }); }) );