From b29503e31b33ef3ef23a57f92c7bd1955155ada3 Mon Sep 17 00:00:00 2001
From: zjh <3046308220@qq.com>
Date: Fri, 3 Apr 2026 21:41:19 +0800
Subject: [PATCH 1/2] feat(router/nwpu): add computer science school
announcements route
---
lib/routes/nwpu/jsj.ts | 74 ++++++++++++++++++++++++++++++++++++
lib/routes/nwpu/namespace.ts | 6 +++
2 files changed, 80 insertions(+)
create mode 100644 lib/routes/nwpu/jsj.ts
create mode 100644 lib/routes/nwpu/namespace.ts
diff --git a/lib/routes/nwpu/jsj.ts b/lib/routes/nwpu/jsj.ts
new file mode 100644
index 000000000000..c6fdf8352190
--- /dev/null
+++ b/lib/routes/nwpu/jsj.ts
@@ -0,0 +1,74 @@
+import { load } from 'cheerio';
+
+import type { Route } from '@/types';
+import ofetch from '@/utils/ofetch';
+import { parseDate } from '@/utils/parse-date';
+
+export const route: Route = {
+ path: '/jsj/:channelId?',
+ categories: ['university'],
+ example: '/nwpu/jsj/1599',
+ parameters: { channelId: '栏目 ID,默认为 1599(通知公告)' },
+ features: {
+ requireConfig: false,
+ requirePuppeteer: false,
+ antiCrawler: false,
+ supportBT: false,
+ supportPodcast: false,
+ supportScihub: false,
+ },
+ radar: [
+ {
+ source: ['jsj.nwpu.edu.cn/snew/list.jsp'],
+ target: '/jsj/1599',
+ },
+ ],
+ name: '计算机学院通知公告',
+ maintainers: [],
+ handler,
+};
+
+async function handler(ctx) {
+ const channelId = ctx.req.param('channelId') || '1599';
+ const baseUrl = 'https://jsj.nwpu.edu.cn';
+ const listUrl = `${baseUrl}/snew/list.jsp`;
+
+ const response = await ofetch(listUrl, {
+ query: {
+ urltype: 'tree.TreeTempUrl',
+ wbtreeid: channelId,
+ },
+ });
+
+ const $ = load(response);
+
+ // 内容在
下的 - 中,格式为:
- 日期标题
+ const items = $('div.cno-right > UL > LI')
+ .toArray()
+ .map((el) => {
+ const $el = $(el);
+ const span = $el.find('SPAN').first();
+ const a = $el.find('A').first();
+ const dateText = span.text().trim();
+ // 链接格式: ../info/1599/29115.htm
+ const href = a.attr('href');
+ if (!href) {
+ return null;
+ }
+ // 转换为完整 URL: https://jsj.nwpu.edu.cn/info/1599/29115.htm
+ const link = `${baseUrl}/${href.replaceAll('../', '')}`;
+
+ return {
+ title: a.text().trim(),
+ link,
+ pubDate: dateText ? parseDate(dateText) : undefined,
+ };
+ })
+ .filter((item): item is { title: string; link: string; pubDate: Date | undefined } => item !== null && !!item.title);
+
+ return {
+ title: '西北工业大学计算机学院通知公告',
+ link: `${baseUrl}/snew/list.jsp?urltype=tree.TreeTempUrl&wbtreeid=${channelId}`,
+ item: items,
+ };
+}
diff --git a/lib/routes/nwpu/namespace.ts b/lib/routes/nwpu/namespace.ts
new file mode 100644
index 000000000000..625addf73128
--- /dev/null
+++ b/lib/routes/nwpu/namespace.ts
@@ -0,0 +1,6 @@
+import type { Namespace } from '@/types';
+
+export const namespace: Namespace = {
+ name: '西北工业大学',
+ url: 'nwpu.edu.cn',
+};
\ No newline at end of file
From 279c640215351c7f077e65a1a0872db08ea43956 Mon Sep 17 00:00:00 2001
From: zjh <3046308220@qq.com>
Date: Sat, 11 Apr 2026 20:34:42 +0800
Subject: [PATCH 2/2] fix(router/nwpu): use lowercase selectors and remove
unnecessary .first()
---
lib/routes/nwpu/jsj.ts | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/lib/routes/nwpu/jsj.ts b/lib/routes/nwpu/jsj.ts
index c6fdf8352190..16924a410b47 100644
--- a/lib/routes/nwpu/jsj.ts
+++ b/lib/routes/nwpu/jsj.ts
@@ -42,13 +42,13 @@ async function handler(ctx) {
const $ = load(response);
- // 内容在 下的 - 中,格式为:
- 日期标题
- const items = $('div.cno-right > UL > LI')
+ // 内容在 下的 - 中,格式为:
- 日期标题
+ const items = $('div.cno-right > ul > li')
.toArray()
.map((el) => {
const $el = $(el);
- const span = $el.find('SPAN').first();
- const a = $el.find('A').first();
+ const span = $el.find('span');
+ const a = $el.find('a');
const dateText = span.text().trim();
// 链接格式: ../info/1599/29115.htm
const href = a.attr('href');