fix(route): fix stats-cn (#11964)

This commit is contained in:
Felix Hsu 2023-02-27 18:40:54 +08:00 committed by GitHub
parent 4698900401
commit efd2bf2332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 3 deletions

View File

@ -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 = {

View File

@ -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