feat(route): add Peking Univ cls announcement (#13641)
* feat(route): add Peking Univ cls announcement * fix(route): CRLF to LF * Update lib/v2/pku/cls/announcement.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * update PR ---------
This commit is contained in:
parent
0d183fb129
commit
13f18e022d
|
|
@ -0,0 +1,42 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const homeUrl = 'https://bio.pku.edu.cn/homes/Index/news/21/21.html';
|
||||
|
||||
const baseUrl = 'https://bio.pku.edu.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got(homeUrl);
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('div.normal_list>ul a')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: $(item).find('p').text().trim(),
|
||||
pubDate: parseDate($(item).find('span.date').text()),
|
||||
link: baseUrl + $(item).attr('href'),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
item.description = $('div.page div.common_width div.col-md-9').first().html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '北京大学生命科学学院通知公告',
|
||||
link: homeUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
module.exports = {
|
||||
'/admission/sszs': ['pkuyjs'],
|
||||
'/bbs/hot': ['wooddance'],
|
||||
'/cls/announcement': ['william-swl'],
|
||||
'/cls/lecture': ['TPOB'],
|
||||
'/eecs/:type?': ['Ir1d'],
|
||||
'/hr/:category?': ['nczitzk'],
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ module.exports = {
|
|||
source: ['/homes/Index/news_jz/7/7.html', '/'],
|
||||
target: '/pku/cls/lecture',
|
||||
},
|
||||
{
|
||||
title: '生命科学学院通知公告',
|
||||
docs: 'https://docs.rsshub.app/routes/university#bei-jing-da-xue',
|
||||
source: ['/homes/Index/news/21/21.html', '/'],
|
||||
target: '/pku/cls/announcement',
|
||||
},
|
||||
],
|
||||
eecs: [
|
||||
{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
module.exports = function (router) {
|
||||
router.get('/admission/sszs', require('./pkuyjs'));
|
||||
router.get('/bbs/hot', require('./bbs/hot'));
|
||||
router.get('/cls/announcement', require('./cls/announcement'));
|
||||
router.get('/cls/lecture', require('./cls/lecture'));
|
||||
router.get('/eecs/:type?', require('./eecs'));
|
||||
router.get('/hr/:category?', require('./hr'));
|
||||
|
|
|
|||
|
|
@ -299,6 +299,10 @@ Note:[Source website](https://ece.umass.edu/seminar) may be empty when there's
|
|||
|
||||
<Route author="TPOB" example="/pku/cls/lecture" path="/pku/cls/lecture" radar="1" rssbud="1"/>
|
||||
|
||||
### 生命科学学院通知公告 {#bei-jing-da-xue-sheng-ming-ke-xue-xue-yuan-tong-zhi-gong-gao}
|
||||
|
||||
<Route author="william-swl" example="/pku/cls/announcement" path="/pku/cls/announcement" radar="1" rssbud="1"/>
|
||||
|
||||
### 北大未名 BBS 全站十大 {#bei-jing-da-xue-bei-da-wei-ming-bbs-quan-zhan-shi-da}
|
||||
|
||||
<Route author="wooddance" example="/pku/bbs/hot" path="/pku/bbs/hot" radar="1" rssbud="1">
|
||||
|
|
|
|||
Loading…
Reference in New Issue