mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-06 05:03:44 +08:00
fix: 后续live & feat: 中国地质大学(武汉) 研究生院综合通知公告 (#3074)
* fix: 后续live * feat: 中国地质大学(武汉) 研究生院综合通知公告
This commit is contained in:
@@ -301,13 +301,7 @@ pageClass: routes
|
||||
|
||||
### Live
|
||||
|
||||
<Route author="ciaranchen" example="/houxu/live/5/original" path="/houxu/live/:id/:timeline?" :paramsDesc="['Live ID', '时间线筛选条件。默认为all。']">
|
||||
|
||||
| 全部 | 原创 | 精选 |
|
||||
| ---- | -------- | -------- |
|
||||
| all | original | featured |
|
||||
|
||||
</Route>
|
||||
<Route author="ciaranchen sanmmm" example="/houxu/live/5" path="/houxu/live/:id" :paramsDesc="['Live ID']" />
|
||||
|
||||
### 最新 Live
|
||||
|
||||
|
||||
@@ -995,6 +995,12 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet
|
||||
|
||||
<Route author="YunYouJun" example="/cuc/yz" path="/cuc/yz" />
|
||||
|
||||
## 中国地质大学(武汉)
|
||||
|
||||
### 研究生院综合通知公告
|
||||
|
||||
<Route author="sanmmm" example="/cug/graduate" path="/cug/graduate" />
|
||||
|
||||
## 中国科学院
|
||||
|
||||
### 上海微系统与信息技术研究所学术活动
|
||||
|
||||
@@ -1717,4 +1717,7 @@ router.get('/engadget-cn', require('./routes/engadget-cn/home'));
|
||||
// 吹牛部落
|
||||
router.get('/chuiniu/column/:id', require('./routes/chuiniu/column'));
|
||||
|
||||
// 中国地质大学
|
||||
router.get('/cug/graduate', require('./routes/cug/graduate'));
|
||||
|
||||
module.exports = router;
|
||||
|
||||
46
lib/routes/cug/graduate.js
Normal file
46
lib/routes/cug/graduate.js
Normal file
@@ -0,0 +1,46 @@
|
||||
const cheerio = require('cheerio');
|
||||
const got = require('@/utils/got');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'http://graduate.cug.edu.cn';
|
||||
const reqUrl = `${baseUrl}/zhtzgg.htm`;
|
||||
const res = await got(reqUrl);
|
||||
const selector = 'div.mainWrap > div.main_con > div.main_conR.main_conRa > div.main_conRCb > ul > li';
|
||||
const links = cheerio
|
||||
.load(res.data)(selector)
|
||||
.map((_, ele) => {
|
||||
const $item = cheerio.load(ele);
|
||||
const link = `${baseUrl}/${$item('a').attr('href')}`;
|
||||
return link;
|
||||
})
|
||||
.get();
|
||||
const item = await Promise.all(
|
||||
links.map((link) =>
|
||||
ctx.cache.tryGet(`cug/${link}`, async () => {
|
||||
const res = await got(link);
|
||||
const $ = cheerio.load(res.data);
|
||||
const mainNode = $('.main_content');
|
||||
const description = mainNode.find('.main_conDiv').html();
|
||||
const title = mainNode.find('.main_contit h2').text();
|
||||
const pubTime = mainNode
|
||||
.find('.main_contit p')
|
||||
.text()
|
||||
.split(' ')
|
||||
.find((s) => s.includes('时间'))
|
||||
.replace('时间:', '');
|
||||
return {
|
||||
title,
|
||||
description,
|
||||
pubDate: new Date(pubTime).toUTCString(),
|
||||
};
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '中国地址大学(武汉)研究生院 - 综合通知公告',
|
||||
description: '中国地址大学(武汉)研究生院 - 综合通知公告',
|
||||
link: `${baseUrl}/zhtzgg.htm`,
|
||||
item,
|
||||
};
|
||||
};
|
||||
@@ -1,46 +1,39 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id, timeline } = ctx.params;
|
||||
const filter = timeline ? timeline : 'all';
|
||||
const baseUrl = `https://houxu.app/lives/${id}?filter=${filter}`;
|
||||
const res = await got.get(baseUrl);
|
||||
const $ = cheerio.load(res.data);
|
||||
const { id } = ctx.params;
|
||||
const baseUrl = 'https://houxu.app';
|
||||
const baseInfoApi = `${baseUrl}/api/1/lives/${id}`;
|
||||
const { desc, title } = await ctx.cache.tryGet(baseInfoApi, async () => {
|
||||
const res = await got.get(baseInfoApi);
|
||||
const { summary: desc, title } = res.data;
|
||||
return {
|
||||
title,
|
||||
desc,
|
||||
};
|
||||
});
|
||||
|
||||
const itemsRes = await got(`${baseUrl}/api/1/lives/${id}/threads`, {
|
||||
query: {
|
||||
limit: 40,
|
||||
},
|
||||
});
|
||||
|
||||
const item = itemsRes.data.results.map((i) => {
|
||||
const { media, url, title, description, publish_at } = i.link;
|
||||
return {
|
||||
title,
|
||||
description: `${description}<br/><img src="${media.avatar_url}" />`,
|
||||
link: url,
|
||||
pubDate: new Date(publish_at).toUTCString(),
|
||||
author: media.name,
|
||||
};
|
||||
});
|
||||
|
||||
const list = $('section.threads > div');
|
||||
const out = list
|
||||
.map((_, el) => {
|
||||
const each = $(el);
|
||||
return {
|
||||
title:
|
||||
each
|
||||
.find('a')
|
||||
.first()
|
||||
.text()
|
||||
.trim() +
|
||||
' | ' +
|
||||
each
|
||||
.find('h3')
|
||||
.text()
|
||||
.trim(),
|
||||
description: each
|
||||
.find('.summary')
|
||||
.text()
|
||||
.trim(),
|
||||
link: each
|
||||
.find('a')
|
||||
.first()
|
||||
.attr('href'),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
ctx.state.data = {
|
||||
title: $('.large-title').text(),
|
||||
description: $('title')
|
||||
.text()
|
||||
.trim(),
|
||||
link: baseUrl,
|
||||
item: out,
|
||||
title,
|
||||
description: desc,
|
||||
link: `${baseUrl}/lives/${id}`,
|
||||
item,
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user