* 添加了新的RSSHub路由,支持Radar ,以及修改了对应的文档 新增了针对南昌大学教务处通知的RSSHub路由,支持Radar。 同时修改了RSShub文档 * Removed redundant settings and fixed the year. 删去了多余的代码,更正了正确的年份 * 修改radar.js来修复问题 原来的radar无法正确识别网站,原来是url错误了,现在已经更改 * Update jwc.js * Refactor jwc.ts and remove unused files * Update dependencies * Refactor jwc.ts and remove unused files * Refactor jwc.ts and update newsDate calculation * Optimized date retrieval code: consolidated year and month retrieval into a single line * style: auto format * Refactor jwc.ts: Consolidate date retrieval code * Revert "Refactor jwc.ts: Consolidate date retrieval code" This reverts commit 353f70745cff2eff950d115a518b9f5750a4b1c7. * Revert "Optimized date retrieval code: consolidated year and month retrieval into a single line" This reverts commit e38bc31ab412b79842e74b8c86a1fe39277e2ca4. * Refactor jwc.ts: Consolidate date retrieval code and optimize newsDate calculation --------- Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
70 lines
2.0 KiB
TypeScript
70 lines
2.0 KiB
TypeScript
import { Route } from '@/types';
|
|
import got from '@/utils/got'; // 自订的 got
|
|
import { load } from 'cheerio'; // 可以使用类似 jQuery 的 API HTML 解析器
|
|
import { parseDate } from '@/utils/parse-date';
|
|
|
|
export const route: Route = {
|
|
path: '/jwc',
|
|
categories: ['university'],
|
|
example: '/ncu/jwc',
|
|
parameters: {},
|
|
features: {
|
|
requireConfig: false,
|
|
requirePuppeteer: false,
|
|
antiCrawler: false,
|
|
supportBT: false,
|
|
supportPodcast: false,
|
|
supportScihub: false,
|
|
},
|
|
radar: [
|
|
{
|
|
source: ['jwc.ncu.edu.cn/', 'jwc.ncu.edu.cn/jwtz/index.htm'],
|
|
},
|
|
],
|
|
name: '教务通知',
|
|
maintainers: ['ywh555hhh'],
|
|
handler,
|
|
url: 'jwc.ncu.edu.cn/',
|
|
};
|
|
|
|
async function handler() {
|
|
const baseUrl = 'https://jwc.ncu.edu.cn';
|
|
const response = await got(baseUrl);
|
|
const $ = load(response.body);
|
|
const currentDate = new Date();
|
|
const currentYear = currentDate.getFullYear();
|
|
const currentMonth = currentDate.getMonth() + 1;
|
|
|
|
const list = $('.box3 .inner ul.img-list li');
|
|
|
|
return {
|
|
title: '南昌大学教务处',
|
|
link: baseUrl,
|
|
description: '南昌大学教务处',
|
|
|
|
item:
|
|
list &&
|
|
list.toArray().map((item) => {
|
|
const el = $(item);
|
|
const linkEl = el.find('a');
|
|
const date = el.text().split('】')[0].replace('【', '').trim();
|
|
const title = linkEl.attr('title');
|
|
const link = `${baseUrl}/${linkEl.attr('href')}`;
|
|
|
|
const newsDate = parseDate(date, 'MM-DD');
|
|
const newsMonth = newsDate.getMonth() + 1;
|
|
|
|
// If the news month is greater than the current month, subtract 1 from the year
|
|
const year = newsMonth > currentMonth ? currentYear - 1 : currentYear;
|
|
|
|
newsDate.setFullYear(year);
|
|
|
|
return {
|
|
title,
|
|
link,
|
|
pubDate: newsDate,
|
|
};
|
|
}),
|
|
};
|
|
}
|