diff --git a/docs/en/university.md b/docs/en/university.md
index b4e6b26ebc..2417898580 100644
--- a/docs/en/university.md
+++ b/docs/en/university.md
@@ -48,6 +48,16 @@ Note: [Source website](https://gs.bjtu.edu.cn/) only provides articles in Chines
## Tianjin University
+### Admission Office of Graduate
+
+
+
+| School-level Notice | Master | Doctor | On-the-job Degree |
+| :-----------------: | :----: | :----: |:-----------------:|
+| notice | master | doctor | job |
+
+
+
### College of Intelligence and Computing
diff --git a/docs/university.md b/docs/university.md
index 683685f27f..0432a85ec5 100644
--- a/docs/university.md
+++ b/docs/university.md
@@ -2423,6 +2423,16 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
+### 研究生招生网
+
+
+
+| 校级公告 | 统考硕士 | 统考博士 | 在职学位 |
+| :----: | :----: | :----: | :--: |
+| notice | master | doctor | job |
+
+
+
## 同济大学
### 同济大学研究生院通知公告
diff --git a/lib/v2/tju/maintainer.js b/lib/v2/tju/maintainer.js
index be49cf4bb3..cff1aa8050 100644
--- a/lib/v2/tju/maintainer.js
+++ b/lib/v2/tju/maintainer.js
@@ -1,4 +1,5 @@
module.exports = {
'/cic/:type?': ['SuperPung'],
'/oaa/:type?': ['AmosChenYQ', 'SuperPung'],
+ '/yzb/:type?': ['SuperPung'],
};
diff --git a/lib/v2/tju/radar.js b/lib/v2/tju/radar.js
index 26cea40827..a06d63c636 100644
--- a/lib/v2/tju/radar.js
+++ b/lib/v2/tju/radar.js
@@ -4,19 +4,19 @@ module.exports = {
cic: [
{
title: '智能与计算学部 - 学部新闻',
- docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue-zhi-neng-yu-ji-suan-xue-bu',
source: ['/xwzx/xyxw.htm', '/'],
target: '/tju/cic/news',
},
{
title: '智能与计算学部 - 通知公告',
- docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue-zhi-neng-yu-ji-suan-xue-bu',
source: ['/xwzx/tzgg.htm', '/'],
target: '/tju/cic/notification',
},
{
title: '智能与计算学部 - 北洋智算论坛',
- docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue-zhi-neng-yu-ji-suan-xue-bu',
source: ['/byzslt.htm', '/'],
target: '/tju/cic/forum',
},
@@ -24,16 +24,42 @@ module.exports = {
oaa: [
{
title: '教务处 - 新闻动态',
- docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue-jiao-wu-chu',
source: ['/xwdt.htm', '/'],
target: '/tju/oaa/news',
},
{
title: '教务处 - 通知公告',
- docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue-jiao-wu-chu',
source: ['/tzgg.htm', '/'],
target: '/tju/oaa/notification',
},
],
+ yzb: [
+ {
+ title: '研究生招生网 - 校级公告',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue-yan-jiu-sheng-zhao-sheng-wang',
+ source: ['/xwzx/zxxx/', '/'],
+ target: '/tju/yzb/notice',
+ },
+ {
+ title: '研究生招生网 - 统考硕士',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue-yan-jiu-sheng-zhao-sheng-wang',
+ source: ['/xwzx/tkss_xw/', '/'],
+ target: '/tju/yzb/master',
+ },
+ {
+ title: '研究生招生网 - 统考博士',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue-yan-jiu-sheng-zhao-sheng-wang',
+ source: ['/xwzx/tkbs_xw/', '/'],
+ target: '/tju/yzb/doctor',
+ },
+ {
+ title: '研究生招生网 - 在职学位',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue-yan-jiu-sheng-zhao-sheng-wang',
+ source: ['/xwzx/zzxw/', '/'],
+ target: '/tju/yzb/job',
+ },
+ ],
},
};
diff --git a/lib/v2/tju/router.js b/lib/v2/tju/router.js
index f9ceec38b1..f1dfa36918 100644
--- a/lib/v2/tju/router.js
+++ b/lib/v2/tju/router.js
@@ -1,4 +1,5 @@
module.exports = function (router) {
router.get('/cic/:type?', require('./cic'));
router.get('/oaa/:type?', require('./oaa'));
+ router.get('/yzb/:type?', require('./yzb'));
};
diff --git a/lib/v2/tju/yzb/index.js b/lib/v2/tju/yzb/index.js
new file mode 100644
index 0000000000..82e242625a
--- /dev/null
+++ b/lib/v2/tju/yzb/index.js
@@ -0,0 +1,121 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const iconv = require('iconv-lite');
+const { parseDate } = require('@/utils/parse-date');
+const timezone = require('@/utils/timezone');
+
+const yzb_base_url = 'http://yzb.tju.edu.cn/';
+const repo_url = 'https://github.com/DIYgod/RSSHub/issues';
+
+const pageType = (href) => {
+ if (href === undefined) {
+ return 'unknown';
+ } else if (!href.startsWith('http')) {
+ return 'in-site';
+ }
+ const url = new URL(href);
+ if (url.hostname === 'yzb.tju.edu.cn') {
+ return 'tju-yzb';
+ } else {
+ return 'unknown';
+ }
+};
+
+module.exports = async (ctx) => {
+ const type = ctx.params && ctx.params.type;
+ let path, subtitle;
+
+ switch (type) {
+ case 'notice':
+ subtitle = '校级公告';
+ path = 'xwzx/zxxx/';
+ break;
+ case 'master':
+ subtitle = '统考硕士';
+ path = 'xwzx/tkss_xw/';
+ break;
+ case 'doctor':
+ subtitle = '统考博士';
+ path = 'xwzx/tkbs_xw/';
+ break;
+ case 'job':
+ subtitle = '在职学位';
+ path = 'xwzx/zzxw/';
+ break;
+ default:
+ subtitle = '校级公告';
+ path = 'xwzx/zxxx/';
+ }
+ let response = null;
+ try {
+ response = await got(yzb_base_url + path, {
+ headers: {
+ Referer: yzb_base_url,
+ },
+ responseType: 'buffer',
+ });
+ } catch (e) {
+ // ignore error handler
+ // console.log(e);
+ }
+
+ if (response === null) {
+ ctx.state.data = {
+ title: '天津大学研究生招生网 - ' + subtitle,
+ link: yzb_base_url + path,
+ description: '链接失效' + yzb_base_url + path,
+ item: [
+ {
+ title: '提示信息',
+ link: repo_url,
+ description: `请到此处提交Issue
`,
+ },
+ ],
+ };
+ } else {
+ const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
+ const list = $('body > table:nth-child(3) > tbody > tr > td.table_left_right > table > tbody > tr:nth-child(3) > td > table > tbody > tr:nth-child(1) > td > table > tbody > tr')
+ .slice(1, -1)
+ .map((_index, item) => {
+ const href = $('td > a', item).attr('href');
+ const type = pageType(href);
+ return {
+ title: $('td > a', item).text(),
+ link: type === 'in-site' ? yzb_base_url + path + href : href,
+ pubDate: timezone(parseDate($('.font_10_time', item).text().slice(2, -2), 'YYYY-MM-DD'), +8),
+ type,
+ };
+ })
+ .get();
+
+ const items = await Promise.all(
+ list.map((item) => {
+ switch (item.type) {
+ case 'tju-yzb':
+ case 'in-site':
+ return ctx.cache.tryGet(item.link, async () => {
+ let detailResponse = null;
+ try {
+ detailResponse = await got(item.link, { responseType: 'buffer' });
+ const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
+ content('.font_18_b').remove();
+ content('.font_grey_en').remove();
+ item.description = content('.nav_a10 > table > tbody').html();
+ } catch (e) {
+ // ignore error handler
+ }
+ return item;
+ });
+ default:
+ return item;
+ }
+ })
+ );
+
+ ctx.state.data = {
+ title: '天津大学研究生招生网 - ' + subtitle,
+ link: yzb_base_url + path,
+ item: items,
+ };
+ }
+};