feat(route): add route for https://jw.cdu.edu.cn/ (#16548)

* feat(route): add route for https://jw.cdu.edu.cn/

添加了成都大学教务处公告通知

* Update jwgg.ts

gwgg-->jwgg

* Update jwgg.ts

https://jw.cdu.edu.cn/jwgg.html-->https://jw.cdu.edu.cn/jwgg.htm

* Delete lib/cdu directory

incorrect directory place

* Add files via upload

add cdu

* Add files via upload

fix:
Enforce consistent linebreak style
Error
Expected linebreaks to be 'LF' but found 'CRLF'.

* Add files via upload

fix namespace.ts's
Error
Expected linebreaks to be 'LF' but found 'CRLF'.

* Add files via upload

correct some errors

* Add files via upload

修复了不匹配问题

* Update jwgg.ts

////-->/**/

* Update jwgg.ts

Enforce consistent spacing after the `//` or `/*` in a comment
one tab

* Update jwgg.ts

A space has been added after /*

* Add files via upload

description repair try

* Update jwgg.ts

A space has been added after /*

* Update lib/routes/cdu/jwgg.ts

update maintainers

Co-authored-by: Tony <TonyRL@users.noreply.github.com>

* Update jwgg.ts

/**/ was used instead of ////

* Update lib/routes/cdu/namespace.ts

---------
This commit is contained in:
uuwor 2024-08-30 02:02:48 +08:00 committed by GitHub
parent d1a4598aad
commit e884dc438f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 85 additions and 0 deletions

79
lib/routes/cdu/jwgg.ts Normal file
View File

@ -0,0 +1,79 @@
import { Route } from '@/types';
import cache from '@/utils/cache';
import got from '@/utils/got';
import { load } from 'cheerio';
import { parseDate } from '@/utils/parse-date';
import timezone from '@/utils/timezone';
export const route: Route = {
path: '/jwgg',
categories: ['university'],
example: '/cdu/jwgg',
parameters: {},
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['jw.cdu.edu.cn/'],
},
],
name: '教务处通知公告',
maintainers: ['uuwor'],
handler,
url: 'jw.cdu.edu.cn/',
};
async function handler() {
const url = 'https://jw.cdu.edu.cn/jwgg.htm';// 数据来源网页(待提取网页)
const response = await got.get(url);
const data = response.data;
const $ = load(data);
const list = $('.ListTable.dataTable.no-footer tbody tr[role="row"].odd')
.slice(0, 10)
.toArray()
.map((e) => {
const element = $(e);
const title = element.find('tr.odd a').text().trim();/* 1. tr.odd a class="odd" <tr> <a>
2..text()
3..trim()*/
const link = element.find('tr.odd a').attr('href');
const date = element
.find('tr.odd td.columnDate')
.text()
.match(/\d{4}-\d{2}-\d{2}/);
const pubDate = timezone(parseDate(date), 8);
return {
title,
link: 'https://jw.cdu.edu.cn/' + link,
author: '成都大学教务处通知公告',
pubDate,
};
});
const result = await Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
const itemReponse = await got.get(item.link);
const data = itemReponse.data;
const itemElement = load(data);
item.description = itemElement('.v_news_content').html();
return item;
})
)
);
return {
title: '成大教务处通知公告',
link: url,
item: result,
};
}

View File

@ -0,0 +1,6 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: '成都大学',
url: 'www.cdu.edu.cn',
};