rsshub 1.0.0-master.d3ce31d → 1.0.0-master.d4c8fa0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/lib/middleware/parameter.js +10 -4
  2. package/lib/radar-rules.js +20 -37
  3. package/lib/router.js +9 -9
  4. package/lib/v2/36kr/index.js +75 -0
  5. package/lib/v2/36kr/maintainer.js +7 -5
  6. package/lib/v2/36kr/radar.js +27 -15
  7. package/lib/v2/36kr/router.js +1 -5
  8. package/lib/v2/acs/journal.js +73 -0
  9. package/lib/v2/acs/maintainer.js +3 -0
  10. package/lib/v2/acs/radar.js +13 -0
  11. package/lib/v2/acs/router.js +3 -0
  12. package/lib/v2/acs/templates/description.art +2 -0
  13. package/lib/v2/airchina/index.js +36 -0
  14. package/lib/v2/airchina/maintainer.js +3 -0
  15. package/lib/v2/airchina/radar.js +13 -0
  16. package/lib/v2/airchina/router.js +3 -0
  17. package/lib/v2/allrecode/index.js +65 -0
  18. package/lib/v2/allrecode/maintainer.js +5 -0
  19. package/lib/v2/allrecode/news.js +35 -0
  20. package/lib/v2/allrecode/radar.js +25 -0
  21. package/lib/v2/allrecode/router.js +4 -0
  22. package/lib/v2/biquge/index.js +78 -0
  23. package/lib/v2/biquge/maintainer.js +3 -0
  24. package/lib/v2/biquge/radar.js +29 -0
  25. package/lib/v2/biquge/router.js +3 -0
  26. package/lib/v2/ccfcv/index.js +68 -0
  27. package/lib/v2/ccfcv/maintainer.js +3 -0
  28. package/lib/v2/ccfcv/radar.js +25 -0
  29. package/lib/v2/ccfcv/router.js +3 -0
  30. package/lib/v2/ccfcv/templates/description.art +1 -0
  31. package/lib/v2/cde/maintainer.js +1 -0
  32. package/lib/v2/cde/radar.js +12 -0
  33. package/lib/v2/cde/router.js +1 -0
  34. package/lib/v2/cde/zdyz.js +77 -0
  35. package/lib/v2/clash/maintainer.js +3 -0
  36. package/lib/v2/clash/premium.js +23 -0
  37. package/lib/v2/clash/radar.js +13 -0
  38. package/lib/v2/clash/router.js +3 -0
  39. package/lib/v2/gdut/maintainer.js +3 -0
  40. package/lib/{routes/universities → v2}/gdut/news.js +4 -0
  41. package/lib/v2/gdut/oa_news.js +214 -0
  42. package/lib/v2/gdut/radar.js +13 -0
  43. package/lib/v2/gdut/router.js +3 -0
  44. package/lib/v2/github/maintainer.js +1 -1
  45. package/lib/v2/github/templates/trending-description.art +5 -0
  46. package/lib/v2/github/trending.js +32 -16
  47. package/lib/v2/gov/maintainer.js +2 -0
  48. package/lib/v2/gov/moj/aac/news.js +49 -0
  49. package/lib/v2/gov/nifdc/index.js +86 -0
  50. package/lib/v2/gov/radar.js +22 -0
  51. package/lib/v2/gov/router.js +2 -0
  52. package/lib/v2/gov/shanghai/yjj/index.js +16 -10
  53. package/lib/v2/hakkatv/maintainer.js +3 -0
  54. package/lib/v2/hakkatv/radar.js +13 -0
  55. package/lib/v2/hakkatv/router.js +3 -0
  56. package/lib/v2/hakkatv/type.js +67 -0
  57. package/lib/v2/hk01/channel.js +13 -30
  58. package/lib/v2/hk01/hot.js +13 -14
  59. package/lib/v2/hk01/issue.js +12 -31
  60. package/lib/v2/hk01/maintainer.js +5 -5
  61. package/lib/v2/hk01/radar.js +19 -19
  62. package/lib/v2/hk01/router.js +4 -4
  63. package/lib/v2/hk01/tag.js +14 -15
  64. package/lib/v2/hk01/templates/description.art +53 -0
  65. package/lib/v2/hk01/utils.js +43 -0
  66. package/lib/v2/hk01/zone.js +15 -34
  67. package/lib/v2/houxu/events.js +37 -0
  68. package/lib/v2/houxu/index.js +21 -69
  69. package/lib/v2/houxu/lives.js +35 -0
  70. package/lib/v2/houxu/maintainer.js +4 -2
  71. package/lib/v2/houxu/memory.js +37 -0
  72. package/lib/v2/houxu/radar.js +18 -6
  73. package/lib/v2/houxu/router.js +6 -1
  74. package/lib/v2/houxu/templates/events.art +5 -0
  75. package/lib/v2/houxu/templates/lives.art +5 -0
  76. package/lib/v2/houxu/templates/memory.art +3 -0
  77. package/lib/v2/myfigurecollection/activity.js +58 -0
  78. package/lib/v2/myfigurecollection/index.js +78 -0
  79. package/lib/v2/myfigurecollection/maintainer.js +4 -0
  80. package/lib/v2/myfigurecollection/radar.js +44 -0
  81. package/lib/v2/myfigurecollection/router.js +4 -0
  82. package/lib/v2/myfigurecollection/templates/activity.art +8 -0
  83. package/lib/v2/myfigurecollection/templates/description.art +24 -0
  84. package/lib/v2/ncepu/maintainer.js +3 -0
  85. package/lib/v2/ncepu/master/masterinfo.js +78 -0
  86. package/lib/v2/ncepu/radar.js +25 -0
  87. package/lib/v2/ncepu/router.js +3 -0
  88. package/lib/{routes → v2}/nga/forum.js +8 -9
  89. package/lib/v2/nga/maintainer.js +4 -0
  90. package/lib/{routes → v2}/nga/post.js +16 -15
  91. package/lib/v2/nga/radar.js +56 -0
  92. package/lib/v2/nga/router.js +4 -0
  93. package/lib/v2/oo-software/changelog.js +40 -0
  94. package/lib/v2/oo-software/maintainer.js +3 -0
  95. package/lib/v2/oo-software/radar.js +13 -0
  96. package/lib/v2/oo-software/router.js +3 -0
  97. package/lib/{routes/outagereport/service.js → v2/outagereport/index.js} +2 -2
  98. package/lib/v2/outagereport/maintainer.js +3 -0
  99. package/lib/v2/outagereport/radar.js +13 -0
  100. package/lib/v2/outagereport/router.js +3 -0
  101. package/lib/v2/peopo/maintainer.js +3 -0
  102. package/lib/v2/peopo/radar.js +13 -0
  103. package/lib/v2/peopo/router.js +3 -0
  104. package/lib/v2/peopo/topic.js +46 -0
  105. package/lib/v2/pts/curations.js +44 -0
  106. package/lib/v2/pts/{dailynews.js → index.js} +24 -11
  107. package/lib/v2/pts/maintainer.js +6 -0
  108. package/lib/v2/pts/projects.js +44 -0
  109. package/lib/v2/pts/radar.js +38 -2
  110. package/lib/v2/pts/router.js +4 -1
  111. package/lib/v2/pts/templates/description.art +6 -0
  112. package/lib/v2/sakurazaka46/blog.js +1 -1
  113. package/lib/v2/sakurazaka46/maintainer.js +1 -0
  114. package/lib/v2/sakurazaka46/news.js +51 -0
  115. package/lib/v2/sakurazaka46/radar.js +6 -0
  116. package/lib/v2/sakurazaka46/router.js +1 -0
  117. package/lib/v2/scitation/journal.js +37 -50
  118. package/lib/v2/scitation/section.js +38 -56
  119. package/lib/v2/scitation/templates/description.art +4 -7
  120. package/lib/v2/scitation/utils.js +29 -0
  121. package/lib/v2/sinchew/index.js +68 -0
  122. package/lib/v2/sinchew/maintainer.js +5 -0
  123. package/lib/v2/sinchew/radar.js +25 -0
  124. package/lib/v2/sinchew/router.js +4 -0
  125. package/lib/v2/sinchew/templates/images.art +4 -0
  126. package/lib/v2/taiwannews/hot.js +52 -0
  127. package/lib/v2/taiwannews/maintainer.js +3 -0
  128. package/lib/v2/taiwannews/radar.js +13 -0
  129. package/lib/v2/taiwannews/router.js +3 -0
  130. package/lib/v2/test/index.js +2 -0
  131. package/lib/v2/tju/cic/index.js +113 -0
  132. package/lib/v2/tju/maintainer.js +6 -0
  133. package/lib/v2/tju/news/index.js +135 -0
  134. package/lib/v2/tju/oaa/index.js +112 -0
  135. package/lib/v2/tju/radar.js +97 -0
  136. package/lib/v2/tju/router.js +6 -0
  137. package/lib/v2/tju/yzb/index.js +121 -0
  138. package/lib/v2/tribalfootball/latest.js +68 -0
  139. package/lib/v2/tribalfootball/maintainer.js +3 -0
  140. package/lib/v2/tribalfootball/radar.js +13 -0
  141. package/lib/v2/tribalfootball/router.js +3 -0
  142. package/lib/v2/tribalfootball/templates/plus_header.art +6 -0
  143. package/lib/v2/youzhiyouxing/materials.js +5 -5
  144. package/lib/v2/zhihu/question.js +5 -3
  145. package/lib/v2/zhihu/router.js +1 -1
  146. package/lib/v2/zhihu/zhuanlan.js +2 -2
  147. package/package.json +19 -19
  148. package/lib/routes/universities/tjpyu/ooa.js +0 -73
  149. package/lib/v2/36kr/motif.js +0 -36
  150. package/lib/v2/36kr/news.js +0 -56
  151. package/lib/v2/36kr/newsflashes.js +0 -37
  152. package/lib/v2/36kr/search/article.js +0 -27
  153. package/lib/v2/36kr/user.js +0 -61
  154. package/lib/v2/houxu/templates/description.art +0 -9
@@ -0,0 +1,78 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const iconv = require('iconv-lite');
4
+ const timezone = require('@/utils/timezone');
5
+ const { parseDate } = require('@/utils/parse-date');
6
+
7
+ module.exports = async (ctx) => {
8
+ const rootUrl = ctx.path.split('/').slice(1, 4).join('/');
9
+ const currentUrl = ctx.path.slice(1);
10
+
11
+ const response = await got({
12
+ method: 'get',
13
+ url: currentUrl,
14
+ responseType: 'buffer',
15
+ https: {
16
+ rejectUnauthorized: false,
17
+ },
18
+ });
19
+
20
+ const isGBK = /charset="?'?gb/i.test(response.data.toString());
21
+ const encoding = isGBK ? 'gbk' : 'utf-8';
22
+
23
+ const $ = cheerio.load(iconv.decode(response.data, encoding));
24
+ const author = $('meta[property="og:novel:author"]').attr('content');
25
+ const pubDate = timezone(parseDate($('meta[property="og:novel:update_time"]').attr('content')), +8);
26
+
27
+ let items = $('dl dd a')
28
+ .toArray()
29
+ .reverse()
30
+ .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 1)
31
+ .map((item) => {
32
+ item = $(item);
33
+
34
+ let link = '';
35
+ const url = item.attr('href');
36
+ if (/^http/.test(url)) {
37
+ link = url;
38
+ } else if (/^\//.test(url)) {
39
+ link = `${rootUrl}${url}`;
40
+ } else {
41
+ link = `${currentUrl}/${url}`;
42
+ }
43
+
44
+ return {
45
+ title: item.text(),
46
+ link,
47
+ author,
48
+ pubDate,
49
+ };
50
+ });
51
+
52
+ items = await Promise.all(
53
+ items.map((item) =>
54
+ ctx.cache.tryGet(item.link, async () => {
55
+ const detailResponse = await got({
56
+ method: 'get',
57
+ url: item.link,
58
+ responseType: 'buffer',
59
+ https: {
60
+ rejectUnauthorized: false,
61
+ },
62
+ });
63
+
64
+ const content = cheerio.load(iconv.decode(detailResponse.data, encoding));
65
+
66
+ item.description = content('#content').html();
67
+
68
+ return item;
69
+ })
70
+ )
71
+ );
72
+
73
+ ctx.state.data = {
74
+ title: `${$('meta[property="og:title"]').attr('content')} - 笔趣阁`,
75
+ link: currentUrl,
76
+ item: items,
77
+ };
78
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/:url': ['nczitzk'],
3
+ };
@@ -0,0 +1,29 @@
1
+ const biquge = {
2
+ _name: '笔趣阁',
3
+ '.': [
4
+ {
5
+ title: '',
6
+ docs: 'https://docs.rsshub.app/reading.html#bi-qu-ge-xiao-shuo',
7
+ source: ['/'],
8
+ target: (params, url) => `/biquge/${new URL(url).toString()}`,
9
+ },
10
+ ],
11
+ };
12
+
13
+ module.exports = {
14
+ 'xbiquwx.la': biquge,
15
+ 'biqu5200.net': biquge,
16
+ 'xbiquge.so': biquge,
17
+ 'biqugeu.net': biquge,
18
+ 'b520.cc': biquge,
19
+ 'biquge.biz': biquge,
20
+ 'xbiquge.la': biquge,
21
+ 'qbiqu.com': biquge,
22
+ 'bswtan.com': biquge,
23
+ 'biquge.co': biquge,
24
+ 'zhhbqg.com': biquge,
25
+ 'biqugse.com': biquge,
26
+ 'ibiquge.net': biquge,
27
+ 'shuquge.com': biquge,
28
+ 'mayiwxw.com': biquge,
29
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get(/([\w/-]+)?/, require('./index'));
3
+ };
@@ -0,0 +1,68 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+ const { art } = require('@/utils/render');
5
+ const path = require('path');
6
+
7
+ const rootUrl = 'http://ccfcv.ccf.org.cn';
8
+
9
+ const cateTitleMap = {
10
+ xsdt: {
11
+ xsqy: '学术前沿',
12
+ rdzw: '热点征文',
13
+ xshy: '学术会议',
14
+ },
15
+ };
16
+
17
+ module.exports = async (ctx) => {
18
+ const channel = ctx.params.channel;
19
+ const cate = ctx.params.category;
20
+
21
+ const url = `${rootUrl}/ccfcv/${channel}/${cate}/`;
22
+ const response = await got(url);
23
+ const $ = cheerio.load(response.data);
24
+
25
+ let items = $('div.article-item')
26
+ .toArray()
27
+ .map((item) => {
28
+ item = $(item);
29
+ return {
30
+ title: item.find('h3 a').text(),
31
+ link: (cate === 'xsqy' ? rootUrl : '') + item.find('h3 a').attr('href'),
32
+ pubDate: parseDate(item.find('div p').text()),
33
+ };
34
+ });
35
+
36
+ if (cate === 'xsqy') {
37
+ items = await Promise.all(
38
+ items.map((item) =>
39
+ ctx.cache.tryGet(item.link, async () => {
40
+ let detailResponse;
41
+
42
+ try {
43
+ detailResponse = await got(item.link);
44
+ } catch (error) {
45
+ item.status = 404;
46
+ }
47
+
48
+ if (item.status !== 404) {
49
+ const content = cheerio.load(detailResponse.data);
50
+ const pdfUrl = content('div.g-box1 p a').attr('href');
51
+ item.description = art(path.join(__dirname, 'templates/description.art'), {
52
+ pdfUrl,
53
+ });
54
+ }
55
+
56
+ delete item.status;
57
+ return item;
58
+ })
59
+ )
60
+ );
61
+ }
62
+
63
+ ctx.state.data = {
64
+ title: `计算机视觉专委 - ${cateTitleMap[channel][cate]}`,
65
+ link: url,
66
+ item: items,
67
+ };
68
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/:channel/:category': ['elxy'],
3
+ };
@@ -0,0 +1,25 @@
1
+ module.exports = {
2
+ 'ccfcv.ccf.org.cn': {
3
+ _name: '计算机视觉专委会',
4
+ www: [
5
+ {
6
+ title: '学术动态 - 学术前沿',
7
+ docs: 'https://docs.rsshub.app/study.html#ji-suan-ji-shi-jue-zhuan-wei-hui',
8
+ source: ['/ccfcv/xsdt/xsqy/'],
9
+ target: '/ccfcv/xsdt/xsqy',
10
+ },
11
+ {
12
+ title: '学术动态 - 热点征文',
13
+ docs: 'https://docs.rsshub.app/study.html#ji-suan-ji-shi-jue-zhuan-wei-hui',
14
+ source: ['/ccfcv/xsdt/rdzw/'],
15
+ target: '/ccfcv/xsdt/rdzw',
16
+ },
17
+ {
18
+ title: '学术动态 - 学术会议',
19
+ docs: 'https://docs.rsshub.app/study.html#ji-suan-ji-shi-jue-zhuan-wei-hui',
20
+ source: ['/ccfcv/xsdt/xshy/'],
21
+ target: '/ccfcv/xsdt/xshy',
22
+ },
23
+ ],
24
+ },
25
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/:channel/:category', require('./index'));
3
+ };
@@ -0,0 +1 @@
1
+ <center><embed src="{{ pdfUrl }}"></center>
@@ -1,4 +1,5 @@
1
1
  module.exports = {
2
2
  '/xxgk/:category': ['TonyRL'],
3
+ '/zdyz/:category': ['TonyRL'],
3
4
  '/:channel/:category': ['Fatpandac'],
4
5
  };
@@ -56,6 +56,18 @@ module.exports = {
56
56
  source: ['/main/xxgk/listpage/4b5255eb0a84820cef4ca3e8b6bbe20c'],
57
57
  target: '/cde/xxgf/cliniCal',
58
58
  },
59
+ {
60
+ title: '发布通告 - 指导原则专栏',
61
+ docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye',
62
+ source: ['/main/xxgk/listpage/2853510d929253719601db17b8a9fd81'],
63
+ target: '/cde/zdyz/domesticGuide',
64
+ },
65
+ {
66
+ title: '征求意见 - 指导原则专栏',
67
+ docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-shen-ping-wang-zhan-shou-ye',
68
+ source: ['/main/xxgk/listpage/3c49fad55caad7a034c263cfc2b6eb9c'],
69
+ target: '/cde/zdyz/opinionList',
70
+ },
59
71
  ],
60
72
  },
61
73
  };
@@ -1,4 +1,5 @@
1
1
  module.exports = function (router) {
2
2
  router.get('/xxgk/:category', require('./xxgk'));
3
+ router.get('/zdyz/:category', require('./zdyz'));
3
4
  router.get('/:channel/:category', require('./index'));
4
5
  };
@@ -0,0 +1,77 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+ const utils = require('./utils');
5
+
6
+ const baseUrl = 'https://www.cde.org.cn';
7
+ const zdyzMap = {
8
+ zdyz: {
9
+ domesticGuide: {
10
+ title: '发布通告',
11
+ url: `${baseUrl}/zdyz/listpage/2853510d929253719601db17b8a9fd81`,
12
+ endPoint: '/zdyz/getDomesticGuideList',
13
+ form: {
14
+ pageNum: 1,
15
+ pageSize: 10,
16
+ searchTitle: '',
17
+ isFbtg: 1,
18
+ classid: '2853510d929253719601db17b8a9fd81',
19
+ issueDate1: '',
20
+ issueDate2: '',
21
+ },
22
+ },
23
+ opinionList: {
24
+ title: '征求意见',
25
+ url: `${baseUrl}/zdyz/listpage/3c49fad55caad7a034c263cfc2b6eb9c`,
26
+ endPoint: '/zdyz/getOpinionList',
27
+ form: {
28
+ pageNum: 1,
29
+ pageSize: 10,
30
+ searchTitle: '',
31
+ issueDate1: '',
32
+ issueDate2: '',
33
+ fclass: '征求意见',
34
+ },
35
+ },
36
+ },
37
+ };
38
+
39
+ module.exports = async (ctx) => {
40
+ const { category } = ctx.params;
41
+
42
+ const { data } = await got.post(`${baseUrl}${zdyzMap.zdyz[category].endPoint}`, {
43
+ form: zdyzMap.zdyz[category].form,
44
+ headers: {
45
+ referer: zdyzMap.zdyz[category].url,
46
+ cookie: await utils.getCookie(ctx),
47
+ },
48
+ });
49
+
50
+ const list = data.data.records.map((item) => ({
51
+ title: item.title,
52
+ pubDate: parseDate(item.issueDate),
53
+ link: item.externalLinks,
54
+ }));
55
+
56
+ const items = await Promise.all(
57
+ list.map((item) =>
58
+ ctx.cache.tryGet(item.link, async () => {
59
+ const response = await got(item.link, {
60
+ headers: {
61
+ referer: zdyzMap.zdyz[category].url,
62
+ cookie: await utils.getCookie(ctx),
63
+ },
64
+ });
65
+ const $ = cheerio.load(response.data);
66
+ item.description = $('.new_detail_content').html() + $('.relatedNews').html();
67
+ return item;
68
+ })
69
+ )
70
+ );
71
+
72
+ ctx.state.data = {
73
+ title: `${zdyzMap.zdyz[category].title} - 国家药品监督管理局药品审评中心`,
74
+ link: zdyzMap.zdyz[category].url,
75
+ item: items,
76
+ };
77
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/premium': ['ttttmr'],
3
+ };
@@ -0,0 +1,23 @@
1
+ const got = require('@/utils/got');
2
+ const { parseDate } = require('@/utils/parse-date');
3
+ const md = require('markdown-it')();
4
+
5
+ module.exports = async (ctx) => {
6
+ const response = await got('https://api.github.com/repos/Dreamacro/clash/releases/tags/premium');
7
+ const data = response.data;
8
+
9
+ ctx.state.data = {
10
+ title: 'Clash Premium Releases',
11
+ link: 'https://github.com/Dreamacro/clash/releases/tag/premium',
12
+ description: 'Clash Premium Releases',
13
+ item: [
14
+ {
15
+ title: data.name,
16
+ author: data.author.login,
17
+ description: md.render(data.body),
18
+ pubDate: parseDate(data.assets[0].updated_at),
19
+ link: `https://github.com/Dreamacro/clash/releases/tag/premium#${encodeURIComponent(data.name)}`,
20
+ },
21
+ ],
22
+ };
23
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'github.com': {
3
+ _name: 'Clash',
4
+ '.': [
5
+ {
6
+ title: 'Premium Releases',
7
+ docs: 'https://docs.rsshub.app/programming.html#cncf',
8
+ source: ['/Dreamacro/clash/releases/tag/premium'],
9
+ target: '/clash/premium',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = (router) => {
2
+ router.get('/premium', require('./premium'));
3
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/oa_news/:type?': ['Jim Kirisame'],
3
+ };
@@ -1,3 +1,5 @@
1
+ /* Removed due to news.gdut.edu.cn no longer exists.
2
+
1
3
  const got = require('@/utils/got');
2
4
  const cheerio = require('cheerio');
3
5
 
@@ -160,3 +162,5 @@ module.exports = async (ctx) => {
160
162
  item: out.length > 0 ? out : articleList,
161
163
  };
162
164
  };
165
+
166
+ */
@@ -0,0 +1,214 @@
1
+ const got = require('@/utils/got');
2
+ const wait = require('@/utils/wait');
3
+ const cheerio = require('cheerio');
4
+ const { CookieJar } = require('tough-cookie');
5
+ const { parseDate } = require('@/utils/parse-date');
6
+ const timezone = require('@/utils/timezone');
7
+ const asyncPool = require('tiny-async-pool');
8
+
9
+ const site = 'https://oas.gdut.edu.cn/seeyon';
10
+ const typeMap = {
11
+ news: {
12
+ id: '-4899485396563308862',
13
+ name: '校内简讯',
14
+ publish: false,
15
+ },
16
+ notice: {
17
+ id: '5854888065150372255',
18
+ name: '校内通知',
19
+ publish: false,
20
+ },
21
+ announcement: {
22
+ id: '5821359576359193913',
23
+ name: '公示公告',
24
+ publish: false,
25
+ },
26
+ tender_result: {
27
+ id: '-1226046021292568614',
28
+ name: '招标结果',
29
+ publish: true,
30
+ },
31
+ tender_invite: {
32
+ id: '-3656117696093796045',
33
+ name: '招标公告',
34
+ publish: true,
35
+ },
36
+ };
37
+
38
+ function getArg(type) {
39
+ if (type.publish) {
40
+ return JSON.stringify([
41
+ {
42
+ pageSize: '20',
43
+ pageNo: 1,
44
+ listType: '1',
45
+ spaceType: '',
46
+ spaceId: '',
47
+ typeId: type.id,
48
+ condition: 'publishDepartment',
49
+ textfield1: '',
50
+ textfield2: '',
51
+ myNews: '',
52
+ },
53
+ ]);
54
+ } else {
55
+ return JSON.stringify([
56
+ {
57
+ pageSize: '20',
58
+ pageNo: 1,
59
+ listType: '1',
60
+ spaceType: '2',
61
+ spaceId: '',
62
+ typeId: '',
63
+ condition: 'publishDepartment',
64
+ textfield1: '',
65
+ textfield2: '',
66
+ myNews: '',
67
+ fragmentId: type.id,
68
+ ordinal: '0',
69
+ panelValue: 'designated_value',
70
+ },
71
+ ]);
72
+ }
73
+ }
74
+
75
+ module.exports = async (ctx) => {
76
+ const typeParam = ctx.params.type ?? 'notice';
77
+ if (typeMap[typeParam] === undefined) {
78
+ throw Error('通知类型' + typeParam + '未定义');
79
+ }
80
+
81
+ const type = typeMap[typeParam];
82
+
83
+ // 获取cookie
84
+ const cookieJar = new CookieJar();
85
+ await got(site + '/main.do', {
86
+ cookieJar,
87
+ });
88
+
89
+ // 获取文章列表
90
+ const listUrl = '/ajax.do?method=ajaxAction&managerName=newsDataManager';
91
+ const resp = await got.post(site + listUrl, {
92
+ cookieJar,
93
+ form: {
94
+ managerMethod: 'findListDatas',
95
+ arguments: getArg(type),
96
+ },
97
+ });
98
+
99
+ if (!resp.data.list) {
100
+ throw Error('文章列表获取失败,可能是被临时限制了访问,请稍后重试');
101
+ }
102
+
103
+ // 构造文章数组
104
+ const articles = [];
105
+ resp.data.list.forEach((item) => {
106
+ articles.push({
107
+ title: item.title,
108
+ guid: item.id,
109
+ link: site + '/newsData.do?method=newsView&newsId=' + item.id,
110
+ pubDate: timezone(parseDate(item.publishDate1), +8),
111
+ author: item.publishUserDepart,
112
+ category: item.typeName,
113
+ });
114
+ });
115
+
116
+ // 获取实际的文章内容
117
+ for await (const data of asyncPool(2, articles, async (data) => {
118
+ const link = data.link;
119
+ data.description = await ctx.cache.tryGet(link, async () => {
120
+ // 获取数据
121
+ const response = await got(link, {
122
+ cookieJar,
123
+ });
124
+
125
+ const $ = cheerio.load(response.data);
126
+ const node = $('#content');
127
+ // 清理样式
128
+ node.find('*')
129
+ .filter(function () {
130
+ return this.type === 'comment' || this.tagName === 'meta' || this.tagName === 'style';
131
+ })
132
+ .remove();
133
+ node.find('*')
134
+ .contents()
135
+ .filter(function () {
136
+ return this.type === 'comment' || this.tagName === 'meta' || this.tagName === 'style';
137
+ })
138
+ .remove();
139
+ node.find('*').each(function () {
140
+ if (this.attribs.style !== undefined) {
141
+ const newSty = this.attribs.style
142
+ .split(';')
143
+ .filter((s) => {
144
+ const styBlocklist = ['color:rgb(0,0,0)', 'color:black', 'background:rgb(255,255,255)', 'background:white', 'text-align:left', 'text-align:justify', 'font-style:normal', 'font-weight:normal'];
145
+ const styPrefixBlocklist = [
146
+ 'font-family',
147
+ 'font-size',
148
+ 'background',
149
+ 'text-autospace',
150
+ 'text-transform',
151
+ 'letter-spacing',
152
+ 'line-height',
153
+ 'padding',
154
+ 'margin',
155
+ 'text-justify',
156
+ 'word-break',
157
+ 'vertical-align',
158
+ 'mso-',
159
+ '-ms-',
160
+ ];
161
+ const sty = s.trim();
162
+ if (styBlocklist.includes(sty.replace(/\s+/g, ''))) {
163
+ return false;
164
+ }
165
+ for (const prefix of styPrefixBlocklist) {
166
+ if (sty.startsWith(prefix)) {
167
+ return false;
168
+ }
169
+ }
170
+ return true;
171
+ })
172
+ .join(';');
173
+ if (newSty) {
174
+ this.attribs.style = newSty;
175
+ } else {
176
+ delete this.attribs.style;
177
+ }
178
+ }
179
+ if (this.attribs.class) {
180
+ if (this.attribs.class.trim().startsWith('Mso')) {
181
+ delete this.attribs.class;
182
+ }
183
+ }
184
+ if (this.attribs.lang) {
185
+ delete this.attribs.lang;
186
+ }
187
+ if (this.tagName === 'font' || this.tagName === 'o:p') {
188
+ $(this).replaceWith(this.childNodes);
189
+ }
190
+ if (this.tagName === 'span' && !this.attribs.style) {
191
+ $(this).replaceWith(this.childNodes);
192
+ }
193
+ });
194
+ node.find('span').each(function () {
195
+ if (this.childNodes.length === 0) {
196
+ $(this).remove();
197
+ }
198
+ });
199
+
200
+ // 防止太快被Ban
201
+ await wait(500);
202
+ return node.html();
203
+ });
204
+ })) {
205
+ data;
206
+ }
207
+
208
+ ctx.state.data = {
209
+ title: `广东工业大学新闻通知网 - ` + type.name,
210
+ link: site,
211
+ description: `广东工业大学新闻通知网`,
212
+ item: articles,
213
+ };
214
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'gdut.edu.cn': {
3
+ _name: '广东工业大学',
4
+ oas: [
5
+ {
6
+ title: '通知公文网',
7
+ docs: 'https://docs.rsshub.app/university.html#guang-dong-gong-ye-da-xue-tong-zhi-gong-wen-wang',
8
+ source: '/seeyon',
9
+ target: '/gdut/oa_news/',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/oa_news/:type?', require('./oa_news'));
3
+ };
@@ -10,6 +10,6 @@ module.exports = {
10
10
  '/starred_repos/:user': ['LanceZhu'],
11
11
  '/stars/:user/:repo': ['HenryQW'],
12
12
  '/topics/:name/:qs?': ['queensferryme'],
13
- '/trending/:since/:language?/:spoken_language?': ['DIYgod'],
13
+ '/trending/:since/:language?/:spoken_language?': ['DIYgod', 'jameschensmith'],
14
14
  '/user/followers/:user': ['HenryQW'],
15
15
  };
@@ -0,0 +1,5 @@
1
+ <img src="{{@ cover }}">
2
+ <br>{{@ desc }}
3
+ <br><br>Language: {{@ lang }}
4
+ <br>Stars: {{@ stars }}
5
+ <br>Forks: {{@ forks }}