feat(route): add 北京协和医学院“4+4”试点班招生网通知公告 (#12419)

This commit is contained in:
Ethan Shen 2023-05-02 02:56:41 +08:00 committed by GitHub
parent 712c7d475c
commit 96b7af5cf4
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 87 additions and 0 deletions

View File

@ -362,6 +362,12 @@ pageClass: routes
由于学校官网对非大陆 IP 的访问存在限制,需自行部署。
:::
## 北京协和医学院
### “4+4” 试点班招生网通知公告
<Route author="nczitzk" example="/pumc/mdadmission" path="/pumc/mdadmission"/>
## 北京邮电大学
### 硕士研究生招生通知

View File

@ -0,0 +1,3 @@
module.exports = {
'/mdadmission': ['nczitzk'],
};

View File

@ -0,0 +1,62 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 100;
const rootUrl = 'https://mdadmission.pumc.edu.cn';
const currentUrl = `${rootUrl}/mdweb/site!noticeList?param.infoTypeId=&rows=${limit}&pages=1`;
const response = await got({
method: 'get',
url: currentUrl,
https: {
rejectUnauthorized: false,
},
});
const $ = cheerio.load(response.data);
let items = $('div.media')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('h4.media-heading a');
return {
title: a.text(),
link: new URL(a.attr('href'), currentUrl).href,
pubDate: parseDate(item.find('span').first().text(), 'DDYYYY-MM'),
};
});
items = await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
const detailResponse = await got({
method: 'get',
url: item.link,
https: {
rejectUnauthorized: false,
},
});
const content = cheerio.load(detailResponse.data);
content('h3').remove();
item.description = content('div.media-body div').last().html();
return item;
})
)
);
ctx.state.data = {
title: '北京协和医学院招生网 - 通知公告',
link: currentUrl,
item: items,
};
};

13
lib/v2/pumc/radar.js Normal file
View File

@ -0,0 +1,13 @@
module.exports = {
'pumc.edu.cn': {
_name: '北京协和医学院',
mdadmission: [
{
title: '“4+4”试点班招生网通知公告',
docs: 'https://docs.rsshub.app/university.html#bei-jing-xie-he-yi-xue-yuan',
source: ['/mdweb/site', '/'],
target: '/pumc/mdadmission',
},
],
},
};

3
lib/v2/pumc/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/mdadmission', require('./mdadmission'));
};