Skip to content

Commit

Permalink
fix(route): fix stats-cn (DIYgod#11964)
Browse files Browse the repository at this point in the history
  • Loading branch information
bigfei authored Feb 27, 2023
1 parent 4698900 commit efd2bf2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
2 changes: 1 addition & 1 deletion lib/v2/gov/stats/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
6 changes: 4 additions & 2 deletions lib/v2/gov/stats/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit efd2bf2

Please sign in to comment.