Skip to content

Commit

Permalink
feat(router/jlu): add JLU Phy (DIYgod#17323)
Browse files Browse the repository at this point in the history
* feat(router/jlu): add JLU Phy

* fix(router/jlu): add description

* fix(router/jlu): add parameters and features

* fix(router/jlu): check rule hope this
  • Loading branch information
tsurumi-yizhou authored Nov 4, 2024
1 parent 9783660 commit 7a11c6b
Showing 1 changed file with 55 additions and 0 deletions.
55 changes: 55 additions & 0 deletions lib/routes/jlu/phy/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';

export const route: Route = {
path: '/phy/:category/:column/:subcolumn?',
categories: ['university'],
example: '/jlu/phy/xzgz/tzgg',
parameters: {
category: '分类,为「行政工作」、「科学研究」、「人才培养」的拼音小写首字母。',
column: '栏目,当分类为「行政工作」时,为「通知公告」、「学院新闻」、「学院文件」的拼音小写首字母。当分类为「科学研究」时,为「科研动态」、「学术活动」的拼音小写首字母。当分类为「人才培养」时。为「本科生教育」、「研究生教育」、「学团工作」的拼音小写首字母。',
subcolumn: '子栏目。当栏目为「本科生教育」时,为「本科资讯」的拼音大写首字母,或为「教育思想大讨论系列活动」、「培养方案」的拼音小写首字母。当栏目为「研究生教育」时,为「教学通知」的拼音小写首字母。',
},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['phy.jlu.edu.cn/:category/:column', 'phy.jlu.edu.cn/:category/:column/:subcolumn'],
},
],
name: '物理学院',
maintainers: ['tsurumi-yizhou'],
url: 'phy.jlu.edu.cn',
handler: async (ctx) => {
const { category, column, subcolumn } = ctx.req.param();
const query = subcolumn ? `${column}/${subcolumn}` : column;
const response = await got(`https://phy.jlu.edu.cn/${category}/${query}.htm`);
const $ = load(response.body);
const list = $('.tit-list ul li');

return {
title: '吉林大学物理学院',
link: 'https://phy.jlu.edu.cn/',
description: '吉林大学物理学院',
item: list.toArray().map((item) => {
const element = $(item).find('a');
const title = element.find('.tl-top').find('h3').text().trim();
const link = element.attr('href')!.replaceAll('../', 'https://phy.jlu.edu.cn/');
const date = element.find('.tl-top').find('.tl-date');
const pubDate = date.find('span').text().replaceAll('/', '').trim() + '-' + date.find('b').text();
return {
title,
link,
pubDate: new Date(pubDate),
};
}),
};
},
};

0 comments on commit 7a11c6b

Please sign in to comment.