feat(route): add route for university: CTBU XXGG (#18082)
* feat(route): add route for university: CTBU XXGS * update filename
This commit is contained in:
@@ -0,0 +1,7 @@
|
||||
import type { Namespace } from '@/types';
|
||||
|
||||
export const namespace: Namespace = {
|
||||
name: '重庆工商大学',
|
||||
url: 'www.ctbu.edu.cn/',
|
||||
lang: 'zh-CN',
|
||||
};
|
||||
@@ -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,
|
||||
};
|
||||
}
|
||||
Reference in New Issue
Block a user