diff --git a/docs/university.md b/docs/university.md index 78c0061687ae96..8d6e888c38d517 100644 --- a/docs/university.md +++ b/docs/university.md @@ -3402,6 +3402,22 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS +## 长江大学 + +### 动物科学学院 + + + +::: tip 提示 + +若订阅 [院情总览 - 通知公告](https://dongke.yangtzeu.edu.cn/yqzl/tzgg.htm),网址为 。截取 `https://dongke.yangtzeu.edu.cn` 到末尾 `.htm` 的部分 `/yqzl/tzgg` 作为参数,此时路由为 [`/yangtzeu/dongke/yqzl/tzgg`](https://rsshub.app/yangtzeu/dongke/yqzl/tzgg)。 + +若订阅子分类 [学生工作](https://dongke.yangtzeu.edu.cn/xsgz.htm),网址为 。截取 `https://dongke.yangtzeu.edu.cn` 到末尾 `.htm` 的部分 `/xsgz` 作为参数,此时路由为 [`/yangtzeu/dongke/xsgz`](https://rsshub.app/yangtzeu/dongke/xsgz)。 + +::: + + + ## 浙江大学 ### 普通栏目 如学术 / 图片 / 新闻等 diff --git a/lib/v2/gov/cac/index.js b/lib/v2/gov/cac/index.js index ac6b9060c527ea..95680d20a635bf 100644 --- a/lib/v2/gov/cac/index.js +++ b/lib/v2/gov/cac/index.js @@ -19,8 +19,8 @@ module.exports = async (ctx) => { .toArray() .map((item) => { const href = $(item).attr('href'); - if (href && href.startsWith('http://www.cac.gov.cn/')) { - const matchArray = href.match(/http:\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/); + if (href && href.match(/(?:http:)?\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/)) { + const matchArray = href.match(/(?:http:)?\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/); if (matchArray && matchArray.length > 2) { const path = matchArray[1]; const htmlName = matchArray[2]; @@ -41,14 +41,14 @@ module.exports = async (ctx) => { const completeUrl = pathList.find((item) => item && item.path === path).completeUrl; const { data: channelResponse } = await got(completeUrl); const $1 = cheerio.load(channelResponse); - const items = $1('li.clearfix') + const items = $1('div#loadingInfoPage li') .toArray() .map((item) => { const c = $1(item); const a = c.find('a'); const articleHref = a.attr('href'); const title = a.text(); - const date = parseDate(c.find('span.times').text()); + const date = parseDate(c.find('.times').text()); return { link: articleHref, pubDate: timezone(date), diff --git a/lib/v2/yangtzeu/dongke.js b/lib/v2/yangtzeu/dongke.js new file mode 100644 index 00000000000000..7fbb8f75365a9a --- /dev/null +++ b/lib/v2/yangtzeu/dongke.js @@ -0,0 +1,60 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10; + + const rootUrl = 'https://dongke.yangtzeu.edu.cn'; + const currentUrl = new URL(`${ctx.path.replace(/^\/dongke/, '') || '/yqzl/xyxw'}.htm`, rootUrl).href; + + const { data: response } = await got(currentUrl); + + const $ = cheerio.load(response); + + let items = $('ul.list-item li a') + .slice(0, limit) + .toArray() + .map((item) => { + item = $(item); + + return { + title: item.text(), + link: new URL(item.prop('href'), rootUrl).href, + }; + }); + + items = await Promise.all( + items.map((item) => + ctx.cache.tryGet(item.link, async () => { + const { data: detailResponse } = await got(item.link); + + const content = cheerio.load(detailResponse); + + item.title = content('title').text(); + item.description = content('div.v_news_content').html(); + item.category = content('meta[name="keywords"]').prop('content').split(','); + item.pubDate = timezone( + parseDate( + content('p.content-info') + .text() + .match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)[1] + ), + +8 + ); + + return item; + }) + ) + ); + + ctx.state.data = { + item: items, + title: $('title').text(), + link: currentUrl, + language: 'zh-cn', + image: new URL($('#head-img a img').prop('src'), rootUrl).href, + author: '长江大学动物科学学院', + }; +}; diff --git a/lib/v2/yangtzeu/maintainer.js b/lib/v2/yangtzeu/maintainer.js new file mode 100644 index 00000000000000..64885afd8ef880 --- /dev/null +++ b/lib/v2/yangtzeu/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/dongke/:path+': ['nczitzk'], +}; diff --git a/lib/v2/yangtzeu/radar.js b/lib/v2/yangtzeu/radar.js new file mode 100644 index 00000000000000..ef4425cffb9bd0 --- /dev/null +++ b/lib/v2/yangtzeu/radar.js @@ -0,0 +1,18 @@ +module.exports = { + 'yangtzeu.edu.cn': { + _name: '长江大学', + '.': [ + { + title: '动物科学学院', + docs: 'https://docs.rsshub.app/universities.html#chang-jiang-da-xue-dong-wu-ke-xue-xue-yuan', + source: ['/:category', '/'], + target: (params, url) => { + url = new URL(url); + const path = /\.edu\.cn(.*?)\.htm/.test(url.href) ? url.href.match(/\.edu\.cn(.*?)\.htm/)[1] : ''; + + return `/yangtzeu/dongke${path}`; + }, + }, + ], + }, +}; diff --git a/lib/v2/yangtzeu/router.js b/lib/v2/yangtzeu/router.js new file mode 100644 index 00000000000000..e7f1e3eaa7514d --- /dev/null +++ b/lib/v2/yangtzeu/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get(/dongke([\w-/]+)?/, require('./dongke')); +};