feat(route): add jlujwc (#15747)

* feat: add jlujwc

* feat: add jlujwc

* feat: add jlujwc
This commit is contained in:
mayouxi 2024-05-28 23:01:21 +08:00 committed by GitHub
parent 9dcc83bc84
commit 2f33a3e81b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 61 additions and 0 deletions

55
lib/routes/jlu/jwc.ts Normal file
View File

@ -0,0 +1,55 @@
import { Route } from '@/types';
import got from '@/utils/got'; // 自订的 got
import { load } from 'cheerio'; // 可以使用类似 jQuery 的 API HTML 解析器
export const route: Route = {
path: '/jwc',
categories: ['university'],
example: '/jlu/jwc',
radar: [
{
source: ['jwc.jlu.edu.cn', 'jwc.jlu.edu.cn/index.htm'],
},
],
name: '教务通知',
maintainers: ['mayouxi'],
handler,
url: 'jwc.jlu.edu.cn',
};
async function handler() {
const baseUrl = 'https://jwc.jlu.edu.cn';
const response = await got(baseUrl);
const $ = load(response.body);
const list = $('.section2 .s2-r .s3-list ul li');
return {
title: '吉林大学教务处',
link: baseUrl,
description: '吉林大学教务处通知公告',
item: list?.toArray().map((item) => {
const el = $(item);
const linkEl = el.find('a');
const YMDiv = el.find('.tm p');
const YMStr = YMDiv.text().trim();
const DDiv = el.find('.tm span');
const DStr = DDiv.text().trim();
const titleDiv = el.find('.s3-info p');
const title = titleDiv.text().trim();
const link = `${baseUrl}/${linkEl.attr('href')}`;
const newsDate = new Date(YMStr + '-' + DStr);
return {
title,
link,
pubDate: newsDate,
};
}),
};
}

View File

@ -0,0 +1,6 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: '吉林大学',
url: 'jlu.edu.cn',
};