forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): add route for university: CTBU XXGG (DIYgod#18082)
* feat(route): add route for university: CTBU XXGS * update filename
- Loading branch information
Showing
2 changed files
with
57 additions
and
0 deletions.
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,7 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: '重庆工商大学', | ||
url: 'www.ctbu.edu.cn/', | ||
lang: 'zh-CN', | ||
}; |
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,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, | ||
}; | ||
} |