feat(route): add 东北大学医学与生物信息工程学院 (#10349)
* feat(route): add 东北大学医学与生物信息工程学院 * Update lib/routes/universities/neu/bmie.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * Update lib/routes/universities/neu/bmie.js Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix(route): 更新BMIE 格式化日期、采用V2路由 * Apply suggestions from code review Co-authored-by: Tony <TonyRL@users.noreply.github.com> * fix(route):采用 pubDate 解析 * refactor: migrate to v2 Co-authored-by: Athena <qingcaomc+zen@gmail.com>
This commit is contained in:
parent
640c3102cd
commit
1d6a70a152
|
|
@ -891,13 +891,51 @@ xskb1 对应 <http://www.auto.uestc.edu.cn/index/xskb1.htm>
|
|||
|
||||
## 东北大学
|
||||
|
||||
### 东北大学新闻网
|
||||
### 新闻网
|
||||
|
||||
<Route author="JeasonLau" example="/neu/news/ddyw" path="/neu/news/:type" :paramsDesc="['种类名']">
|
||||
<Route author="JeasonLau" example="/neu/news/ddyw" path="/neu/news/:type" :paramsDesc="['种类名,见下表']">
|
||||
|
||||
| 东大要闻 | 媒体东大 | 通知公告 | 新闻纵横 | 人才培养 | 学术科研 | 英文新闻 | 招生就业 | 考研出国 | 校园文学 | 校友风采 | 时事热点 | 教育前沿 | 文化体育 | 最新科技 |
|
||||
| ---- | ---- | ---- | ---- | ---: | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- | ---- |
|
||||
| ddyw | mtdd | tzgg | xwzh | rcpy | xsky | 217 | zsjy | kycg | xywx | xyfc | ssrd | jyqy | whty | zxkj |
|
||||
| 种类名 | 参数 |
|
||||
| ---- | ---- |
|
||||
| 东大要闻 | ddyw |
|
||||
| 媒体东大 | mtdd |
|
||||
| 通知公告 | tzgg |
|
||||
| 新闻纵横 | xwzh |
|
||||
| 人才培养 | rcpy |
|
||||
| 学术科研 | xsky |
|
||||
| 英文新闻 | 217 |
|
||||
| 招生就业 | zsjy |
|
||||
| 考研出国 | kycg |
|
||||
| 校园文学 | xywx |
|
||||
| 校友风采 | xyfc |
|
||||
| 时事热点 | ssrd |
|
||||
| 教育前沿 | jyqy |
|
||||
| 文化体育 | whty |
|
||||
| 最新科技 | zxkj |
|
||||
|
||||
</Route>
|
||||
|
||||
### 医学与生物信息工程学院
|
||||
|
||||
<Route author="TennousuAthena" example="/neu/bmie/news" path="/neu/bmie/:type" :paramsDesc="['分类 id 见下表']">
|
||||
|
||||
| Id | 名称 |
|
||||
| ---------------------- | ----- |
|
||||
| news | 学院新闻 |
|
||||
| academic | 学术科研 |
|
||||
| talent_development | 人才培养 |
|
||||
| international_exchange | 国际交流 |
|
||||
| announcement | 通知公告 |
|
||||
| undergraduate_dev | 本科生培养 |
|
||||
| postgraduate_dev | 研究生培养 |
|
||||
| undergraduate_recruit | 本科生招募 |
|
||||
| postgraduate_recruit | 研究生招募 |
|
||||
| CPC_build | 党的建设 |
|
||||
| CPC_work | 党委工作 |
|
||||
| union_work | 工会工作 |
|
||||
| CYL_work | 共青团工作 |
|
||||
| security_management | 安全管理 |
|
||||
| alumni_style | 校友风采 |
|
||||
|
||||
</Route>
|
||||
|
||||
|
|
|
|||
|
|
@ -2473,7 +2473,7 @@ router.get('/haohaozhu/whole-house/:keyword?', lazyloadRouteHandler('./routes/ha
|
|||
router.get('/haohaozhu/discover/:keyword?', lazyloadRouteHandler('./routes/haohaozhu/discover'));
|
||||
|
||||
// 东北大学
|
||||
router.get('/neu/news/:type', lazyloadRouteHandler('./routes/universities/neu/news'));
|
||||
// router.get('/neu/news/:type', lazyloadRouteHandler('./routes/universities/neu/news'));
|
||||
|
||||
// 快递100
|
||||
router.get('/kuaidi100/track/:number/:id/:phone?', lazyloadRouteHandler('./routes/kuaidi100/index'));
|
||||
|
|
|
|||
|
|
@ -1,61 +0,0 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const baseUrl = 'https://neunews.neu.edu.cn';
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
const newsUrl = `${baseUrl}/${type}/list.htm`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: newsUrl,
|
||||
});
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const title = $('title').text();
|
||||
const items = $('.column-news-list > .news_list > .news > .news_title').slice(0, 5).get();
|
||||
const results = await Promise.all(
|
||||
items.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const title = $('a').attr('title');
|
||||
const url = baseUrl + $('a').attr('href');
|
||||
const description = await ctx.cache.tryGet(url, async () => {
|
||||
const result = await got.get(url);
|
||||
const $ = cheerio.load(result.data);
|
||||
// 处理部分格式
|
||||
$('article')
|
||||
.find('span')
|
||||
.each(function () {
|
||||
const temp = $(this).text();
|
||||
$(this).replaceWith(temp);
|
||||
});
|
||||
$('article')
|
||||
.find('div')
|
||||
.each(function () {
|
||||
const temp = $(this).html();
|
||||
$(this).replaceWith(temp);
|
||||
});
|
||||
$('article').find('a').remove();
|
||||
$('article')
|
||||
.find('p')
|
||||
.each(function () {
|
||||
$(this).removeAttr('style');
|
||||
$(this).removeAttr('class');
|
||||
});
|
||||
return $('article').html();
|
||||
});
|
||||
const result = {
|
||||
title,
|
||||
description,
|
||||
link: url,
|
||||
};
|
||||
return Promise.resolve(result);
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: `东北大学新闻网-${title}`,
|
||||
link: newsUrl,
|
||||
item: results,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,94 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const baseUrl = 'http://www.bmie.neu.edu.cn';
|
||||
|
||||
const map = {
|
||||
news: 561,
|
||||
academic: 562,
|
||||
talent_development: 563,
|
||||
international_exchange: 'gjjl3',
|
||||
announcement: 564,
|
||||
undergraduate_dev: 573,
|
||||
postgraduate_dev: 574,
|
||||
undergraduate_recruit: 'bks',
|
||||
postgraduate_recruit: 574,
|
||||
CPC_build: 556,
|
||||
CPC_work: 576,
|
||||
union_work: 577,
|
||||
CYL_work: 'gqtgz',
|
||||
security_management: 569,
|
||||
alumni_style: 557,
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
let type = ctx.params.type;
|
||||
if (typeof map[type] !== 'undefined') {
|
||||
type = map[type];
|
||||
}
|
||||
const newsUrl = `${baseUrl}/${type}/list.htm`;
|
||||
const response = await got(newsUrl);
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const title = $('title').text();
|
||||
const items = $('#subIndex > div.main_frame_sub > div.detail_sub > div > div > div > ul > li').slice(0, 7).get();
|
||||
const results = await Promise.all(
|
||||
items.map(async (item) => {
|
||||
const $ = cheerio.load(item);
|
||||
const title = $('a').attr('title');
|
||||
const url = baseUrl + $('a').attr('href');
|
||||
const data = await ctx.cache.tryGet(url, async () => {
|
||||
const result = await got(url);
|
||||
const $ = cheerio.load(result.data);
|
||||
|
||||
const info = $($('.ny_con p')[1]).text();
|
||||
const s = info.search(/\d{4}-\d{2}-\d{2}/);
|
||||
const date = info.substring(s, s + 10);
|
||||
|
||||
const au_start = info.indexOf('作者:') + 3;
|
||||
const au_end = info.lastIndexOf('|');
|
||||
const auhor = info.substring(au_start, au_end).trim();
|
||||
$('.entry')
|
||||
.find('span')
|
||||
.each(function () {
|
||||
const temp = $(this).text();
|
||||
$(this).replaceWith(temp);
|
||||
});
|
||||
$('.entry')
|
||||
.find('div')
|
||||
.each(function () {
|
||||
const temp = $(this).html();
|
||||
$(this).replaceWith(temp);
|
||||
});
|
||||
$('.entry').find('a').remove();
|
||||
$('.entry')
|
||||
.find('p')
|
||||
.each(function () {
|
||||
$(this).removeAttr('style');
|
||||
$(this).removeAttr('class');
|
||||
});
|
||||
$('.wp_art_adjoin').remove();
|
||||
return { description: $('.entry').html(), date, author: auhor };
|
||||
});
|
||||
const description = data.description;
|
||||
const pubDate = parseDate(data.date);
|
||||
const author = data.author;
|
||||
const result = {
|
||||
title,
|
||||
description,
|
||||
link: url,
|
||||
pubDate,
|
||||
author,
|
||||
};
|
||||
return result;
|
||||
})
|
||||
);
|
||||
ctx.state.data = {
|
||||
title: `东北大学 医学与生物信息工程学院 ${title}`,
|
||||
link: newsUrl,
|
||||
item: results,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = {
|
||||
'/bmie/:type': ['tennousuathena'],
|
||||
'/news/:type': ['JeasonLau'],
|
||||
};
|
||||
|
|
@ -0,0 +1,44 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const baseUrl = 'https://neunews.neu.edu.cn';
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const type = ctx.params.type;
|
||||
const newsUrl = `${baseUrl}/${type}/list.htm`;
|
||||
const response = await got(newsUrl);
|
||||
|
||||
const data = response.data;
|
||||
const $ = cheerio.load(data);
|
||||
|
||||
const items = $('.column-news-list > .news_list > .news')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('a').attr('title'),
|
||||
link: new URL(item.find('a').attr('href'), baseUrl).href,
|
||||
pubDate: parseDate(item.find('.news_meta').text(), 'YYYY-MM-DD'),
|
||||
};
|
||||
});
|
||||
|
||||
const results = await Promise.all(
|
||||
items.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const result = await got(item.link);
|
||||
const $ = cheerio.load(result.data);
|
||||
|
||||
item.author = $('.arti-metas').text().split('更新日期')[0];
|
||||
item.description = $('.article_content').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `东北大学新闻网-${$('head title').text()}`,
|
||||
link: newsUrl,
|
||||
item: results,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,21 @@
|
|||
module.exports = {
|
||||
'neu.edu.cn': {
|
||||
_name: '东北大学',
|
||||
neunews: [
|
||||
{
|
||||
title: '新闻网',
|
||||
docs: 'https://docs.rsshub.app/university.html#dong-bei-da-xue',
|
||||
source: ['/:type/list.htm'],
|
||||
target: '/neu/news/:type',
|
||||
},
|
||||
],
|
||||
'www.bmie': [
|
||||
{
|
||||
title: '学院新闻 - 医学与生物信息工程学院',
|
||||
docs: 'https://docs.rsshub.app/university.html#dong-bei-da-xue',
|
||||
source: ['/'],
|
||||
target: '/neu/bmie/news',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,4 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/bmie/:type', require('./bmie'));
|
||||
router.get('/news/:type', require('./news'));
|
||||
};
|
||||
Loading…
Reference in New Issue