feat(route): add jwb of dgut (#19792)

* Add files via upload

* Add files via upload

* Delete dgut directory

* Add files via upload

* style: auto format

* Update jwb.ts

* Add files via upload

* style: auto format

* Add files via upload

* style: auto format

* Update namespace.ts

* Add files via upload

* Update jwb.ts

* Update lib/routes/dgut/jwb.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/dgut/jwb.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/dgut/jwb.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update lib/routes/dgut/namespace.ts

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update jwb.ts

---------

Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
This commit is contained in:
1200522928 2025-08-12 20:10:57 +08:00 committed by GitHub
parent 59a757dccb
commit de263cbba0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 82 additions and 0 deletions

73
lib/routes/dgut/jwb.ts Normal file
View File

@ -0,0 +1,73 @@
import { Route } from '@/types';
import cache from '@/utils/cache';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
export const route: Route = {
path: '/jwb/:type?',
categories: ['university'],
example: '/dgut/jwb/jwtz',
parameters: { type: '哪种通知,默认为教务通知' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
maintainers: ['1200522928'],
radar: [
{
source: ['jwb.dgut.edu.cn/tzgg/'],
target: '',
},
],
name: '教务部通知公告',
description: `| 教学动态 | 教务通知 | 教研通知 | 实践通知 | 产业学院 | 通识教育 |"杨振宁"班|招生信息 |采购公告 |
| ------- | ------- | ---------| --------| --------| ----------|---------|------- |--------|
| jxdt | jwtz | jytz | sjtz | cyxy | tsjy | yznb | zsxx | cggg |`,
handler,
};
async function handler(ctx) {
const { type = 'jwtz' } = ctx.req.param();
const url = `https://jwb.dgut.edu.cn/tzgg/${type}.htm`;
const baseurl = 'https://jwb.dgut.edu.cn/';
const response = await ofetch(url);
const $ = load(response);
const list = $('ul.ul-new4 > li')
.toArray()
.map((item) => {
const $li = $(item);
const $a = $li.find('a.con');
return {
title: $a.find('.tit').text().trim(),
pubDate: parseDate(`${$a.find('.year').text().trim()}-${$a.find('.day').text().trim()}`),
link: `${baseurl}${$a.attr('href')}`,
};
});
const items = await Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
const response = await ofetch(item.link);
const $ = load(response);
return {
...item,
description: $('div.v_news_content').first().html() || undefined,
};
})
)
);
return {
title: $('title').text(),
link: url,
allowEmpty: true,
item: items,
};
}

View File

@ -0,0 +1,9 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: '东莞理工学院',
url: 'www.dgut.edu.cn',
zh: {
name: '东莞理工学院',
},
};