fix: 适配网信办页面更新 (#12792)

This commit is contained in:
drgnchan 2023-07-14 02:52:24 +08:00 committed by GitHub
parent 22670d331f
commit 58ec314787
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 4 deletions

View File

@ -19,8 +19,8 @@ module.exports = async (ctx) => {
.toArray()
.map((item) => {
const href = $(item).attr('href');
if (href && href.startsWith('http://www.cac.gov.cn/')) {
const matchArray = href.match(/http:\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/);
if (href && href.match(/(?:http:)?\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/)) {
const matchArray = href.match(/(?:http:)?\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/);
if (matchArray && matchArray.length > 2) {
const path = matchArray[1];
const htmlName = matchArray[2];
@ -41,14 +41,14 @@ module.exports = async (ctx) => {
const completeUrl = pathList.find((item) => item && item.path === path).completeUrl;
const { data: channelResponse } = await got(completeUrl);
const $1 = cheerio.load(channelResponse);
const items = $1('li.clearfix')
const items = $1('div#loadingInfoPage li')
.toArray()
.map((item) => {
const c = $1(item);
const a = c.find('a');
const articleHref = a.attr('href');
const title = a.text();
const date = parseDate(c.find('span.times').text());
const date = parseDate(c.find('.times').text());
return {
link: articleHref,
pubDate: timezone(date),