diff --git a/docs/new-media.md b/docs/new-media.md index 859b90d497..b66ee4cbff 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -301,13 +301,7 @@ pageClass: routes ### Live - - -| 全部 | 原创 | 精选 | -| ---- | -------- | -------- | -| all | original | featured | - - + ### 最新 Live diff --git a/docs/university.md b/docs/university.md index f3f116cc3c..541630f141 100644 --- a/docs/university.md +++ b/docs/university.md @@ -995,6 +995,12 @@ https://rsshub.app/**nuist**/`bulletin` 或 https://rsshub.app/**nuist**/`bullet +## 中国地质大学(武汉) + +### 研究生院综合通知公告 + + + ## 中国科学院 ### 上海微系统与信息技术研究所学术活动 diff --git a/lib/router.js b/lib/router.js index e322c1fa93..9cfc198ed1 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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; diff --git a/lib/routes/cug/graduate.js b/lib/routes/cug/graduate.js new file mode 100644 index 0000000000..40b5545bf3 --- /dev/null +++ b/lib/routes/cug/graduate.js @@ -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, + }; +}; diff --git a/lib/routes/houxu/live.js b/lib/routes/houxu/live.js index 70538fa5be..5a009ef2f7 100644 --- a/lib/routes/houxu/live.js +++ b/lib/routes/houxu/live.js @@ -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}
`, + 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, }; };