fix(route): 哈尔滨工业大学(威海)通知公告 (#9303)

* fix(route): 哈尔滨工业大学(威海)通知公告

* fix css selector

* fix: use parseDate
This commit is contained in:
swwind 2022-03-11 22:23:56 +08:00 committed by GitHub
parent 233f1c8152
commit 727f17a15f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 6 additions and 6 deletions

View File

@ -1,6 +1,6 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url = require('url');
const { parseDate } = require('@/utils/parse-date');
const baseUrl = 'http://today.hitwh.edu.cn';
@ -9,10 +9,10 @@ module.exports = async (ctx) => {
const { data } = response;
const $ = cheerio.load(data);
const type = (filename) => filename.split('.').pop();
const links = $('#righ_list ul li')
const links = $('.list_list_wrap > ul > li')
.map((_, el) => ({
pubDate: new Date($(el).find('font').text().substr(-10, 10)).toUTCString(),
link: url.resolve(baseUrl, $('a', el).attr('href')),
pubDate: parseDate($(el).find('.news-time2').text()),
link: new URL($(el).find('a').attr('href'), baseUrl).toString(),
title: $(el).find('a').text(),
}))
.get();
@ -30,8 +30,8 @@ module.exports = async (ctx) => {
$('div.wp_articlecontent').html() &&
$('div.wp_articlecontent')
.html()
.replace(/src="\//g, `src="${url.resolve(baseUrl, '.')}`)
.replace(/href="\//g, `href="${url.resolve(baseUrl, '.')}`)
.replace(/src="\//g, `src="${baseUrl}/`)
.replace(/href="\//g, `href="${baseUrl}/`)
.trim();
return item;
} else {