mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add 哈尔滨工业大学(深圳)新闻中心 (#6803)
This commit is contained in:
@@ -645,6 +645,18 @@ category 列表:
|
||||
部分文章需要经过统一身份认证后才能阅读全文。
|
||||
:::
|
||||
|
||||
## 哈尔滨工业大学(深圳)
|
||||
|
||||
### 哈尔滨工业大学(深圳) - 新闻中心
|
||||
|
||||
<Route author="yx1302317313" example="/hitsz/article/id-74" path="/hitsz/article/:category?" :paramsDesc="['分类名,默认为通知公告']" >
|
||||
|
||||
| 校区要闻 | 媒体报道 | 通知公告 | 综合新闻 | 校园动态 | 讲座论坛 | 热点专题 |
|
||||
| -------- | -------- | -------- | -------- | -------- | -------- | -------- |
|
||||
| id-116 | id-80 | id-74 | id-75 | id-77 | id-78 | id-79 |
|
||||
|
||||
</Route>
|
||||
|
||||
## 哈尔滨工业大学(威海)
|
||||
|
||||
### 今日工大 - 通知公告
|
||||
|
||||
@@ -636,6 +636,9 @@ router.get('/hhu/libNewsc', require('./routes/universities/hhu/libNewsc'));
|
||||
router.get('/hit/jwc', require('./routes/universities/hit/jwc'));
|
||||
router.get('/hit/today/:category', require('./routes/universities/hit/today'));
|
||||
|
||||
// 哈尔滨工业大学(深圳)
|
||||
router.get('/hitsz/article/:category?', require('./routes/universities/hitsz/article'));
|
||||
|
||||
// 哈尔滨工业大学(威海)
|
||||
router.get('/hitwh/today', require('./routes/universities/hitwh/today'));
|
||||
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const host = 'http://www.hitsz.edu.cn';
|
||||
const category = ctx.params.category || 'id-74';
|
||||
|
||||
const response = await got.get(`${host}/article/${category}.html`);
|
||||
const $ = cheerio.load(response.data);
|
||||
const category_name = $('div.title_page').text().trim();
|
||||
|
||||
const lists = $('.mainside_news ul li')
|
||||
.map((_, el) => ({
|
||||
title: $('a', el).text().trim(),
|
||||
link: `${host}${$('a', el).attr('href')}`,
|
||||
pubDate: new Date($('span[class=date]', el).text()).toUTCString(),
|
||||
}))
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
lists.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got.get(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
item.description =
|
||||
$('div.detail').html() &&
|
||||
$('div.detail')
|
||||
.html()
|
||||
.replace(/src="\//g, `src="${new URL('.', host).toString()}"`)
|
||||
.replace(/href="\//g, `href="${new URL('.', host).toString()}"`)
|
||||
.trim();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '哈尔滨工业大学(深圳)-' + category_name,
|
||||
link: `${host}/article/${category}.html`,
|
||||
description: '哈尔滨工业大学(深圳)-' + category_name,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user