feat(route): add 厦门大学经济学院科研动态 (#18126)

* add 厦门大学经济学院科研动态

* Apply suggestions from code review

Thanks for the feedback! The change has been applied.

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

---------
This commit is contained in:
linsenwang 2025-01-15 11:04:11 +08:00 committed by GitHub
parent 38ec0d4a65
commit 7a1a9b2cf7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 77 additions and 0 deletions

68
lib/routes/xmu/kydt.ts Normal file
View File

@ -0,0 +1,68 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
import cache from '@/utils/cache';
export const route: Route = {
path: '/kydt',
categories: ['university'],
example: '/xmu/kydt',
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
radar: [
{
source: ['soe.xmu.edu.cn/kxyj/kydt.htm'],
},
],
name: '科研动态',
maintainers: ['linsenwang'],
handler,
};
async function handler() {
const host = 'https://soe.xmu.edu.cn/kxyj/kydt.htm';
const response = await ofetch(host);
const $ = load(response);
const list = $('div.news li')
.toArray()
.map((item) => {
item = $(item);
const title = item.find('h4').first().text();
const time = item.find('h6').first().text();
const a = item.find('a').first().attr('href');
const fullUrl = new URL(a, host).href;
return {
title,
link: fullUrl,
pubDate: time,
};
});
const items = await Promise.all(
list.map((item) =>
cache.tryGet(item.link, async () => {
const response = await ofetch(item.link);
const $ = load(response);
item.description = $('.v_news_content').first().html();
return item;
})
)
);
return {
allowEmpty: true,
title: '厦门大学经济学院科研动态',
link: host,
item: items,
};
}

View File

@ -0,0 +1,9 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Xiamen University',
url: 'soe.xmu.edu.cn',
zh: {
name: '厦门大学经济学院',
},
};