From efd2bf23325baba4fc2fd1b9c5f174bfb7f8f7f1 Mon Sep 17 00:00:00 2001 From: Felix Hsu Date: Mon, 27 Feb 2023 18:40:54 +0800 Subject: [PATCH] fix(route): fix stats-cn (#11964) --- lib/v2/gov/stats/index.js | 2 +- lib/v2/gov/stats/utils.js | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/v2/gov/stats/index.js b/lib/v2/gov/stats/index.js index a9374bfcd..30e76eca4 100644 --- a/lib/v2/gov/stats/index.js +++ b/lib/v2/gov/stats/index.js @@ -8,7 +8,7 @@ module.exports = async (ctx) => { pathname = pathname === '' ? defaultPath : pathname.endsWith('/') ? pathname : pathname + '/'; const currentUrl = `${rootUrl}${pathname}`; - const { list, title } = await parseContList(currentUrl, 'ul.center_list_contlist li a:not([id])', ctx); + const { list, title } = await parseContList(currentUrl, 'ul.center_list_contlist li a:not([id]), ul.center_list_cont li a:not([id])', ctx); const items = await Promise.all(list.map((item) => parseXilan(item, ctx))); ctx.state.data = { diff --git a/lib/v2/gov/stats/utils.js b/lib/v2/gov/stats/utils.js index ef47ac621..e4fcbfd03 100644 --- a/lib/v2/gov/stats/utils.js +++ b/lib/v2/gov/stats/utils.js @@ -13,10 +13,12 @@ const parseContList = async (url, selector, ctx) => { .toArray() .map((item) => { item = $(item); + + const date = item.find('.cont_tit02').text() || item.next('.cont_tit02').text(); return { - title: item.find('.cont_tit03').text(), + title: item.find('.cont_tit03, .cont_tit01').text(), link: new URL(item.attr('href'), url).href, - pubDate: parseDate(item.find('.cont_tit02').text(), 'YYYY-MM-DD'), + pubDate: parseDate(date, 'YYYY-MM-DD'), }; }) .filter((item) => item.title); // exclude the empty title