rsshub 1.0.0-master.baeafb9 → 1.0.0-master.bb80a2e

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 (104) hide show
  1. package/README.md +4 -3
  2. package/lib/config.js +4 -0
  3. package/lib/middleware/cache/index.js +3 -3
  4. package/lib/middleware/cache/memory.js +5 -11
  5. package/lib/router.js +23 -22
  6. package/lib/routes/amd/graphicsdrivers.js +1 -1
  7. package/lib/routes/weibo/keyword.js +18 -10
  8. package/lib/routes/weibo/super_index.js +24 -15
  9. package/lib/routes/weibo/timeline.js +37 -14
  10. package/lib/routes/weibo/user.js +42 -18
  11. package/lib/routes/weibo/utils.js +39 -0
  12. package/lib/utils/parse-date.js +171 -17
  13. package/lib/utils/torrent.js +9 -1
  14. package/lib/v2/asus/bios.js +38 -0
  15. package/lib/v2/asus/maintainer.js +3 -0
  16. package/lib/v2/asus/radar.js +13 -0
  17. package/lib/v2/asus/router.js +3 -0
  18. package/lib/v2/asus/templates/bios.art +6 -0
  19. package/lib/v2/douban/people/status.js +10 -2
  20. package/lib/v2/douban/people/wish.js +55 -43
  21. package/lib/v2/gov/anhui/kjt.js +56 -0
  22. package/lib/v2/gov/maintainer.js +1 -0
  23. package/lib/v2/gov/radar.js +90 -76
  24. package/lib/v2/gov/router.js +1 -0
  25. package/lib/v2/hupu/all.js +73 -0
  26. package/lib/v2/hupu/bbs.js +64 -0
  27. package/lib/v2/hupu/index.js +72 -0
  28. package/lib/v2/hupu/maintainer.js +7 -0
  29. package/lib/v2/hupu/radar.js +35 -0
  30. package/lib/v2/hupu/router.js +7 -0
  31. package/lib/v2/hupu/templates/description.art +6 -0
  32. package/lib/{routes → v2}/ifeng/feng.js +7 -5
  33. package/lib/v2/ifeng/maintainer.js +3 -0
  34. package/lib/v2/ifeng/radar.js +11 -0
  35. package/lib/v2/ifeng/router.js +3 -0
  36. package/lib/{routes → v2}/ifeng/utils.js +0 -0
  37. package/lib/v2/kakuyomu/episode.js +54 -0
  38. package/lib/v2/kakuyomu/maintainer.js +3 -0
  39. package/lib/v2/kakuyomu/radar.js +13 -0
  40. package/lib/v2/kakuyomu/router.js +1 -0
  41. package/lib/v2/mihoyo/bbs.js +62 -0
  42. package/lib/v2/mihoyo/maintainer.js +3 -0
  43. package/lib/v2/mihoyo/radar.js +31 -0
  44. package/lib/v2/mihoyo/router.js +3 -0
  45. package/lib/v2/mihoyo/templates/description.art +6 -0
  46. package/lib/{routes → v2}/mpaypass/main.js +23 -27
  47. package/lib/v2/mpaypass/maintainer.js +4 -0
  48. package/lib/v2/mpaypass/news.js +39 -0
  49. package/lib/v2/mpaypass/radar.js +19 -0
  50. package/lib/v2/mpaypass/router.js +4 -0
  51. package/lib/v2/natgeo/dailyphoto.js +32 -0
  52. package/lib/v2/natgeo/dailyselection.js +41 -0
  53. package/lib/v2/natgeo/maintainer.js +5 -0
  54. package/lib/{routes → v2}/natgeo/natgeo.js +18 -32
  55. package/lib/v2/natgeo/radar.js +24 -0
  56. package/lib/v2/natgeo/router.js +5 -0
  57. package/lib/v2/natgeo/templates/dailyPhoto.art +5 -0
  58. package/lib/v2/nuaa/cs/index.js +87 -0
  59. package/lib/v2/nuaa/jwc/jwc.js +82 -0
  60. package/lib/v2/nuaa/maintainer.js +5 -0
  61. package/lib/v2/nuaa/radar.js +23 -0
  62. package/lib/v2/nuaa/router.js +5 -0
  63. package/lib/{routes/universities → v2}/nuaa/utils/pypasswaf.js +1 -1
  64. package/lib/{routes/universities → v2}/nuaa/yjsy/yjsy.js +16 -22
  65. package/lib/v2/picuki/profile.js +12 -3
  66. package/lib/v2/pubmed/maintainer.js +3 -0
  67. package/lib/v2/pubmed/radar.js +13 -0
  68. package/lib/v2/pubmed/router.js +3 -0
  69. package/lib/v2/pubmed/templates/description.art +7 -0
  70. package/lib/v2/pubmed/trending.js +58 -0
  71. package/lib/v2/qweather/3days.js +46 -0
  72. package/lib/v2/qweather/maintainer.js +4 -0
  73. package/lib/v2/qweather/now.js +46 -0
  74. package/lib/v2/qweather/router.js +4 -0
  75. package/lib/v2/qweather/util/3days.art +20 -0
  76. package/lib/v2/qweather/util/now.art +16 -0
  77. package/lib/v2/telegram/channel.js +10 -6
  78. package/lib/v2/test/index.js +1 -1
  79. package/lib/{routes → v2}/thepaper/839studio/category.js +0 -0
  80. package/lib/{routes → v2}/thepaper/839studio/studio.js +0 -0
  81. package/lib/{routes → v2}/thepaper/channel.js +0 -0
  82. package/lib/v2/thepaper/factpaper.js +61 -0
  83. package/lib/{routes → v2}/thepaper/featured.js +0 -0
  84. package/lib/{routes → v2}/thepaper/list.js +0 -0
  85. package/lib/v2/thepaper/maintainer.js +8 -0
  86. package/lib/v2/thepaper/radar.js +42 -0
  87. package/lib/v2/thepaper/router.js +8 -0
  88. package/lib/v2/thepaper/templates/factpaper.art +12 -0
  89. package/lib/v2/thepaper/utils.js +55 -0
  90. package/lib/v2/zooTeam/blog.js +32 -0
  91. package/lib/v2/zooTeam/maintainer.js +4 -0
  92. package/lib/v2/zooTeam/radar.js +21 -0
  93. package/lib/v2/zooTeam/router.js +4 -0
  94. package/lib/v2/zooTeam/weekly.js +34 -0
  95. package/package.json +12 -8
  96. package/lib/routes/hupu/all.js +0 -53
  97. package/lib/routes/hupu/bbs.js +0 -83
  98. package/lib/routes/hupu/dept.js +0 -66
  99. package/lib/routes/mpaypass/news.js +0 -43
  100. package/lib/routes/natgeo/dailyphoto.js +0 -27
  101. package/lib/routes/pubmed/trending.js +0 -65
  102. package/lib/routes/thepaper/utils.js +0 -48
  103. package/lib/routes/universities/nuaa/cs/index.js +0 -84
  104. package/lib/routes/universities/nuaa/jwc/jwc.js +0 -105
@@ -0,0 +1,62 @@
1
+ const got = require('@/utils/got');
2
+ const { art } = require('@/utils/render');
3
+ const path = require('path');
4
+ const { parseDate } = require('@/utils/parse-date');
5
+ // 游戏id
6
+ const GITS_MAP = {
7
+ 1: '崩坏三',
8
+ 2: '原神',
9
+ 3: '崩坏二',
10
+ 4: '未定事件簿',
11
+ 6: '崩坏:星穹铁道',
12
+ };
13
+
14
+ // 公告类型
15
+ const TYPE_MAP = {
16
+ 1: '公告',
17
+ 2: '活动',
18
+ 3: '资讯',
19
+ };
20
+
21
+ const renderDescription = (description, images) => art(path.join(__dirname, 'templates/description.art'), { description, images });
22
+
23
+ module.exports = async (ctx) => {
24
+ const { gids, type = '2', page_size = '20', last_id = '' } = ctx.params;
25
+ const query = new URLSearchParams({
26
+ gids,
27
+ type,
28
+ page_size,
29
+ last_id,
30
+ }).toString();
31
+ const url = `https://bbs-api.mihoyo.com/post/wapi/getNewsList?${query}`;
32
+ const response = await got({
33
+ method: 'get',
34
+ url,
35
+ });
36
+ const list = response?.data?.data?.list;
37
+ if (!list) {
38
+ throw new Error('未获取到数据!');
39
+ }
40
+ const title = `米游社 - ${GITS_MAP[gids] || ''} - ${TYPE_MAP[type] || ''}`;
41
+ const items = list.map((e) => {
42
+ const author = e.user.nickname;
43
+ const title = e.post.subject;
44
+ const link = `https://bbs.mihoyo.com/ys/article/${e.post.post_id}`;
45
+ const description = renderDescription(e.post.content, e.post.images);
46
+ const pubDate = parseDate(e.post.created_at * 1000);
47
+ return {
48
+ author,
49
+ title,
50
+ link,
51
+ description,
52
+ pubDate,
53
+ };
54
+ });
55
+ const data = {
56
+ title,
57
+ link: url,
58
+ item: items,
59
+ };
60
+
61
+ ctx.state.data = data;
62
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/bbs/official/:gids/:type?/:page_size?/:last_id?': ['CaoMeiYouRen'],
3
+ };
@@ -0,0 +1,31 @@
1
+ module.exports = {
2
+ 'mihoyo.com': {
3
+ _name: '米游社v2',
4
+ bbs: [
5
+ {
6
+ title: '米游社 - 官方公告',
7
+ docs: 'https://docs.rsshub.app/game.html#mi-ha-you-mi-you-she-guan-fang-gong-gao',
8
+ // source: ['/ys/home/28', '/bh3/home/6', '/bh2/home/31', '/wd/home/33', '/sr/home/53'],
9
+ source: ['/:game/home/28', '/:game/home/6', '/:game/home/31', '/:game/home/33', '/:game/home/53'],
10
+ target: (params, url) => {
11
+ const GITS_MAP = {
12
+ bh3: 1, // '崩坏三',
13
+ ys: 2, // '原神',
14
+ bh2: 3, // '崩坏二',
15
+ wd: 4, // '未定事件簿',
16
+ sr: 6, // '崩坏:星穹铁道',
17
+ };
18
+ const { game } = params;
19
+ const gids = GITS_MAP[game];
20
+ if (!gids) {
21
+ return '';
22
+ }
23
+ const { type = '2' } = new URL(url).searchParams;
24
+ const page_size = '20';
25
+ const last_id = '';
26
+ return `/mihoyo/bbs/official/${gids}/${type}/${page_size}/${last_id}`;
27
+ },
28
+ },
29
+ ],
30
+ },
31
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/bbs/official/:gids/:type?/:page_size?/:last_id?', require('./bbs'));
3
+ };
@@ -0,0 +1,6 @@
1
+ {{ description }}
2
+ {{if images}}
3
+ {{each images}}
4
+ <img src="{{ $value }}">
5
+ {{/each}}
6
+ {{/if}}
@@ -1,5 +1,7 @@
1
- const got = require('../../utils/got');
1
+ const got = require('@/utils/got');
2
2
  const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+ const timezone = require('@/utils/timezone');
3
5
 
4
6
  module.exports = async (ctx) => {
5
7
  let title_url = '';
@@ -29,40 +31,34 @@ module.exports = async (ctx) => {
29
31
  .map(function () {
30
32
  const info = {
31
33
  title: $(this).find('#title').text(),
32
- link: $(this).find('#pic a').attr('href'),
33
- pic: $(this).find('#pic img').attr('src'),
34
+ link: $(this).find('#title').find('a').attr('href'),
34
35
  time: $(this).find('#time').text(),
36
+ category: $(this)
37
+ .find('#keywords')
38
+ .find('a')
39
+ .toArray()
40
+ .map((e) => $(e).text().trim()),
35
41
  };
36
42
  return info;
37
43
  })
38
44
  .get();
39
45
 
40
46
  const out = await Promise.all(
41
- list.map(async (info) => {
42
- const title = info.title;
43
- let date = info.time.toString();
44
- date = date.substring(2, date.length);
45
- const link = info.link;
47
+ list.map((info) =>
48
+ ctx.cache.tryGet(info.link, async () => {
49
+ const response = await got(info.link);
50
+ const $ = cheerio.load(response.data);
51
+ const newsbody = $('div.newsbody').html();
46
52
 
47
- const cache = await ctx.cache.get(link);
48
- if (cache) {
49
- return Promise.resolve(JSON.parse(cache));
50
- }
51
-
52
- const response = await got.get(link);
53
- const $ = cheerio.load(response.data);
54
- const newsbody = $('div.newsbody').html();
55
-
56
- const single = {
57
- title,
58
- link,
59
- pubDate: date,
60
- description: newsbody,
61
- };
62
-
63
- ctx.cache.set(link, JSON.stringify(single));
64
- return Promise.resolve(single);
65
- })
53
+ return {
54
+ title: info.title,
55
+ link: info.link,
56
+ pubDate: timezone(parseDate(info.time), +8),
57
+ description: newsbody,
58
+ category: info.category,
59
+ };
60
+ })
61
+ )
66
62
  );
67
63
 
68
64
  ctx.state.data = {
@@ -0,0 +1,4 @@
1
+ module.exports = {
2
+ '/main/:type?': ['zhuan-zhu'],
3
+ '/news': ['LogicJake', 'genghis-yang'],
4
+ };
@@ -0,0 +1,39 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+ const timezone = require('@/utils/timezone');
5
+
6
+ module.exports = async (ctx) => {
7
+ const link = 'http://m.mpaypass.com.cn';
8
+ const listData = await got(link);
9
+ const $list = cheerio.load(listData.data);
10
+ ctx.state.data = {
11
+ title: '新闻 - 移动支付网',
12
+ link,
13
+ language: 'zh-CN',
14
+ item: await Promise.all(
15
+ $list('.Newslist-li')
16
+ .map((_, el) => {
17
+ const $el = $list(el);
18
+ const $a = $el.find('.Newslist-title a');
19
+ const href = $a.attr('href');
20
+ const title = $a.text();
21
+ const date = $el.find('.Newslist-time span').text();
22
+
23
+ return ctx.cache.tryGet(href, async () => {
24
+ const contentData = await got.get(href);
25
+ const $content = cheerio.load(contentData.data);
26
+ const description = $content('.newslist-body').html();
27
+
28
+ return {
29
+ title,
30
+ description,
31
+ link: href,
32
+ pubDate: timezone(parseDate(date), +8),
33
+ };
34
+ });
35
+ })
36
+ .get()
37
+ ),
38
+ };
39
+ };
@@ -0,0 +1,19 @@
1
+ module.exports = {
2
+ 'mpaypass.com.cn': {
3
+ _name: '移动支付网',
4
+ '.': [
5
+ {
6
+ title: '新闻',
7
+ docs: 'https://docs.rsshub.app/new-media.html#yi-dong-zhi-fu-wang',
8
+ source: '/',
9
+ target: '/mpaypass/news',
10
+ },
11
+ {
12
+ title: '分类',
13
+ docs: 'https://docs.rsshub.app/new-media.html#yi-dong-zhi-fu-wang',
14
+ source: ['/:type', '/'],
15
+ target: (params) => `/mpaypass/main/${params.type.replace('.html', '')}`,
16
+ },
17
+ ],
18
+ },
19
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = (router) => {
2
+ router.get('/main/:type?', require('./main'));
3
+ router.get('/news', require('./news'));
4
+ };
@@ -0,0 +1,32 @@
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
+ const config = require('@/config').value;
7
+
8
+ module.exports = async (ctx) => {
9
+ const rootUrl = 'https://www.nationalgeographic.com';
10
+ const apiUrl = `${rootUrl}/photo-of-the-day`;
11
+ const response = await ctx.cache.tryGet(apiUrl, async () => (await got(apiUrl)).data, config.cache.contentExpire, false);
12
+ const $ = cheerio.load(response);
13
+
14
+ const natgeo = JSON.parse($.html().match(/window\['__natgeo__'\]=(.*);/)[1]);
15
+ const media = natgeo.page.content.mediaspotlight.frms[0].mods[0].edgs[1].media;
16
+
17
+ const items = media.map((item) => ({
18
+ title: item.meta.title,
19
+ description: art(path.join(__dirname, 'templates/dailyPhoto.art'), {
20
+ img: item.img,
21
+ }),
22
+ link: rootUrl + item.locator,
23
+ pubDate: parseDate(item.caption.preHeading),
24
+ author: item.img.crdt,
25
+ }));
26
+
27
+ ctx.state.data = {
28
+ title: 'Nat Geo Photo of the Day',
29
+ link: apiUrl,
30
+ item: items,
31
+ };
32
+ };
@@ -0,0 +1,41 @@
1
+ const got = require('@/utils/got');
2
+ const timezone = require('@/utils/timezone');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+
5
+ module.exports = async (ctx) => {
6
+ const host = 'http://dili.bdatu.com/jiekou/mains/p1.html';
7
+ const data = await got(host);
8
+
9
+ let sort = 0;
10
+ let addtime = '';
11
+
12
+ for (let i = 0; i < data.data.album.length; i++) {
13
+ if (parseInt(data.data.album[i].ds) === 1) {
14
+ sort = data.data.album[i].sort;
15
+ addtime = data.data.album[i].addtime;
16
+ break;
17
+ }
18
+ }
19
+ const api = 'http://dili.bdatu.com/jiekou/albums/a' + sort + '.html';
20
+ const response = await got(api);
21
+ const items = response.data.picture;
22
+ const out = new Array();
23
+
24
+ items.map((item) => {
25
+ const info = {
26
+ title: item.title,
27
+ link: item.url,
28
+ description: `<img src="${item.url}"><br>` + item.content,
29
+ pubDate: timezone(parseDate(addtime), +0),
30
+ guid: item.id,
31
+ };
32
+ out.push(info);
33
+ return info;
34
+ });
35
+
36
+ ctx.state.data = {
37
+ title: 'Photo of the Daily Selection',
38
+ link: api,
39
+ item: out,
40
+ };
41
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ '/dailyselection': ['OrangeEd1t'],
3
+ '/dailyphoto': ['LogicJake', 'OrangeEd1t', 'TonyRL'],
4
+ '/:cat/:type?': ['fengkx'],
5
+ };
@@ -1,65 +1,51 @@
1
1
  const cheerio = require('cheerio');
2
2
  const got = require('@/utils/got');
3
+ const { parseDate } = require('@/utils/parse-date');
3
4
 
4
5
  // https://www.natgeomedia.com//article/
5
6
 
6
- const MonthMap = {
7
- JAN: 0,
8
- FEB: 1,
9
- MAR: 2,
10
- APR: 3,
11
- MAY: 4,
12
- JUN: 5,
13
- JUL: 6,
14
- AUG: 7,
15
- SEP: 8,
16
- OCT: 9,
17
- NOV: 10,
18
- DEC: 11,
19
- };
20
-
21
7
  async function load(link) {
22
- const { data } = await got.get(link);
8
+ const { data } = await got(link);
23
9
  const $ = cheerio.load(data);
24
10
  const dtStr = $('.content-title-area')
25
11
  .find('h6')
26
12
  .first()
27
- .text()
28
- .split(/[\s.]+/);
29
- const dt = new Date();
30
- dt.setMonth(MonthMap[dtStr[0].toUpperCase()]);
31
- dt.setDate(dtStr[1]);
13
+ .html()
14
+ .replace(/&nbsp;/gi, ' ')
15
+ .trim();
16
+
32
17
  let description = $('article').first().html() + $('article').eq(1).html();
33
18
  if (/photo/.test(link)) {
34
19
  description = $('#content-album').html() + description;
35
20
  }
36
21
  return {
37
22
  title: $('title').text(),
38
- pubDate: dt.toUTCString(),
23
+ pubDate: parseDate(dtStr, 'MMM. DD YYYY'),
39
24
  description,
40
25
  };
41
26
  }
42
27
 
43
28
  module.exports = async (ctx) => {
44
- const type = ctx.params.type || '';
29
+ const type = ctx.params.type ?? '';
45
30
  const url = `https://www.natgeomedia.com/${ctx.params.cat}/${type}`;
46
- const res = await got.get(url);
31
+ const res = await got(url);
47
32
  const $ = cheerio.load(res.data);
48
33
 
49
- const urlList = Array.prototype.map.call($('.article-link-w100').find('.read-btn'), (i) => $(i).find('a[href]').first().attr('href'));
34
+ const urlList = $('.article-link-w100')
35
+ .find('.read-btn')
36
+ .toArray()
37
+ .map((i) => ({
38
+ link: $(i).find('a[href]').first().attr('href'),
39
+ }));
50
40
 
51
- const count = [];
52
- for (let i = 0; i < Math.min(urlList.length, 10); i++) {
53
- count.push(i);
54
- }
55
41
  const out = await Promise.all(
56
- count.map(async (i) => {
57
- const link = urlList[i];
42
+ urlList.map(async (i) => {
43
+ const link = i.link;
58
44
  const single = {
59
45
  link,
60
46
  };
61
47
  const other = await ctx.cache.tryGet(link, () => load(link));
62
- return Object.assign({}, single, other);
48
+ return { ...single, ...other };
63
49
  })
64
50
  );
65
51
  ctx.state.data = {
@@ -0,0 +1,24 @@
1
+ module.exports = {
2
+ 'nationalgeographic.com': {
3
+ _name: '国家地理',
4
+ '.': [
5
+ {
6
+ title: '每日一图',
7
+ docs: 'https://docs-rsshub.pages.dev/picture.html#guo-jia-di-li',
8
+ source: ['/photo-of-the-day/*', '/'],
9
+ target: '/natgeo/dailyphoto',
10
+ },
11
+ ],
12
+ },
13
+ 'natgeomedia.com': {
14
+ _name: '国家地理',
15
+ '.': [
16
+ {
17
+ title: '分类',
18
+ docs: 'https://docs.rsshub.app/travel.html#guo-jia-di-li',
19
+ source: ['/:cat/:type', '/'],
20
+ target: '/natgeo/:cat/:type',
21
+ },
22
+ ],
23
+ },
24
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = (router) => {
2
+ router.get('/dailyphoto', require('./dailyphoto'));
3
+ router.get('/dailyselection', require('./dailyselection'));
4
+ router.get('/:cat/:type?', require('./natgeo'));
5
+ };
@@ -0,0 +1,5 @@
1
+ <img src="{{@ img.src }}" alt="{{@ img.altText }}">
2
+ <br>
3
+ <h3>{{@ img.ttl }}</h3>
4
+ <p>{{@ img.dsc }}</p>
5
+ <p>{{@ img.crdt }}</p>
@@ -0,0 +1,87 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+ const getCookie = require('../utils/pypasswaf');
5
+ const host = 'http://cs.nuaa.edu.cn/';
6
+
7
+ const map = new Map([
8
+ ['tzgg', { title: '南京航空航天大学计算机科学与技术学院 -- 通知公告', suffix: 'tzgg/list.htm' }],
9
+ ['rdxw', { title: '南京航空航天大学计算机科学与技术学院 -- 热点新闻', suffix: '10846/list.htm' }],
10
+ ['xkky', { title: '南京航空航天大学计算机科学与技术学院 -- 学科科研', suffix: '10849/list.htm' }],
11
+ ['be', { title: '南京航空航天大学计算机科学与技术学院 -- 本科生培养', suffix: '10850/list.htm' }],
12
+ ['me', { title: '南京航空航天大学计算机科学与技术学院 -- 研究生培养', suffix: '10851/list.htm' }],
13
+ ['jxdt', { title: '南京航空航天大学计算机科学与技术学院 -- 教学动态', suffix: '1977/list.htm' }],
14
+ ['xsgz', { title: '南京航空航天大学计算机科学与技术学院 -- 学生工作', suffix: '1959/list.htm' }],
15
+ ]);
16
+
17
+ module.exports = async (ctx) => {
18
+ const type = ctx.params.type;
19
+ const getDescription = Boolean(ctx.params.getDescription) || false;
20
+ const suffix = map.get(type).suffix;
21
+
22
+ const link = new URL(suffix, host).href;
23
+ const cookie = await getCookie();
24
+ const gotConfig = {
25
+ headers: {
26
+ cookie,
27
+ },
28
+ };
29
+ const response = await got(link, gotConfig);
30
+ const $ = cheerio.load(response.data);
31
+
32
+ const list = $('#news_list ul li')
33
+ .slice(0, Math.min(parseInt($('.per_count', '#wp_paging_w6').text()), parseInt($('.all_count', '#wp_paging_w6').slice(1).text())))
34
+ .map(function () {
35
+ const info = {
36
+ title: $(this).find('a').attr('title'),
37
+ link: $(this).find('a').attr('href'),
38
+ date: $(this).find('span').text(),
39
+ };
40
+ return info;
41
+ })
42
+ .get();
43
+
44
+ const out = await Promise.all(
45
+ list.map((info) => {
46
+ const title = info.title || 'tzgg';
47
+ const date = info.date;
48
+ const itemUrl = new URL(info.link, host).href;
49
+
50
+ return ctx.cache.tryGet(itemUrl, async () => {
51
+ const arr = itemUrl.split('.');
52
+ const pageType = arr[arr.length - 1];
53
+
54
+ // 南航新 WAF 过于敏感
55
+ // 目前 description 需要遍历页面,会被 WAF 拦截导致无法输出
56
+ // 考虑换一种获取 description 的方式或者将标题当作 title。
57
+ let description = title;
58
+ if (getDescription) {
59
+ description = itemUrl;
60
+ if (pageType === 'htm' || pageType === 'html') {
61
+ const response = await got.get(itemUrl, gotConfig);
62
+ const $ = cheerio.load(response.data);
63
+ description = $('.wp_articlecontent')
64
+ .html()
65
+ .replace(/src="\//g, `src="${new URL('.', host).href}`)
66
+ .trim();
67
+ }
68
+ }
69
+
70
+ const single = {
71
+ title,
72
+ link: itemUrl,
73
+ description,
74
+ pubDate: parseDate(date),
75
+ };
76
+ return single;
77
+ });
78
+ })
79
+ );
80
+
81
+ ctx.state.data = {
82
+ title: map.get(type).title,
83
+ link,
84
+ description: '南京航空航天大学计算机科学与技术学院RSS',
85
+ item: out,
86
+ };
87
+ };
@@ -0,0 +1,82 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+ const getCookie = require('../utils/pypasswaf');
5
+ const host = 'http://aao.nuaa.edu.cn/';
6
+
7
+ const map = new Map([
8
+ ['tzgg', { title: '南京航空航天大学教务处 -- 通知公告', suffix: '8222/list.htm' }],
9
+ ['jxfw', { title: '南京航空航天大学教务处 -- 教学服务', suffix: '8230/list.htm' }],
10
+ ['xspy', { title: '南京航空航天大学教务处 -- 学生培养', suffix: '8231/list.htm' }],
11
+ ['jxjs', { title: '南京航空航天大学教务处 -- 教学建设', suffix: '8232/list.htm' }],
12
+ ['jxzy', { title: '南京航空航天大学教务处 -- 教学资源', suffix: '8233/list.htm' }],
13
+ ]);
14
+
15
+ module.exports = async (ctx) => {
16
+ const type = ctx.params.type;
17
+ const suffix = map.get(type).suffix;
18
+ const getDescription = Boolean(ctx.params.getDescription) || false;
19
+
20
+ const link = new URL(suffix, host).href;
21
+ const cookie = await getCookie();
22
+ const gotConfig = {
23
+ headers: {
24
+ cookie,
25
+ },
26
+ };
27
+ const response = await got(link, gotConfig);
28
+ const $ = cheerio.load(response.data);
29
+
30
+ const list = $('#wp_news_w8 ul li')
31
+ .slice(0, 10)
32
+ .map(function () {
33
+ const info = {
34
+ title: $(this).find('a').text(),
35
+ link: $(this).find('a').attr('href'),
36
+ date: $(this).find('span').text(),
37
+ };
38
+ return info;
39
+ })
40
+ .get();
41
+
42
+ const out = await Promise.all(
43
+ list.map((info) => {
44
+ const title = info.title || 'tzgg';
45
+ const date = info.date;
46
+ const itemUrl = new URL(info.link, host).href;
47
+
48
+ return ctx.cache.tryGet(itemUrl, async () => {
49
+ const arr = itemUrl.split('.');
50
+ const pageType = arr[arr.length - 1];
51
+
52
+ // 南航新 WAF 过于敏感
53
+ // 目前 description 需要遍历页面,会被 WAF 拦截导致无法输出
54
+ // 考虑换一种获取 description 的方式或者将标题当作 title。
55
+ let description = title;
56
+ if (getDescription) {
57
+ description = itemUrl;
58
+ if (pageType === 'htm' || pageType === 'html') {
59
+ const response = await got(itemUrl, gotConfig);
60
+ const $ = cheerio.load(response.data);
61
+ description = $('.wp_articlecontent').html();
62
+ }
63
+ }
64
+
65
+ const single = {
66
+ title,
67
+ link: itemUrl,
68
+ description,
69
+ pubDate: parseDate(date),
70
+ };
71
+ return single;
72
+ });
73
+ })
74
+ );
75
+
76
+ ctx.state.data = {
77
+ title: map.get(type).title,
78
+ link,
79
+ description: '南京航空航天大学教务处RSS',
80
+ item: out,
81
+ };
82
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ '/cs/:type/:getDescription?': ['LogicJake', 'Seiry', 'qrzbing'],
3
+ '/jwc/:type/:getDescription?': ['arcosx', 'Seiry', 'qrzbing'],
4
+ '/yjsy/:type?': ['junfengP', 'Seiry'],
5
+ };
@@ -0,0 +1,23 @@
1
+ module.exports = {
2
+ 'nuaa.edu.cn': {
3
+ _name: '南京航空航天大学',
4
+ aao: [
5
+ {
6
+ title: '教务处',
7
+ docs: 'https://docs.rsshub.app/university.html#nan-jing-hang-kong-hang-tian-da-xue',
8
+ },
9
+ ],
10
+ cs: [
11
+ {
12
+ title: '计算机科学与技术学院',
13
+ docs: 'https://docs.rsshub.app/university.html#nan-jing-hang-kong-hang-tian-da-xue',
14
+ },
15
+ ],
16
+ 'www.graduate': [
17
+ {
18
+ title: '研究生院',
19
+ docs: 'https://docs.rsshub.app/university.html#nan-jing-hang-kong-hang-tian-da-xue',
20
+ },
21
+ ],
22
+ },
23
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = (router) => {
2
+ router.get('/cs/:type/:getDescription?', require('./cs/index'));
3
+ router.get('/jwc/:type/:getDescription?', require('./jwc/jwc'));
4
+ router.get('/yjsy/:type?', require('./yjsy/yjsy'));
5
+ };