diff --git a/lib/v2/cas/genetics/index.js b/lib/v2/cas/genetics/index.js new file mode 100644 index 0000000000..577c16363d --- /dev/null +++ b/lib/v2/cas/genetics/index.js @@ -0,0 +1,63 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const baseUrl = 'https://genetics.cas.cn'; + +module.exports = async (ctx) => { + const { path } = ctx.params; + + const currentUrl = `${baseUrl}/${path}/`; + + const { data: response } = await got(currentUrl); + const $ = cheerio.load(response); + + let items; + + if (path.substring(0, 3) === 'edu') { + items = $('li.box-s.h16') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('a').first(); + const date = item.find('.box-date').first(); + return { + title: a.text(), + link: new URL(a.attr('href'), currentUrl).href, + pubDate: parseDate(date.text(), 'YYYY-MM-DD'), + }; + }); + } else if (path.substring(0, 4) === 'dqyd') { + items = $('div.list-tab ul li') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('a').first(); + const date = item.find('.right').first(); + return { + title: a.text(), + link: new URL(a.attr('href'), currentUrl).href, + pubDate: parseDate(date.text(), 'YYYY-MM-DD'), + }; + }); + } else { + items = $('li.row.no-gutters.py-1') + .toArray() + .map((item) => { + item = $(item); + const a = item.find('a').first(); + const date = item.find('.col-news-date').first(); + return { + title: a.text(), + link: new URL(a.attr('href'), currentUrl).href, + pubDate: parseDate(date.text(), 'YYYY.MM.DD'), + }; + }); + } + + ctx.state.data = { + title: $('head title').text(), + link: currentUrl, + item: items, + }; +}; diff --git a/lib/v2/cas/genetics/xshd.js b/lib/v2/cas/genetics/xshd.js deleted file mode 100644 index 6e4bbd836f..0000000000 --- a/lib/v2/cas/genetics/xshd.js +++ /dev/null @@ -1,29 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const { parseDate } = require('@/utils/parse-date'); - -module.exports = async (ctx) => { - const baseUrl = 'https://genetics.cas.cn/jixs/yg/'; - - const { data: response } = await got(baseUrl); - const $ = cheerio.load(response); - - const items = $('li.row.no-gutters.py-1') - .toArray() - .map((item) => { - item = $(item); - const a = item.find('a').first(); - const date = item.find('.col-news-date').first(); - return { - title: a.text(), - link: new URL(a.attr('href'), baseUrl).href, - pubDate: parseDate(date.text(), 'YYYY.MM.DD'), - }; - }); - - ctx.state.data = { - title: 'IGDB - 学术活动', - link: baseUrl, - item: items, - }; -}; diff --git a/lib/v2/cas/maintainer.js b/lib/v2/cas/maintainer.js index 0025b232fc..8409ff3ffa 100644 --- a/lib/v2/cas/maintainer.js +++ b/lib/v2/cas/maintainer.js @@ -1,6 +1,6 @@ module.exports = { '/cg/:caty?': ['nczitzk'], - '/genetics/xshd': ['panyq357'], + '/genetics/:path+': ['panyq357'], '/ia/yjs': ['shengmaosu'], '/iee/kydt': ['nczitzk'], '/is/:path+': ['Misaka13514'], diff --git a/lib/v2/cas/radar.js b/lib/v2/cas/radar.js index af51f17b8c..1a9bd7a2e2 100644 --- a/lib/v2/cas/radar.js +++ b/lib/v2/cas/radar.js @@ -11,10 +11,10 @@ module.exports = { ], 'www.genetics': [ { - title: '遗传与生物学研究所 - 学术活动', + title: '遗传与发育生物学研究所', docs: 'https://docs.rsshub.app/routes/university#zhong-guo-ke-xue-yuan', - source: ['/jixs/yg', '/'], - target: '/cas/genetics/xshd', + source: ['/*path'], + target: '/cas/genetics/*path', }, ], 'www.ia': [ diff --git a/lib/v2/cas/router.js b/lib/v2/cas/router.js index 2ac205ea34..bde64304a2 100644 --- a/lib/v2/cas/router.js +++ b/lib/v2/cas/router.js @@ -1,6 +1,6 @@ module.exports = (router) => { router.get('/cg/:caty?', require('./cg/index')); - router.get('/genetics/xshd', require('./genetics/xshd')); + router.get('/genetics/:path+', require('./genetics/index')); router.get('/ia/yjs', require('./ia/yjs')); router.get('/iee/kydt', require('./iee/kydt')); router.get('/is/:path+', require('./is/index')); diff --git a/website/docs/routes/university.mdx b/website/docs/routes/university.mdx index 7c45c70ed1..1dca95c32b 100644 --- a/website/docs/routes/university.mdx +++ b/website/docs/routes/university.mdx @@ -3524,9 +3524,19 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE\_TL | xwdt2016/tzgg2016 | xwdt2016/kjdt2016 | kxcb2016/kpdt2016 | -### 遗传与发育生物学研究所 学术活动 {#zhong-guo-ke-xue-yuan-yi-chuan-yu-fa-yu-sheng-wu-xue-yan-jiu-suo-xue-shu-huo-dong} +### 遗传与发育生物学研究所 {#zhong-guo-ke-xue-yuan-yi-chuan-yu-fa-yu-sheng-wu-xue-yan-jiu-suo} - + + 路径参数示例: + + | 路径 | 栏目 | + | :--------------------- | :--------- | + | jixs/yg | 学术预告 | + | dtxw/kyjz | 科研进展 | + | edu/zsxx/ssszs\_187556 | 硕士生招生 | + | edu/zsxx/bsszs\_187557 | 博士生招生 | + | dqyd/djgz/dwyw | 党委要闻 | + ## 中国科学院大学 {#zhong-guo-ke-xue-yuan-da-xue}