feat(route): add hdu/auto (#18046)
This commit is contained in:
@@ -0,0 +1,27 @@
|
||||
import { Route } from '@/types';
|
||||
import { fetchAutoNews } from './utils';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/auto/graduate',
|
||||
categories: ['university'],
|
||||
example: '/hdu/auto/graduate',
|
||||
parameters: {},
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '自动化学院 - 研究生教育通知',
|
||||
maintainers: ['jalenzz'],
|
||||
handler: () => fetchAutoNews('3754/list.htm', '研究生教育'),
|
||||
description: '杭州电子科技大学自动化学院研究生教育',
|
||||
radar: [
|
||||
{
|
||||
source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3754/list.htm'],
|
||||
target: '/auto/graduate',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Route } from '@/types';
|
||||
import { fetchAutoNews } from './utils';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/auto',
|
||||
categories: ['university'],
|
||||
example: '/hdu/auto',
|
||||
parameters: {},
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '自动化学院 - 通知公告',
|
||||
maintainers: ['jalenzz'],
|
||||
handler: () => fetchAutoNews('3779/list.htm', '通知公告'),
|
||||
description: '杭州电子科技大学自动化学院通知公告',
|
||||
radar: [
|
||||
{
|
||||
source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3779/list.htm'],
|
||||
target: '/auto',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Route } from '@/types';
|
||||
import { fetchAutoNews } from './utils';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/auto/student',
|
||||
categories: ['university'],
|
||||
example: '/hdu/auto/student',
|
||||
parameters: {},
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '自动化学院 - 学生工作',
|
||||
maintainers: ['jalenzz'],
|
||||
handler: () => fetchAutoNews('3726/list.htm', '学生工作'),
|
||||
description: '杭州电子科技大学自动化学院学生工作',
|
||||
radar: [
|
||||
{
|
||||
source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3726/list.htm'],
|
||||
target: '/auto/student',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,27 @@
|
||||
import { Route } from '@/types';
|
||||
import { fetchAutoNews } from './utils';
|
||||
|
||||
export const route: Route = {
|
||||
path: '/auto/undergraduate',
|
||||
categories: ['university'],
|
||||
example: '/hdu/auto/undergraduate',
|
||||
parameters: {},
|
||||
features: {
|
||||
requireConfig: false,
|
||||
requirePuppeteer: false,
|
||||
antiCrawler: false,
|
||||
supportBT: false,
|
||||
supportPodcast: false,
|
||||
supportScihub: false,
|
||||
},
|
||||
name: '自动化学院 - 本科教学',
|
||||
maintainers: ['jalenzz'],
|
||||
handler: () => fetchAutoNews('3745/list.htm', '本科教学'),
|
||||
description: '杭州电子科技大学自动化学院本科教学',
|
||||
radar: [
|
||||
{
|
||||
source: ['auto.hdu.edu.cn/main.htm', 'auto.hdu.edu.cn/3745/list.htm'],
|
||||
target: '/auto/undergraduate',
|
||||
},
|
||||
],
|
||||
};
|
||||
@@ -0,0 +1,51 @@
|
||||
import { Data, DataItem } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import { load } from 'cheerio';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
const BASE_URL = 'https://auto.hdu.edu.cn';
|
||||
|
||||
export const fetchAutoNews = async (path: string, title: string): Promise<Data> => {
|
||||
const link = `${BASE_URL}/${path}`;
|
||||
const response = await got(link);
|
||||
const $ = load(response.data);
|
||||
|
||||
const list = $('.rightlist')
|
||||
.toArray()
|
||||
.map((item): DataItem => {
|
||||
const $item = $(item);
|
||||
const $a = $item.find('.newstitle a');
|
||||
const href = $a.attr('href');
|
||||
const title = $a.text().trim();
|
||||
const dateMatch = $item
|
||||
.find('.newsinfo')
|
||||
.text()
|
||||
.match(/日期:(\d{4}\/\d{2}\/\d{2})/);
|
||||
const brief = $item.find('.newsbrief').text().trim();
|
||||
|
||||
return {
|
||||
title: title || '无标题',
|
||||
link: href ? new URL(href, BASE_URL).href : BASE_URL,
|
||||
pubDate: dateMatch ? parseDate(dateMatch[1], 'YYYY/MM/DD') : undefined,
|
||||
description: brief || '',
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
const { data } = await got(item.link);
|
||||
const $detail = load(data);
|
||||
const description = $detail('.wp_articlecontent').html();
|
||||
return { ...item, description: description || item.description };
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
return {
|
||||
title: `杭州电子科技大学自动化学院 - ${title}`,
|
||||
link,
|
||||
item: items as DataItem[],
|
||||
};
|
||||
};
|
||||
@@ -2,6 +2,6 @@ import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: '杭州电子科技大学',
|
||||
url: 'computer.hdu.edu.cn',
|
||||
url: 'hdu.edu.cn',
|
||||
lang: 'zh-CN',
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user