-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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 厦门大学经济学院科研动态 (#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> ---------
- Loading branch information
1 parent
38ec0d4
commit 7a1a9b2
Showing
2 changed files
with
77 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,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, | ||
}; | ||
} |
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,9 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Xiamen University', | ||
url: 'soe.xmu.edu.cn', | ||
zh: { | ||
name: '厦门大学经济学院', | ||
}, | ||
}; |