From 18d243ad99db105317970fb61b35fffad44c47f3 Mon Sep 17 00:00:00 2001 From: StevenRCE0 <40051361+StevenRCE0@users.noreply.github.com> Date: Fri, 3 Jun 2022 12:25:19 +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=B7=AF=E7=94=B1,=20=E5=B9=B6=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E9=94=99=E8=AF=AF=E6=8A=9B=E5=87=BA=20(#9885)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Fix issue #9877 * Fix issue #9877 * Fix issue #9877 --- lib/v2/gcores/category.js | 6 +++++- lib/v2/gcores/tag.js | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/v2/gcores/category.js b/lib/v2/gcores/category.js index a289b33f0..eb63e6d8a 100644 --- a/lib/v2/gcores/category.js +++ b/lib/v2/gcores/category.js @@ -15,7 +15,7 @@ module.exports = async (ctx) => { const list = $('.original.am_card.original-normal') .map(function () { const item = { - url: $(this).find('a.am_card_content.original_content').attr('href'), + 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(), }; @@ -23,6 +23,10 @@ module.exports = async (ctx) => { }) .get(); + if (list.length > 0 && list.every((item) => item.url === undefined)) { + throw new Error('Article URL not found! Please submit an issue on GitHub.'); + } + const out = await Promise.all( list.map((item) => { const articleUrl = `https://www.gcores.com${item.url}`; diff --git a/lib/v2/gcores/tag.js b/lib/v2/gcores/tag.js index 8722ce162..a307b31c2 100644 --- a/lib/v2/gcores/tag.js +++ b/lib/v2/gcores/tag.js @@ -16,7 +16,7 @@ module.exports = async (ctx) => { const list = $('.original.am_card.original-normal') .map(function () { const item = { - url: $(this).find('a.am_card_content.original_content').attr('href'), + 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(), }; @@ -24,6 +24,10 @@ module.exports = async (ctx) => { }) .get(); + if (list.length > 0 && list.every((item) => item.url === undefined)) { + throw new Error('Article URL not found! Please submit an issue on GitHub.'); + } + const out = await Promise.all( list.map((item) => { const articleUrl = `https://www.gcores.com${item.url}`;