-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'DIYgod:master' into my-feature
- Loading branch information
Showing
31 changed files
with
446 additions
and
124 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
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
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
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
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
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
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
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
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
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
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
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
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,80 @@ | ||
import { Route } from '@/types'; | ||
import cache from '@/utils/cache'; | ||
import got from '@/utils/got'; | ||
import { load } from 'cheerio'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
const rootUrl = 'http://sec.hrbeu.edu.cn'; | ||
|
||
export const route: Route = { | ||
path: '/sec/:id', | ||
categories: ['university'], | ||
example: '/hrbeu/sec/xshd', | ||
parameters: { id: '栏目编号,由 `URL` 中获取。' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['sec.hrbeu.edu.cn/:id/list.htm'], | ||
}, | ||
], | ||
name: '船舶工程学院', | ||
maintainers: ['Chi-hong22'], | ||
handler, | ||
description: `| 学院要闻 | 学术活动 | 通知公告 | 学科方向 | | ||
| :------: | :------: |:------: | :------: | | ||
| xyyw | xshd | 229 | xkfx |`, | ||
}; | ||
|
||
async function handler(ctx) { | ||
const id = ctx.req.param('id'); | ||
const response = await got(`${rootUrl}/${id}/list.htm`, { | ||
headers: { | ||
Referer: rootUrl, | ||
}, | ||
}); | ||
|
||
const $ = load(response.data); | ||
|
||
const bigTitle = $('div [class=lanmuInnerMiddleBigClass_right]').find('div [portletmode=simpleColumnAttri]').text().replaceAll(/[\s·]/g, '').trim(); | ||
|
||
const list = $('li.list_item') | ||
.toArray() | ||
.map((item) => { | ||
let link = $(item).find('a').attr('href'); | ||
if (link && link.includes('page.htm')) { | ||
link = `${rootUrl}${link}`; | ||
} | ||
return { | ||
title: $(item).find('a').attr('title'), | ||
pubDate: parseDate($(item).find('span.Article_PublishDate').text()), | ||
link, | ||
}; | ||
}); | ||
|
||
const items = await Promise.all( | ||
list.map((item) => | ||
cache.tryGet(item.link, async () => { | ||
if (item.link.includes('page.htm')) { | ||
const detailResponse = await got(item.link); | ||
const content = load(detailResponse.data); | ||
item.description = content('div.wp_articlecontent').html(); | ||
} else { | ||
item.description = '本文需跳转,请点击标题后阅读'; | ||
} | ||
return item; | ||
}) | ||
) | ||
); | ||
|
||
return { | ||
title: '船舶工程学院 - ' + bigTitle, | ||
link: rootUrl.concat('/', id, '/list.htm'), | ||
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
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,11 @@ | ||
import type { Namespace } from '@/types'; | ||
|
||
export const namespace: Namespace = { | ||
name: 'Institute of Science Tokyo', | ||
url: 'isct.ac.jp', | ||
lang: 'ja', | ||
|
||
ja: { | ||
name: '東京科学大学', | ||
}, | ||
}; |
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,66 @@ | ||
import { Route } from '@/types'; | ||
import ofetch from '@/utils/ofetch'; | ||
import { parseDate } from '@/utils/parse-date'; | ||
import { decode } from 'entities'; | ||
|
||
interface NewsItem { | ||
ID: string; | ||
TITLE: string; | ||
PUBLISH_DATE: string; | ||
META_DESCRIPTION: string; | ||
MEDIA_CD: string; | ||
} | ||
|
||
export const route: Route = { | ||
path: '/news/:lang', | ||
categories: ['university'], | ||
example: '/isct/news/ja', | ||
parameters: { lang: 'language, could be ja or en' }, | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
radar: [ | ||
{ | ||
source: ['www.isct.ac.jp/:lang/news'], | ||
target: '/news/:lang', | ||
}, | ||
], | ||
name: 'News', | ||
maintainers: ['catyyy'], | ||
handler: async (ctx) => { | ||
const { lang = 'ja' } = ctx.req.param(); | ||
const response = await ofetch(`https://www.isct.ac.jp/expansion/get_media_list_json.php?lang_cd=${lang}`); | ||
|
||
const decodedResponse = decode(response); | ||
const data = JSON.parse(decodedResponse); | ||
const itemsArray: NewsItem[] = Object.values(data); | ||
|
||
const items = itemsArray.map((item) => ({ | ||
// 文章标题 | ||
title: item.TITLE, | ||
// 文章链接 | ||
link: 'news/' + item.MEDIA_CD, | ||
// 文章正文 | ||
description: item.META_DESCRIPTION, | ||
// 文章发布日期 | ||
pubDate: parseDate(item.PUBLISH_DATE), | ||
// 如果有的话,文章作者 | ||
// author: item.user.login, | ||
// 如果有的话,文章分类 | ||
// category: item.labels.map((label) => label.name), | ||
})); | ||
return { | ||
// 源标题 | ||
title: `ISCT News - ${lang}`, | ||
// 源链接 | ||
link: `https://www.isct.ac.jp/${lang}/news`, | ||
// 源文章 | ||
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
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
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
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
Oops, something went wrong.