-
Notifications
You must be signed in to change notification settings - Fork 7.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
160 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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', | ||
}, | ||
], | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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[], | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters