Skip to content

Commit

Permalink
feat(route): add 厦门大学经济学院科研动态 (#18126)
Browse files Browse the repository at this point in the history
* add 厦门大学经济学院科研动态

* Apply suggestions from code review

Thanks for the feedback! The change has been applied.

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

---------
  • Loading branch information
linsenwang authored Jan 15, 2025
1 parent 38ec0d4 commit 7a1a9b2
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
68 changes: 68 additions & 0 deletions lib/routes/xmu/kydt.ts
Original file line number Diff line number Diff line change
@@ -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,
};
}
9 changes: 9 additions & 0 deletions lib/routes/xmu/namespace.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
import type { Namespace } from '@/types';

export const namespace: Namespace = {
name: 'Xiamen University',
url: 'soe.xmu.edu.cn',
zh: {
name: '厦门大学经济学院',
},
};

0 comments on commit 7a1a9b2

Please sign in to comment.