diff --git a/docs/en/university.md b/docs/en/university.md
index 1bb8fb944..c3981b9ff 100644
--- a/docs/en/university.md
+++ b/docs/en/university.md
@@ -46,6 +46,18 @@ Note: [Source website](https://gs.bjtu.edu.cn/) only provides articles in Chines
+## Tianjin University
+
+### The Office of Academic Affairs
+
+
+
+| News | Notification |
+| ---- | ------------ |
+| news | notification |
+
+
+
## UMASS Amherst
### College of Electrical and Computer Engineering
diff --git a/docs/university.md b/docs/university.md
index deb2cff60..44efd31e7 100644
--- a/docs/university.md
+++ b/docs/university.md
@@ -2387,7 +2387,7 @@ jsjxy.hbut.edu.cn 证书链不全,自建 RSSHub 可设置环境变量 NODE_TLS
### 天津大学教务处
-
+
| 新闻动态 | 通知公告 |
| ---- | ------------ |
diff --git a/lib/router.js b/lib/router.js
index 74e461e7d..113a2a9ce 100644
--- a/lib/router.js
+++ b/lib/router.js
@@ -731,8 +731,8 @@ router.get('/wzbc/:type?', lazyloadRouteHandler('./routes/universities/wzbc/news
// 河南大学
router.get('/henu/:type?', lazyloadRouteHandler('./routes/universities/henu/news'));
-// 天津大学
-router.get('/tjpyu/ooa/:type?', lazyloadRouteHandler('./routes/universities/tjpyu/ooa'));
+// 天津大学 migrated to v2
+// router.get('/tju/oaa/:type?', lazyloadRouteHandler('./routes/universities/tju/oaa'));
// 南开大学
router.get('/nku/jwc/:type?', lazyloadRouteHandler('./routes/universities/nku/jwc/index'));
diff --git a/lib/routes/universities/tjpyu/ooa.js b/lib/routes/universities/tjpyu/ooa.js
deleted file mode 100644
index d08b386c3..000000000
--- a/lib/routes/universities/tjpyu/ooa.js
+++ /dev/null
@@ -1,73 +0,0 @@
-const got = require('@/utils/got');
-const cheerio = require('cheerio');
-
-const ooa_base_url = 'http://oaa.tju.edu.cn/';
-const repo_url = 'https://github.com/DIYgod/RSSHub/issues';
-
-module.exports = async (ctx) => {
- const type = ctx.params && ctx.params.type;
- let path, subtitle;
-
- switch (type) {
- case 'news':
- subtitle = '新闻动态';
- path = 'zytz';
- break;
- case 'notification':
- subtitle = '通知公告';
- path = 'zygg';
- break;
- default:
- subtitle = '新闻动态';
- path = 'zytz';
- }
- let response = null;
- try {
- response = await got({
- method: 'get',
- url: ooa_base_url + path,
- headers: {
- Referer: ooa_base_url,
- },
- });
- } catch (e) {
- // ignore error handler
- // console.log(e);
- }
-
- if (response === null) {
- ctx.state.data = {
- title: '天津大学教务处 - ' + subtitle,
- link: ooa_base_url + path,
- description: '链接失效' + ooa_base_url + path,
- item: [
- {
- title: '提示信息',
- link: repo_url,
- description: `请到此处提交Issue
`,
- },
- ],
- };
- } else {
- const $ = cheerio.load(response.data);
- const list = $('.iplan > ul > li').slice(0, 10);
-
- ctx.state.data = {
- title: '天津大学教务处 - ' + subtitle,
- link: ooa_base_url + path,
- description: null,
- item:
- list &&
- list
- .map((index, item) => ({
- title: $('h2', item)
- .text()
- .replace(/(\d+)-(\d+)-(\d+)$/, ''), // remove duplicate date at the end of h2 element
- pubDate: new Date($('span', item).text()).toUTCString(),
- link: $('a', item).attr('href'),
- description: $('p', item).text(),
- }))
- .get(),
- };
- }
-};
diff --git a/lib/v2/tju/maintainer.js b/lib/v2/tju/maintainer.js
new file mode 100644
index 000000000..fedd83619
--- /dev/null
+++ b/lib/v2/tju/maintainer.js
@@ -0,0 +1,3 @@
+module.exports = {
+ '/oaa/:type?': ['AmosChenYQ', 'SuperPung'],
+};
diff --git a/lib/v2/tju/oaa/index.js b/lib/v2/tju/oaa/index.js
new file mode 100644
index 000000000..4ade384fc
--- /dev/null
+++ b/lib/v2/tju/oaa/index.js
@@ -0,0 +1,112 @@
+const got = require('@/utils/got');
+const cheerio = require('cheerio');
+const { finishArticleItem } = require('@/utils/wechat-mp');
+const { parseDate } = require('@/utils/parse-date');
+const timezone = require('@/utils/timezone');
+
+const oaa_base_url = 'http://oaa.tju.edu.cn/';
+const repo_url = 'https://github.com/DIYgod/RSSHub/issues';
+
+const pageType = (href) => {
+ if (!href.startsWith('http')) {
+ return 'in-site';
+ }
+ const url = new URL(href);
+ if (url.hostname === 'mp.weixin.qq.com') {
+ return 'wechat-mp';
+ } else if (url.hostname === 'oaa.tju.edu.cn') {
+ return 'tju-oaa';
+ } else {
+ return 'unknown';
+ }
+};
+
+module.exports = async (ctx) => {
+ const type = ctx.params && ctx.params.type;
+ let path, subtitle;
+
+ switch (type) {
+ case 'news':
+ subtitle = '新闻动态';
+ path = 'xwdt.htm';
+ break;
+ case 'notification':
+ subtitle = '通知公告';
+ path = 'tzgg.htm';
+ break;
+ default:
+ subtitle = '新闻动态';
+ path = 'xwdt.htm';
+ }
+ let response = null;
+ try {
+ response = await got(oaa_base_url + path, {
+ headers: {
+ Referer: oaa_base_url,
+ },
+ });
+ } catch (e) {
+ // ignore error handler
+ // console.log(e);
+ }
+
+ if (response === null) {
+ ctx.state.data = {
+ title: '天津大学教务处 - ' + subtitle,
+ link: oaa_base_url + path,
+ description: '链接失效' + oaa_base_url + path,
+ item: [
+ {
+ title: '提示信息',
+ link: repo_url,
+ description: `请到此处提交Issue
`,
+ },
+ ],
+ };
+ } else {
+ const $ = cheerio.load(response.data);
+ const list = $('.notice_l > ul > li > dl > dt')
+ .map((_index, item) => {
+ const href = $('a', item).attr('href');
+ const type = pageType(href);
+ return {
+ title: $('h2', item).text(),
+ link: type === 'in-site' ? oaa_base_url + href : href,
+ pubDate: timezone(parseDate($('.fl_01_r_time', item).text(), 'DDYYYY-MM'), +8),
+ type,
+ };
+ })
+ .get();
+
+ const items = await Promise.all(
+ list.map((item) => {
+ switch (item.type) {
+ case 'wechat-mp':
+ return finishArticleItem(ctx, item);
+ case 'tju-oaa':
+ case 'in-site':
+ return ctx.cache.tryGet(item.link, async () => {
+ let detailResponse = null;
+ try {
+ detailResponse = await got(item.link, { https: { rejectUnauthorized: false } });
+ const content = cheerio.load(detailResponse.data);
+ item.description = content('.v_news_content').html();
+ } catch (e) {
+ // ignore error handler
+ }
+ return item;
+ });
+ default:
+ return item;
+ }
+ })
+ );
+
+ ctx.state.data = {
+ title: '天津大学教务处 - ' + subtitle,
+ link: oaa_base_url + path,
+ description: null,
+ item: items,
+ };
+ }
+};
diff --git a/lib/v2/tju/radar.js b/lib/v2/tju/radar.js
new file mode 100644
index 000000000..206e59de7
--- /dev/null
+++ b/lib/v2/tju/radar.js
@@ -0,0 +1,19 @@
+module.exports = {
+ 'tju.edu.cn': {
+ _name: '天津大学',
+ oaa: [
+ {
+ title: '教务处 - 新闻动态',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue',
+ source: ['/xwdt.htm', '/'],
+ target: '/tju/oaa/news',
+ },
+ {
+ title: '教务处 - 通知公告',
+ docs: 'https://docs.rsshub.app/university.html#tian-jin-da-xue',
+ source: ['/tzgg.htm', '/'],
+ target: '/tju/oaa/notification',
+ },
+ ],
+ },
+};
diff --git a/lib/v2/tju/router.js b/lib/v2/tju/router.js
new file mode 100644
index 000000000..1d64b9111
--- /dev/null
+++ b/lib/v2/tju/router.js
@@ -0,0 +1,3 @@
+module.exports = function (router) {
+ router.get('/oaa/:type?', require('./oaa'));
+};