* refactor: fix scut namespace * refactor: fix gzhu namespace * refactor: fix scnu namespace * refactor: fix hust namespace * refactor: fix ccnu namespace * refactor: fix sustech namespace * refactor: fix szu namespace remove `/szuyjs` since it's a duplicate of `/szu/yz/:type?` * refactor: fix tongji namespace * refactor: fix ocu namespace * refactor: fix upc namespace * refactor: fix ucas namespace * refactor: fix cas namespace * refactor: fix cau namespace * refactor: remove `/cucyjs` since `/cuc/yz` existed well before that * refactor: fix bit namespace * refactor: fix **undocumented** scau namespace * fix: typo * fix: code scan
30 lines
965 B
JavaScript
Executable File
30 lines
965 B
JavaScript
Executable File
const got = require('@/utils/got');
|
|
const cheerio = require('cheerio');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
module.exports = async (ctx) => {
|
|
const { type } = ctx.params;
|
|
const baseUrl = 'https://aia.hust.edu.cn';
|
|
const link = `${baseUrl}/tzgg${type ? `/${type}` : ''}.htm`;
|
|
const response = await got(link);
|
|
const $ = cheerio.load(response.data);
|
|
const list = $('.list li');
|
|
const title = $('title').text();
|
|
|
|
ctx.state.data = {
|
|
title,
|
|
link,
|
|
item:
|
|
list &&
|
|
list.toArray().map((item) => {
|
|
item = $(item);
|
|
return {
|
|
title: item.find('a h2').text(),
|
|
description: item.find('a div').text() || title,
|
|
pubDate: parseDate(item.find('.date3').text(), 'DDYYYY-MM'),
|
|
link: new URL(item.find('a').attr('href'), link).href,
|
|
};
|
|
}),
|
|
};
|
|
};
|