Skip to content

Commit

Permalink
feat(route): add route for university: CTBU XXGG (DIYgod#18082)
Browse files Browse the repository at this point in the history
* feat(route): add route for university: CTBU XXGS

* update filename
  • Loading branch information
Skylwn authored Jan 9, 2025
1 parent 4fb6d09 commit f7f73e8
Show file tree
Hide file tree
Showing 2 changed files with 57 additions and 0 deletions.
7 changes: 7 additions & 0 deletions lib/routes/ctbu/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: '重庆工商大学',
url: 'www.ctbu.edu.cn/',
lang: 'zh-CN',
};
50 changes: 50 additions & 0 deletions lib/routes/ctbu/xxgg.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
const baseURL = 'https://www.ctbu.edu.cn/index/xxgg.htm';

export const route: Route = {
path: '/xxgg',
categories: ['university'],
example: '/ctbu/xxgg',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['www.ctbu.edu.cn/', 'www.ctbu.edu.cn/index/xxgg.htm'],
},
],
name: '学校公告',
maintainers: ['Skylwn'],
handler,
url: 'www.ctbu.edu.cn/',
};

async function handler() {
const response = await got(baseURL);
const $ = load(response.data);
const items = $('li.clearfix')
.toArray()
.map((item) => {
item = $(item);
return {
title: item.find('a').attr('title'),
description: item.find('p').text(),
pubDate: parseDate(item.find('h6').text() + '-' + item.find('em').text(), 'YYYY-MM-DD'),
link: item.find('a').attr('href'),
};
});
return {
title: $('title').text(),
link: baseURL,
item: items,
};
}

0 comments on commit f7f73e8

Please sign in to comment.