diff --git a/assets/radar-rules.js b/assets/radar-rules.js index f8b487db7..6521e8e46 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -512,21 +512,6 @@ ], grs: [{ title: '研究生院通知', docs: 'https://docs.rsshub.app/university.html#yun-nan-da-xue', source: '/*', target: '' }], }, - 'zju.edu.cn': { - _name: '浙江大学', - cst: [ - { title: '软件学院 - 全部通知', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: ['', '/*tpath'], target: '/zju/cst/0' }, - { title: '软件学院 - 招生信息', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: '/32178/list.htm', target: '/zju/cst/1' }, - { title: '软件学院 - 教务管理', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: '/36216/list.htm', target: '/zju/cst/2' }, - { title: '软件学院 - 论文管理', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: '/36217/list.htm', target: '/zju/cst/3' }, - { title: '软件学院 - 思政工作', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: '/36192/list.htm', target: '/zju/cst/4' }, - { title: '软件学院 - 评奖评优', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: '/36228/list.htm', target: '/zju/cst/5' }, - { title: '软件学院 - 实习就业', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: '/36193/list.htm', target: '/zju/cst/6' }, - { title: '软件学院 - 国际实习', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: '/36235/list.htm', target: '/zju/cst/7' }, - { title: '软件学院 - 国内合作科研', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: '/36194/list.htm', target: '/zju/cst/8' }, - { title: '软件学院 - 国际合作科研', docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', source: '/36246/list.htm', target: '/zju/cst/9' }, - ], - }, 'kuaidi100.com': { _name: '快递100', '.': [ diff --git a/docs/university.md b/docs/university.md index 20eecee88..71a9f5b7b 100644 --- a/docs/university.md +++ b/docs/university.md @@ -2747,11 +2747,11 @@ type 列表: ### 普通栏目 如学术 / 图片 / 新闻等 - + -### 浙大研究生院 +### 研究生院 - + | 全部公告 | 教学管理 | 各类资助 | 学科建设 | 海外交流 | | ---- | ---- | ---- | ---- | ---- | @@ -2759,9 +2759,9 @@ type 列表: -### 浙大就业服务平台 +### 就业服务平台 - + | 新闻动态 | 活动通知 | 学院通知 | 告示通知 | | ---- | ---- | ---- | ---- | @@ -2769,17 +2769,17 @@ type 列表: -### 浙大物理系 +### 物理学院 - + -| 本系动态 | 科研通知 | 研究生教育最新消息 | 学生思政最新消息 | 研究生思政消息公告 | 研究生奖助学金 | 研究生思政就业信息 | 本科生思政消息公告 | 本科生奖助学金 | 本科生就业信息 | 学术报告 | -| ---- | ---- | --------- | -------- | --------- | ------- | --------- | --------- | ------- | ------- | ---- | -| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | +| 本院动态 | 科研进展 | 研究生教育最新消息 | +| ---- | ---- | --------- | +| 1 | 2 | 3 | -### 浙大软件学院 +### 软件学院 diff --git a/lib/radar-rules.js b/lib/radar-rules.js index 09b673c29..b3f8435e9 100644 --- a/lib/radar-rules.js +++ b/lib/radar-rules.js @@ -1238,71 +1238,6 @@ module.exports = { }, ], }, - 'zju.edu.cn': { - _name: '浙江大学', - cst: [ - { - title: '软件学院 - 全部通知', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: ['', '/*tpath'], - target: '/zju/cst/0', - }, - { - title: '软件学院 - 招生信息', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: '/32178/list.htm', - target: '/zju/cst/1', - }, - { - title: '软件学院 - 教务管理', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: '/36216/list.htm', - target: '/zju/cst/2', - }, - { - title: '软件学院 - 论文管理', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: '/36217/list.htm', - target: '/zju/cst/3', - }, - { - title: '软件学院 - 思政工作', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: '/36192/list.htm', - target: '/zju/cst/4', - }, - { - title: '软件学院 - 评奖评优', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: '/36228/list.htm', - target: '/zju/cst/5', - }, - { - title: '软件学院 - 实习就业', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: '/36193/list.htm', - target: '/zju/cst/6', - }, - { - title: '软件学院 - 国际实习', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: '/36235/list.htm', - target: '/zju/cst/7', - }, - { - title: '软件学院 - 国内合作科研', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: '/36194/list.htm', - target: '/zju/cst/8', - }, - { - title: '软件学院 - 国际合作科研', - docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', - source: '/36246/list.htm', - target: '/zju/cst/9', - }, - ], - }, 'kuaidi100.com': { _name: '快递100', '.': [ diff --git a/lib/router.js b/lib/router.js index 51692f1e9..6d2fdc24c 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1470,13 +1470,13 @@ router.get('/psnine/game', lazyloadRouteHandler('./routes/psnine/game')); router.get('/psnine/news/:order?', lazyloadRouteHandler('./routes/psnine/news')); router.get('/psnine/node/:id?/:order?', lazyloadRouteHandler('./routes/psnine/node')); -// 浙江大学 -router.get('/zju/list/:type', lazyloadRouteHandler('./routes/universities/zju/list')); -router.get('/zju/physics/:type', lazyloadRouteHandler('./routes/universities/zju/physics')); -router.get('/zju/grs/:type', lazyloadRouteHandler('./routes/universities/zju/grs')); -router.get('/zju/career/:type', lazyloadRouteHandler('./routes/universities/zju/career')); -router.get('/zju/cst/:type', lazyloadRouteHandler('./routes/universities/zju/cst')); -router.get('/zju/cst/custom/:id', lazyloadRouteHandler('./routes/universities/zju/cst/custom')); +// 浙江大学 migrated to v2 +// router.get('/zju/list/:type', lazyloadRouteHandler('./routes/universities/zju/list')); +// router.get('/zju/physics/:type', lazyloadRouteHandler('./routes/universities/zju/physics')); +// router.get('/zju/grs/:type', lazyloadRouteHandler('./routes/universities/zju/grs')); +// router.get('/zju/career/:type', lazyloadRouteHandler('./routes/universities/zju/career')); +// router.get('/zju/cst/:type', lazyloadRouteHandler('./routes/universities/zju/cst')); +// router.get('/zju/cst/custom/:id', lazyloadRouteHandler('./routes/universities/zju/cst/custom')); // 浙江大学城市学院 router.get('/zucc/news/latest', lazyloadRouteHandler('./routes/universities/zucc/news')); diff --git a/lib/routes/universities/zju/grs/index.js b/lib/routes/universities/zju/grs/index.js deleted file mode 100644 index 530f2e5b8..000000000 --- a/lib/routes/universities/zju/grs/index.js +++ /dev/null @@ -1,44 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -const host = 'http://grs.zju.edu.cn/redir.php?catalog_id=16313'; - -const map = new Map([ - [1, { title: '浙大研究生院 -- 全部公告', tag: '' }], - [2, { title: '浙大研究生院 -- 教学管理', tag: '&tag=%E6%95%99%E5%AD%A6%E7%AE%A1%E7%90%86' }], - [3, { title: '浙大研究生院 -- 各类资助', tag: '&tag=%E5%90%84%E7%B1%BB%E8%B5%84%E5%8A%A9' }], - [4, { title: '浙大研究生院 -- 学科建设', tag: '&tag=%E5%AD%A6%E7%A7%91%E5%BB%BA%E8%AE%BE' }], - [5, { title: '浙大研究生院 -- 海外交流', tag: '&tag=%E6%B5%B7%E5%A4%96%E4%BA%A4%E6%B5%81' }], -]); - -module.exports = async (ctx) => { - const type = Number.parseInt(ctx.params.type); - const tag = map.get(type).tag; - const res = await got({ - method: 'get', - url: `${host}${tag}`, - }); - - const $ = cheerio.load(res.data); - const list = $('.cg-pic-news-list').find('li').slice(0, 20); - - const items = - list && - list - .map((index, item) => { - item = $(item); - return { - title: item.find('a').text(), - pubDate: new Date(item.find('.art-dateee').text()).toUTCString(), - link: `http://grs.zju.edu.cn/${item.find('a').eq(-1).attr('href')}`, - description: item.find('div').text(), - }; - }) - .get(); - - ctx.state.data = { - title: map.get(type).title, - link: `${host}${tag}`, - item: items, - }; -}; diff --git a/lib/routes/universities/zju/list.js b/lib/routes/universities/zju/list.js deleted file mode 100644 index 454ada0a0..000000000 --- a/lib/routes/universities/zju/list.js +++ /dev/null @@ -1,78 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const url = require('url'); -const host = 'http://www.zju.edu.cn/'; -module.exports = async (ctx) => { - const type = ctx.params.type || 'xs'; - const link = host + type + `/list.htm`; - const response = await got({ - method: 'get', - url: link, - headers: { - Referer: host, - }, - }); - const $ = cheerio.load(response.data); - - function sortDate(e) { - // console.log(e); - const pubday = e.substr(-3, 2); - const pubmonth = e.substr(-6, 2); - const pubyear = e.substr(-11, 4); - const pubdateString = pubmonth + `-` + pubday + `-` + pubyear; - // console.log(pubdateString); - - return pubdateString; - } - function sortUrl(e) { - if (e.search('redirect') !== -1) { - return link; - } else { - return e; - } - } - const list = $('#wp_news_w7 ul.news li') - .map(function () { - const info = { - title: $(this).find('a').text(), - link: sortUrl($(this).find('a').attr('href')), - date: sortDate($(this).text()), - }; - return info; - }) - .get(); - const out = await Promise.all( - list.map(async (info) => { - const title = info.title; - const date = info.date; - const itemUrl = url.resolve(host, info.link); - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - - const response = await got({ - method: 'get', - url: itemUrl, - headers: { - Referer: link, - }, - }); - const $ = cheerio.load(response.data); - const description = $('.right_content').html(); - const single = { - title, - link: itemUrl, - description, - pubDate: new Date(date).toLocaleDateString(), - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); - }) - ); - ctx.state.data = { - title: `浙江大学` + $('ul.submenu .selected').text(), - link, - item: out, - }; -}; diff --git a/lib/routes/universities/zju/physics/index.js b/lib/routes/universities/zju/physics/index.js deleted file mode 100644 index d6a914975..000000000 --- a/lib/routes/universities/zju/physics/index.js +++ /dev/null @@ -1,55 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); -const iconv = require('iconv-lite'); - -const host = 'http://physics.zju.edu.cn/redir.php?catalog_id='; -// const host = 'http://10.14.122.238/redir.php?catalog_id='; - -const map = new Map([ - [1, { title: '浙大物理系 -- 本系动态', id: '66' }], - [2, { title: '浙大物理系 -- 科研通知', id: '88' }], - [3, { title: '浙大物理系 -- 研究生教育最新消息', id: '104' }], - [4, { title: '浙大物理系 -- 学生思政最新消息', id: '112' }], - [5, { title: '浙大物理系 -- 研究生思政消息公告', id: '155' }], - [6, { title: '浙大物理系 -- 研究生奖助学金', id: '661' }], - [7, { title: '浙大物理系 -- 研究生思政就业信息', id: '664' }], - [8, { title: '浙大物理系 -- 本科生思政消息公告', id: '667' }], - [9, { title: '浙大物理系 -- 本科生奖助学金', id: '670' }], - [10, { title: '浙大物理系 -- 本科生就业信息', id: '671' }], - [11, { title: '浙大物理系 -- 学术报告', id: '3735' }], -]); - -module.exports = async (ctx) => { - const type = Number.parseInt(ctx.params.type); - const id = map.get(type).id; - const res = await got({ - method: 'get', - url: `${host}${id}`, - responseType: 'buffer', - }); - - const $ = cheerio.load(iconv.decode(res.data, 'gb2312')); - const list = $('.art_list').find('li').slice(0, 20); - - const items = - list && - list - .map((index, item) => { - item = $(item); - return { - title: item.find('a').text(), - // title: item.find('a').attr('title'), - pubDate: new Date(item.find('.date').text()).toUTCString(), - - link: `http://physics.zju.edu.cn/${item.find('a').attr('href')}`, - // link: `http://10.14.122.238/${item.find('a').attr('href')}`, - }; - }) - .get(); - - ctx.state.data = { - title: map.get(type).title, - link: `${host}${id}`, - item: items, - }; -}; diff --git a/lib/routes/universities/zju/career/index.js b/lib/v2/zju/career/index.js similarity index 64% rename from lib/routes/universities/zju/career/index.js rename to lib/v2/zju/career/index.js index ee92c5dcf..4af79e2a6 100644 --- a/lib/routes/universities/zju/career/index.js +++ b/lib/v2/zju/career/index.js @@ -1,35 +1,36 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const rootUrl = 'http://www.career.zju.edu.cn'; const host = 'http://www.career.zju.edu.cn/jyxt/jygz/new/getContent.zf?minCount=0&maxCount=10&'; const map = new Map([ - [1, { title: '浙大就业服务平台 -- 新闻动态', id: 'lmjdid=739BEBB72A072B25E0538713470A6C41&sjlmid=undefined&lmtype=2&lx=2&_=670' }], - [2, { title: '浙大就业服务平台 -- 活动通知', id: 'lmjdid=739BEBB72A0B2B25E0538713470A6C41&sjlmid=undefined&lmtype=2&lx=2&_=1196' }], - [3, { title: '浙大就业服务平台 -- 学院动态', id: 'lmjdid=739BEBB72A0C2B25E0538713470A6C41&sjlmid=undefined&lmtype=2&lx=2&_=8' }], - [4, { title: '浙大就业服务平台 -- 告示通告', id: 'lmjdid=739BEBB72A252B25E0538713470A6C41&sjlmid=undefined&lmtype=2&lx=2&_=15' }], + [1, { title: '浙大就业服务平台 -- 新闻动态', id: 'lmjdid=739BEBB72A072B25E0538713470A6C41&sjlmid=undefined&lmtype=2&lx=2' }], + [2, { title: '浙大就业服务平台 -- 活动通知', id: 'lmjdid=739BEBB72A0B2B25E0538713470A6C41&sjlmid=undefined&lmtype=2&lx=2' }], + [3, { title: '浙大就业服务平台 -- 学院动态', id: 'lmjdid=739BEBB72A0C2B25E0538713470A6C41&sjlmid=undefined&lmtype=2&lx=2' }], + [4, { title: '浙大就业服务平台 -- 告示通告', id: 'lmjdid=739BEBB72A252B25E0538713470A6C41&sjlmid=undefined&lmtype=2&lx=2' }], ]); module.exports = async (ctx) => { - const type = Number.parseInt(ctx.params.type); + const type = parseInt(ctx.params.type); const id = map.get(type).id; - const res = await got({ - method: 'get', - url: `${host}${id}`, - }); + const res = await got(`${host}${id}`); const $ = cheerio.load(res.data); - const list = $('.com-list').find('li').slice(0, 10); + const list = $('.com-list li'); const items = list && list .map((index, item) => { item = $(item); + const link = item.find('a').eq(0); return { // title: item.find('a').attr('title'), - title: item.find('.news-ctn').text(), - pubDate: new Date(item.find('.new-time').text()).toUTCString(), + title: item.find('span').eq(0).attr('title'), + pubDate: parseDate(item.find('.news-time').text()), - link: `www.career.zju.edu.cn${item.find('a').eq(0).attr('href')}`, + link: link.attr('href').startsWith('http') ? link.attr('href') : `${rootUrl}/jyxt${link.attr('data-src')}xwid=${link.attr('data-xwid')}&lmtype=${link.attr('data-lmtype')}`, }; }) .get(); diff --git a/lib/routes/universities/zju/cst/custom.js b/lib/v2/zju/cst/custom.js similarity index 90% rename from lib/routes/universities/zju/cst/custom.js rename to lib/v2/zju/cst/custom.js index 55465a4d1..b0caeaaf6 100644 --- a/lib/routes/universities/zju/cst/custom.js +++ b/lib/v2/zju/cst/custom.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); async function getPage(id) { const res = await got({ @@ -16,7 +17,7 @@ async function getPage(id) { item = $(item); const title = item.find('a').text(); - const pubDate = new Date(item.find('.fr').text()).toUTCString(); + const pubDate = parseDate(item.find('.fr').text()); const link = item.find('a').attr('href'); return { diff --git a/lib/routes/universities/zju/cst/index.js b/lib/v2/zju/cst/index.js similarity index 70% rename from lib/routes/universities/zju/cst/index.js rename to lib/v2/zju/cst/index.js index 04bef35d2..f3ede2f24 100644 --- a/lib/routes/universities/zju/cst/index.js +++ b/lib/v2/zju/cst/index.js @@ -1,5 +1,6 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); const host = 'http://www.cst.zju.edu.cn/'; @@ -33,7 +34,7 @@ async function getPage(id) { item = $(item); return { title: item.find('a').text(), - pubDate: new Date(item.find('.fr').text()).toUTCString(), + pubDate: parseDate(item.find('.fr').text()), link: item.find('a').attr('href'), }; }) @@ -42,7 +43,7 @@ async function getPage(id) { } module.exports = async (ctx) => { - const type = Number.parseInt(ctx.params.type); + const type = parseInt(ctx.params.type); const link = host + map.get(type).id; let items = []; if (type === 0) { @@ -59,30 +60,25 @@ module.exports = async (ctx) => { } const out = await Promise.all( - items.map(async (item) => { + items.map((item) => { const itemUrl = host + item.link; - const cache = await ctx.cache.get(itemUrl); - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - - const response = await got({ - method: 'get', - url: itemUrl, - headers: { - Referer: link, - }, + return ctx.cache.tryGet(itemUrl, async () => { + const response = await got({ + method: 'get', + url: itemUrl, + headers: { + Referer: link, + }, + }); + const $ = cheerio.load(response.data); + const description = $('.vid_wz').html(); + return { + title: item.title, + link: itemUrl, + description, + pubDate: item.pubDate, + }; }); - const $ = cheerio.load(response.data); - const description = $('.vid_wz').html(); - const single = { - title: item.title, - link: itemUrl, - description, - pubDate: item.pubDate, - }; - ctx.cache.set(itemUrl, JSON.stringify(single)); - return Promise.resolve(single); }) ); diff --git a/lib/v2/zju/grs/index.js b/lib/v2/zju/grs/index.js new file mode 100644 index 000000000..893ef729d --- /dev/null +++ b/lib/v2/zju/grs/index.js @@ -0,0 +1,43 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +const host = 'http://www.grs.zju.edu.cn/'; + +const map = new Map([ + [1, { title: '浙大研究生院 -- 全部公告', tag: '1335' }], + [2, { title: '浙大研究生院 -- 教学管理', tag: '1336' }], + [3, { title: '浙大研究生院 -- 各类资助', tag: '1337' }], + [4, { title: '浙大研究生院 -- 学科建设', tag: '1338' }], + [5, { title: '浙大研究生院 -- 海外交流', tag: '1339' }], +]); + +module.exports = async (ctx) => { + const type = parseInt(ctx.params.type); + const tag = map.get(type).tag; + const url = `${host}${tag}/list.htm`; + const res = await got(url); + + const $ = cheerio.load(res.data); + const list = $('#wp_news_w24').find('.list_nav'); + + const items = + list && + list + .map((index, item) => { + item = $(item); + return { + title: item.find('.list_tit').children('a').attr('title'), + pubDate: parseDate(item.find('.list_time').text()), + link: `http://www.grs.zju.edu.cn/${item.find('a').eq(-1).attr('href')}`, + description: item.find('.list_intro a').text(), + }; + }) + .get(); + + ctx.state.data = { + title: map.get(type).title, + link: `${host}${tag}/list.htm`, + item: items, + }; +}; diff --git a/lib/v2/zju/list.js b/lib/v2/zju/list.js new file mode 100644 index 000000000..49bca181e --- /dev/null +++ b/lib/v2/zju/list.js @@ -0,0 +1,66 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); +const host = 'https://www.zju.edu.cn/'; +module.exports = async (ctx) => { + const type = ctx.params.type ?? 'xs'; + const link = host + type + `/list.htm`; + const response = await got({ + method: 'get', + url: link, + headers: { + Referer: host, + }, + }); + const $ = cheerio.load(response.data); + + function sortUrl(e) { + if (e.search('redirect') !== -1) { + return link; + } else { + return e; + } + } + const list = $('#wp_news_w7 ul.news li') + .map(function () { + const info = { + title: $(this).find('a').attr('title'), + link: sortUrl($(this).find('a').attr('href')), + date: $(this) + .text() + .match(/\d{4}-\d{2}-\d{2}/)[0], + }; + return info; + }) + .get(); + + const out = await Promise.all( + list.map((info) => { + const title = info.title; + const date = info.date; + const itemUrl = new URL(info.link, host).href; + return ctx.cache.tryGet(itemUrl, async () => { + const response = await got({ + method: 'get', + url: itemUrl, + headers: { + Referer: link, + }, + }); + const $ = cheerio.load(response.data); + const description = $('.right_content').html(); + return { + title, + link: itemUrl, + description, + pubDate: parseDate(date), + }; + }); + }) + ); + ctx.state.data = { + title: `浙江大学` + $('ul.submenu .selected').text(), + link, + item: out, + }; +}; diff --git a/lib/v2/zju/maintainer.js b/lib/v2/zju/maintainer.js new file mode 100644 index 000000000..aa0141d57 --- /dev/null +++ b/lib/v2/zju/maintainer.js @@ -0,0 +1,8 @@ +module.exports = { + '/career/:type': ['Caicailiushui'], + '/cst/custom/:id': ['zwithz'], + '/cst/:type': ['yonvenne', 'zwithz'], + '/grs/:type': ['Caicailiushui'], + '/list/:type': ['Jeason0228'], + '/physics/:type': ['Caicailiushui'], +}; diff --git a/lib/v2/zju/physics/index.js b/lib/v2/zju/physics/index.js new file mode 100644 index 000000000..327963cfa --- /dev/null +++ b/lib/v2/zju/physics/index.js @@ -0,0 +1,52 @@ +const got = require('@/utils/got'); +const cheerio = require('cheerio'); +const { parseDate } = require('@/utils/parse-date'); + +// const host = 'http://physics.zju.edu.cn/redir.php?catalog_id='; +const host = 'http://physics.zju.edu.cn'; +// const host = 'http://10.14.122.238/redir.php?catalog_id='; + +const map = new Map([ + [1, { title: '浙大物理学院 -- 本院动态', id: '39060' }], + [2, { title: '浙大物理学院 -- 科研进展', id: '39070' }], + [3, { title: '浙大物理学院 -- 研究生教育最新消息', id: '39079' }], + + // could not find these sections due to http://physics.zju.edu.cn/2022/0325/c39060a2510676/page.htm + /* [4, { title: '浙大物理学院 -- 学生思政最新消息', id: '112' }], + [5, { title: '浙大物理学院 -- 研究生思政消息公告', id: '155' }], + [6, { title: '浙大物理学院 -- 研究生奖助学金', id: '661' }], + [7, { title: '浙大物理学院 -- 研究生思政就业信息', id: '664' }], + [8, { title: '浙大物理学院 -- 本科生思政消息公告', id: '667' }], + [9, { title: '浙大物理学院 -- 本科生奖助学金', id: '670' }], + [10, { title: '浙大物理学院 -- 本科生就业信息', id: '671' }], + [11, { title: '浙大物理学院 -- 学术报告', id: '3735' }],*/ +]); + +module.exports = async (ctx) => { + const type = parseInt(ctx.params.type); + const id = map.get(type).id; + const res = await got({ + method: 'get', + url: `${host}/${id}/list.htm`, + }); + + const $ = cheerio.load(res.data); + const items = $('#arthd li') + .map((index, item) => { + item = $(item); + return { + title: item.find('a').attr('title'), + pubDate: parseDate(item.find('.art-date').text()), + + link: `http://physics.zju.edu.cn/${item.find('a').attr('href')}`, + // link: `http://10.14.122.238/${item.find('a').attr('href')}`, + }; + }) + .get(); + + ctx.state.data = { + title: map.get(type).title, + link: `${host}${id}`, + item: items, + }; +}; diff --git a/lib/v2/zju/radar.js b/lib/v2/zju/radar.js new file mode 100644 index 000000000..6bb3c7d4d --- /dev/null +++ b/lib/v2/zju/radar.js @@ -0,0 +1,139 @@ +module.exports = { + 'zju.edu.cn': { + _name: '浙江大学', + physics: [ + { + title: '物理学院', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: ['/*path'], + target: (params) => { + let type; + switch (params.path) { + case '39060/list.htm': + type = '1'; + break; + case '39070/list.htm': + type = '2'; + break; + case '39079/list.htm': + type = '3'; + break; + default: + type = '1'; + break; + } + return `/zju/physics/${type}`; + }, + }, + ], + www: [ + { + title: '普通栏目', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: ['/*path'], + target: (params) => `/zju/list/${params.path.replace('/list.htm', '')}`, + }, + ], + 'www.career': [ + { + title: '就业服务平台', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: ['/'], + target: '/zju/career/1', + }, + ], + 'www.cst': [ + { + title: '软件学院 - 全部通知', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: ['', '/*tpath'], + target: '/zju/cst/0', + }, + { + title: '软件学院 - 招生信息', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: '/32178/list.htm', + target: '/zju/cst/1', + }, + { + title: '软件学院 - 教务管理', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: '/36216/list.htm', + target: '/zju/cst/2', + }, + { + title: '软件学院 - 论文管理', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: '/36217/list.htm', + target: '/zju/cst/3', + }, + { + title: '软件学院 - 思政工作', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: '/36192/list.htm', + target: '/zju/cst/4', + }, + { + title: '软件学院 - 评奖评优', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: '/36228/list.htm', + target: '/zju/cst/5', + }, + { + title: '软件学院 - 实习就业', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: '/36193/list.htm', + target: '/zju/cst/6', + }, + { + title: '软件学院 - 国际实习', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: '/36235/list.htm', + target: '/zju/cst/7', + }, + { + title: '软件学院 - 国内合作科研', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: '/36194/list.htm', + target: '/zju/cst/8', + }, + { + title: '软件学院 - 国际合作科研', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: '/36246/list.htm', + target: '/zju/cst/9', + }, + ], + 'www.grs': [ + { + title: '研究生院', + docs: 'https://docs.rsshub.app/university.html#zhe-jiang-da-xue', + source: ['/*path', '/'], + target: (params) => { + let type; + switch (params.path) { + case '1335/list.htm': + type = 1; + break; + case '1336/list.htm': + type = 2; + break; + case '1337/list.htm': + type = 3; + break; + case '1338/list.htm': + type = 4; + break; + case '1339/list.htm': + type = 5; + break; + default: + type = 1; + break; + } + return `/zju/grs/${type}`; + }, + }, + ], + }, +}; diff --git a/lib/v2/zju/router.js b/lib/v2/zju/router.js new file mode 100644 index 000000000..75b1f23b7 --- /dev/null +++ b/lib/v2/zju/router.js @@ -0,0 +1,8 @@ +module.exports = (router) => { + router.get('/career/:type', require('./career')); + router.get('/cst/custom/:id', require('./cst/custom')); + router.get('/cst/:type', require('./cst')); + router.get('/grs/:type', require('./grs')); + router.get('/list/:type', require('./list')); + router.get('/physics/:type', require('./physics')); +};