This commit is contained in:
prnake
2020-07-29 14:24:53 +01:00
committed by GitHub
parent c4e15f5a21
commit 8779ad1689
+5 -4
View File
@@ -1,12 +1,13 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const url_resolve = require('url').resolve;
// 获取通知详情
async function load_detail(list, cache) {
return await Promise.all(
list.map(async (item) => {
const notice_item = cheerio.load(item);
const url = notice_item('a').attr('href');
const url = url_resolve('http://jwc.scu.edu.cn', notice_item('a').attr('href'));
return await cache.tryGet(url, async () => {
const detail_response = await got({
method: 'get',
@@ -16,11 +17,11 @@ async function load_detail(list, cache) {
},
});
const detail = cheerio.load(detail_response.data);
const date_part = detail('.list-main-content > .list-a-content > .page-date > span').text().slice(6, 16).split('-');
const date_part = detail('.page-date > span').text().slice(5, 15).split('-');
const date = new Date(date_part[0], date_part[1] - 1, date_part[2]);
return {
title: notice_item('li').attr('title'),
description: detail('.list-main-content > .list-a-content > .page-content').html(),
title: detail('.page-title').text(),
description: detail('.page-content').html(),
pubDate: date,
link: url,
};