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
@@ -1,5 +1,7 @@
1
1
  const got = require('@/utils/got');
2
+ const { art } = require('@/utils/render');
2
3
  const cheerio = require('cheerio');
4
+ const path = require('path');
3
5
 
4
6
  module.exports = async (ctx) => {
5
7
  const since = ctx.params.since;
@@ -20,24 +22,38 @@ module.exports = async (ctx) => {
20
22
  const $ = cheerio.load(data);
21
23
  const list = $('article');
22
24
 
25
+ const items = await Promise.all(
26
+ list.map((_, item) => {
27
+ item = $(item);
28
+ const endpoint = item.find('h1 a').attr('href');
29
+ const link = `https://github.com${endpoint}`;
30
+ return ctx.cache.tryGet(`github:trending:${endpoint}`, async () => {
31
+ const response = await got(link);
32
+
33
+ const $ = cheerio.load(response.data);
34
+ const cover = $('meta[property="og:image"]');
35
+
36
+ const single = {
37
+ title: item.find('h1').text(),
38
+ author: item.find('h1').text().split('/')[0].trim(),
39
+ description: art(path.join(__dirname, 'templates/trending-description.art'), {
40
+ cover: cover.attr('content'),
41
+ desc: item.find('p').text(),
42
+ lang: item.find('span[itemprop="programmingLanguage"]').text() || 'Unknown',
43
+ stars: item.find('.Link--muted').eq(0).text().trim(),
44
+ forks: item.find('.Link--muted').eq(1).text().trim(),
45
+ }),
46
+ link,
47
+ };
48
+
49
+ return single;
50
+ });
51
+ })
52
+ );
53
+
23
54
  ctx.state.data = {
24
55
  title: $('title').text(),
25
56
  link: url,
26
- item:
27
- list &&
28
- list
29
- .map((_, item) => {
30
- item = $(item);
31
- return {
32
- title: item.find('h1').text(),
33
- author: item.find('h1').text().split('/')[0].trim(),
34
- description: `${item.find('.pr-4').text()}<br>
35
- <br>Language: ${item.find('span[itemprop="programmingLanguage"]').text() ?? 'unknown'}
36
- <br>Star: ${item.find('.Link--muted').eq(0).text().trim()}
37
- <br>Fork: ${item.find('.Link--muted').eq(1).text().trim()}`,
38
- link: `https://github.com${item.find('h1 a').attr('href')}`,
39
- };
40
- })
41
- .get(),
57
+ item: items,
42
58
  };
43
59
  };
@@ -11,6 +11,8 @@ module.exports = {
11
11
  '/miit/wjgs': ['Yoge-Code'],
12
12
  '/miit/zcjd': ['Yoge-Code'],
13
13
  '/moe/:type': ['Crawler995'],
14
+ '/moj/aac/news/:type?': ['TonyRL'],
15
+ '/nifdc/:path+': ['nczitzk'],
14
16
  '/nmpa/:path+': ['TonyRL'],
15
17
  '/nrta/news/:category?': ['yuxinliu-alex'],
16
18
  '/nsfc/news/:type?': ['Derekmini', 'nczitzk'],
@@ -0,0 +1,49 @@
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
+ const baseUrl = 'https://www.aac.moj.gov.tw';
6
+
7
+ module.exports = async (ctx) => {
8
+ const { type } = ctx.params;
9
+ const url = `${baseUrl}/7204/7246/?Page=1&PageSize=40${type ? `&type=${type}` : ''}`;
10
+ const response = await got(url);
11
+ const $ = cheerio.load(response.data);
12
+ $('.num').remove();
13
+ const list = $('.list ul li a')
14
+ .toArray()
15
+ .map((item) => {
16
+ item = $(item);
17
+ const isDownload = /檔案下載/.test(item.attr('title'));
18
+ const title = isDownload ? item.text().trim() : item.attr('title');
19
+ return {
20
+ title,
21
+ link: new URL(item.attr('href'), baseUrl).href,
22
+ isDownload,
23
+ };
24
+ });
25
+
26
+ const items = await Promise.all(
27
+ list.map((item) =>
28
+ ctx.cache.tryGet(item.link, async () => {
29
+ if (!item.isDownload) {
30
+ const response = await got(item.link);
31
+ const $ = cheerio.load(response.data);
32
+
33
+ item.pubDate = timezone(parseDate($('.info time').attr('datetime'), 'YYYY-MM-DD HH:mm:ss'), +8);
34
+ $('.info, button').remove();
35
+ item.description = $('.cp').html() + ($('.lightbox_slider').length ? $('.lightbox_slider').html() : '') + ($('.file_download').length ? $('.file_download').html() : '');
36
+ }
37
+ delete item.isDownload;
38
+ return item;
39
+ })
40
+ )
41
+ );
42
+
43
+ ctx.state.data = {
44
+ title: $('head title').text(),
45
+ link: url,
46
+ item: items,
47
+ language: 'zh-TW',
48
+ };
49
+ };
@@ -0,0 +1,86 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const timezone = require('@/utils/timezone');
4
+ const { parseDate } = require('@/utils/parse-date');
5
+
6
+ module.exports = async (ctx) => {
7
+ const params = ctx.path === '/nifdc' ? '/nifdc/bshff/ylqxbzhgl/qxggtzh' : ctx.path;
8
+
9
+ const rootUrl = 'https://www.nifdc.org.cn';
10
+ const currentUrl = `${rootUrl}${params}/index.html`;
11
+
12
+ const response = await got({
13
+ method: 'get',
14
+ url: currentUrl,
15
+ });
16
+
17
+ const $ = cheerio.load(response.data);
18
+
19
+ let items = $('.list ul li a')
20
+ .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 20)
21
+ .toArray()
22
+ .map((item) => {
23
+ item = $(item);
24
+
25
+ const link = item.attr('href');
26
+
27
+ return {
28
+ title: item.text(),
29
+ link: /^http/.test(link) ? link : new URL(link, currentUrl).href,
30
+ pubDate: parseDate(
31
+ item
32
+ .next()
33
+ .text()
34
+ .match(/\((.*)\)/)
35
+ ),
36
+ };
37
+ });
38
+
39
+ const browser = await require('@/utils/puppeteer')();
40
+
41
+ items = await Promise.all(
42
+ items.map((item) =>
43
+ ctx.cache.tryGet(item.link, async () => {
44
+ if (/^https:\/\/www\.nmpa\.gov\.cn\//.test(item.link)) {
45
+ const page = await browser.newPage();
46
+ await page.setRequestInterception(true);
47
+
48
+ page.on('request', (request) => {
49
+ request.resourceType() === 'document' || request.resourceType() === 'script' ? request.continue() : request.abort();
50
+ });
51
+
52
+ await page.goto(item.link, {
53
+ waitUntil: 'domcontentloaded',
54
+ });
55
+ await page.waitForSelector('.text');
56
+ const html = await page.evaluate(() => document.documentElement.innerHTML);
57
+ await page.close();
58
+
59
+ const content = cheerio.load(html);
60
+
61
+ item.description = content('.text').html();
62
+ } else {
63
+ const detailResponse = await got({
64
+ method: 'get',
65
+ url: item.link,
66
+ });
67
+
68
+ const content = cheerio.load(detailResponse.data);
69
+
70
+ item.description = content('.text').html();
71
+ item.pubDate = timezone(parseDate(content('meta[name="PubDate"]').attr('content')), +8);
72
+ }
73
+
74
+ return item;
75
+ })
76
+ )
77
+ );
78
+
79
+ await browser.close();
80
+
81
+ ctx.state.data = {
82
+ title: $('title').text().replace(/----/, ' - '),
83
+ link: currentUrl,
84
+ item: items,
85
+ };
86
+ };
@@ -450,6 +450,28 @@ module.exports = {
450
450
  },
451
451
  ],
452
452
  },
453
+ 'moj.gov.tw': {
454
+ _name: '台灣法務部廉政署',
455
+ 'www.aac': [
456
+ {
457
+ title: '最新消息',
458
+ docs: 'https://docs.rsshub.app/government.html#zhong-hua-ren-min-gong-he-guo-jiao-yu-bu',
459
+ source: ['/7204/7246/'],
460
+ target: (_params, url) => `/gov/moj/aac/news${new URL(url).searchParams.has('type') ? '/' + new URL(url).searchParams.get('type') : ''}`,
461
+ },
462
+ ],
463
+ },
464
+ 'nifdc.gov.cn': {
465
+ _name: '国家药品监督管理局医疗器械标准管理中心',
466
+ '.': [
467
+ {
468
+ title: '通用',
469
+ docs: 'https://docs.rsshub.app/government.html#guo-jia-yao-pin-jian-du-guan-li-ju-yi-liao-qi-xie-biao-zhun-guan-li-zhong-xin',
470
+ source: ['/*path'],
471
+ target: (params) => `/gov/nifdc/${params.path.replace('/index.html', '')}`,
472
+ },
473
+ ],
474
+ },
453
475
  'nmpa.gov.cn': {
454
476
  _name: '国家药品监督管理局',
455
477
  '.': [
@@ -11,6 +11,8 @@ module.exports = function (router) {
11
11
  router.get('/miit/wjgs', require('./miit/wjgs'));
12
12
  router.get('/miit/zcjd', require('./miit/zcjd'));
13
13
  router.get('/moe/:type', require('./moe/moe'));
14
+ router.get('/moj/aac/news/:type?', require('./moj/aac/news'));
15
+ router.get(/nifdc\/([\w/-]+)?/, require('./nifdc'));
14
16
  router.get(/\/nmpa\/([\w][\w/]+)?/, require('./nmpa/generic'));
15
17
  router.get('/nrta/news/:category?', require('./nrta/news'));
16
18
  router.get('/nsfc/news/:type?', require('./nsfc'));
@@ -21,25 +21,31 @@ module.exports = async (ctx) => {
21
21
  .map((item) => {
22
22
  item = $(item);
23
23
 
24
+ const link = item.attr('href');
25
+
24
26
  return {
25
27
  title: item.text(),
26
- link: `${rootUrl}${item.attr('href')}`,
27
28
  pubDate: parseDate(item.next().text()),
29
+ link: /^http/.test(link) ? link : `${rootUrl}${link}`,
28
30
  };
29
31
  });
30
32
 
31
33
  items = await Promise.all(
32
34
  items.map((item) =>
33
35
  ctx.cache.tryGet(item.link, async () => {
34
- const detailResponse = await got({
35
- method: 'get',
36
- url: item.link,
37
- });
38
-
39
- const content = cheerio.load(detailResponse.data);
40
-
41
- item.description = content('#ivs_content').html();
42
- item.pubDate = timezone(parseDate(content('meta[name="pubdate"]').attr('content')), +8);
36
+ try {
37
+ const detailResponse = await got({
38
+ method: 'get',
39
+ url: item.link,
40
+ });
41
+
42
+ const content = cheerio.load(detailResponse.data);
43
+
44
+ item.description = content('#ivs_content').html();
45
+ item.pubDate = timezone(parseDate(content('meta[name="pubdate"]').attr('content')), +8);
46
+ } catch (e) {
47
+ // no-empty
48
+ }
43
49
 
44
50
  return item;
45
51
  })
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/news/:type?': ['TonyRL'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'hakkatv.org.tw': {
3
+ _name: '客家電視台',
4
+ '.': [
5
+ {
6
+ title: '新聞首頁 - 客家電視台',
7
+ docs: 'https://docs.rsshub.app/traditional-media.html#ke-jia-dian-shi-tai',
8
+ source: '/news',
9
+ target: '/hakkatv/news',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = (router) => {
2
+ router.get('/news/:type?', require('./type'));
3
+ };
@@ -0,0 +1,67 @@
1
+ const got = require('@/utils/got');
2
+ const { parseDate } = require('@/utils/parse-date');
3
+ const timezone = require('@/utils/timezone');
4
+
5
+ const typeMap = ['hakka', 'political', 'medical', 'local', 'international'];
6
+ const baseUrl = 'https://www.hakkatv.org.tw';
7
+ const apiUrl = 'https://api.hakkatv.org.tw';
8
+
9
+ module.exports = async (ctx) => {
10
+ const { type } = ctx.params;
11
+
12
+ let allData;
13
+ if (!type) {
14
+ allData = await Promise.all(
15
+ typeMap.map(async (t) => {
16
+ const { data } = await got(`${apiUrl}/api/news/index`, {
17
+ searchParams: {
18
+ per: 4,
19
+ 'sort[created_at]': 'desc',
20
+ type: t,
21
+ keywords: '',
22
+ },
23
+ });
24
+ return data.data;
25
+ })
26
+ );
27
+ } else {
28
+ allData = (
29
+ await got(`${apiUrl}/api/news/index`, {
30
+ searchParams: {
31
+ per: 4,
32
+ 'sort[created_at]': 'desc',
33
+ type,
34
+ keywords: '',
35
+ },
36
+ })
37
+ ).data.data;
38
+ }
39
+
40
+ const list = [].concat(...allData).map((item) => ({
41
+ title: item.title,
42
+ pubDate: timezone(parseDate(item.created_at), +8),
43
+ author: item.author,
44
+ link: `${baseUrl}/news-detail/${item.id}`,
45
+ id: item.id,
46
+ }));
47
+
48
+ const items = await Promise.all(
49
+ list.map((item) =>
50
+ ctx.cache.tryGet(item.link, async () => {
51
+ const { data } = await got(`${apiUrl}/api/news/read/${item.id}`);
52
+ item.category = data.tag.map((t) => t.tag);
53
+ item.description = data.content.replace(/\n/g, '<br>');
54
+ delete item.id;
55
+ return item;
56
+ })
57
+ )
58
+ );
59
+
60
+ ctx.state.data = {
61
+ title: '新聞首頁 - 客家電視台',
62
+ description: '客家電視是屬於全民、以至於全世界客家族群的頻道,亦是為傳播客家文化而存在,定位為「全體客家族群之媒體」。',
63
+ link: `${baseUrl}/news`,
64
+ language: 'zh-TW',
65
+ item: items,
66
+ };
67
+ };
@@ -1,40 +1,23 @@
1
1
  const got = require('@/utils/got');
2
- const cheerio = require('cheerio');
3
- const { parseDate } = require('@/utils/parse-date');
2
+ const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
4
3
 
5
4
  module.exports = async (ctx) => {
6
- const id = ctx.params.id;
5
+ const id = ctx.params.id ?? '1';
7
6
 
8
- const response = await got(`https://web-data.api.hk01.com/v2/page/category/${id}`);
9
- const data = response.data;
10
- const list = data.sections[0].items;
7
+ const currentUrl = `${rootUrl}/channel/${id}`;
8
+ const apiUrl = `${apiRootUrl}/v2/feed/category/${id}`;
11
9
 
12
- await Promise.all(
13
- list.map((item) =>
14
- ctx.cache.tryGet(`https://www.hk01.com/${item.data.mainCategory}/${item.data.articleId}`, async () => {
15
- const detailResponse = await got(item.data.canonicalUrl);
16
- const $ = cheerio.load(detailResponse.data);
10
+ const response = await got({
11
+ method: 'get',
12
+ url: apiUrl,
13
+ });
17
14
 
18
- $('article > div.view-tracker').remove();
19
- $('article > div.flex.flex-col').remove();
20
-
21
- item.data.description = $('article').html();
22
-
23
- return item;
24
- })
25
- )
26
- );
15
+ const items = await ProcessItems(response.data.items, ctx.query.limit, ctx.cache.tryGet);
27
16
 
28
17
  ctx.state.data = {
29
- title: `香港01 - ${data.category.publishName}`,
30
- description: data.meta.metaDesc,
31
- link: data.category.publishUrl,
32
- item: list.map((item) => ({
33
- title: item.data.title,
34
- author: item.data.authors && item.data.authors.map((e) => e.publishName).join(', '),
35
- description: `<p>${item.data.description}</p><img style="width: 100%" src="${item.data.mainImage.cdnUrl}" />`,
36
- pubDate: parseDate(item.data.lastModifyTime * 1000),
37
- link: item.data.canonicalUrl,
38
- })),
18
+ title: `${response.data.category.publishName} | 香港01`,
19
+ link: currentUrl,
20
+ item: items,
21
+ image: response.data.category.icon,
39
22
  };
40
23
  };
@@ -1,21 +1,20 @@
1
1
  const got = require('@/utils/got');
2
- const { parseDate } = require('@/utils/parse-date');
2
+ const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
3
3
 
4
4
  module.exports = async (ctx) => {
5
- const response = await got('https://web-data.api.hk01.com/v2/page/hot/');
6
- const data = response.data;
7
- const list = data.items;
5
+ const currentUrl = `${rootUrl}/hot`;
6
+ const apiUrl = `${apiRootUrl}/v2/feed/hot`;
7
+
8
+ const response = await got({
9
+ method: 'get',
10
+ url: apiUrl,
11
+ });
12
+
13
+ const items = await ProcessItems(response.data.items, ctx.query.limit, ctx.cache.tryGet);
8
14
 
9
15
  ctx.state.data = {
10
- title: '香港01 - 熱門',
11
- description: data.meta.metaDesc,
12
- link: data.meta.canonicalUrl,
13
- item: list.map((item) => ({
14
- title: item.data.title,
15
- author: item.data.authors && item.data.authors.map((e) => e.publishName).join(', '),
16
- description: `<p>${item.data.description}</p><img style="width: 100%" src="${item.data.mainImage.cdnUrl}" />`,
17
- pubDate: parseDate(item.data.lastModifyTime * 1000),
18
- link: item.data.canonicalUrl,
19
- })),
16
+ title: '熱門新聞、全城熱話及社會時事 | 香港01',
17
+ link: currentUrl,
18
+ item: items,
20
19
  };
21
20
  };
@@ -1,41 +1,22 @@
1
1
  const got = require('@/utils/got');
2
- const cheerio = require('cheerio');
3
- const { parseDate } = require('@/utils/parse-date');
2
+ const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
4
3
 
5
4
  module.exports = async (ctx) => {
6
- const id = ctx.params.id;
5
+ const id = ctx.params.id ?? '649';
7
6
 
8
- const response = await got(`https://web-data.api.hk01.com/v2/page/issue/${id}`);
9
- const data = response.data;
10
- const list = data.issue.blocks[0].articles;
7
+ const currentUrl = `${rootUrl}/issue/${id}`;
8
+ const apiUrl = `${apiRootUrl}/v2/issues/${id}`;
11
9
 
12
- await Promise.all(
13
- list.map((item) =>
14
- ctx.cache.tryGet(`https://www.hk01.com/${item.data.mainCategory}/${item.data.articleId}`, async () => {
15
- const detailResponse = await got(item.data.canonicalUrl);
16
- const $ = cheerio.load(detailResponse.data);
10
+ const response = await got({
11
+ method: 'get',
12
+ url: apiUrl,
13
+ });
17
14
 
18
- $('div.lazyload-placeholder').remove();
19
- $('article > div.view-tracker').remove();
20
- $('article > div.flex.flex-col').remove();
21
-
22
- item.data.description = $('article').html();
23
-
24
- return item;
25
- })
26
- )
27
- );
15
+ const items = await ProcessItems(response.data.blocks[0].articles, ctx.query.limit, ctx.cache.tryGet);
28
16
 
29
17
  ctx.state.data = {
30
- title: `香港01 - ${data.issue.title}`,
31
- description: data.meta.metaDesc,
32
- link: data.issue.publishUrl,
33
- item: list.map((item) => ({
34
- title: item.data.title,
35
- author: item.data.authors && item.data.authors.map((e) => e.publishName).join(', '),
36
- description: `<img style="width: 100%" src="${item.data.mainImage.cdnUrl}" /><p>${item.data.description}</p>`,
37
- pubDate: parseDate(item.data.lastModifyTime * 1000),
38
- link: item.data.canonicalUrl,
39
- })),
18
+ title: `${response.data.title} | 香港01`,
19
+ link: currentUrl,
20
+ item: items,
40
21
  };
41
22
  };
@@ -1,7 +1,7 @@
1
1
  module.exports = {
2
- '/channel/:id': ['hoilc', 'Fatpandac'],
3
- '/hot': ['hoilc', 'Fatpandac'],
4
- '/issue/:id': ['hoilc', 'Fatpandac'],
5
- '/tag/:id': ['hoilc', 'Fatpandac'],
6
- '/zone/:id': ['hoilc', 'Fatpandac'],
2
+ '/channel/:id': ['hoilc', 'Fatpandac', 'nczitzk'],
3
+ '/hot': ['hoilc', 'Fatpandac', 'nczitzk'],
4
+ '/issue/:id': ['hoilc', 'Fatpandac', 'nczitzk'],
5
+ '/tag/:id': ['hoilc', 'Fatpandac', 'nczitzk'],
6
+ '/zone/:id': ['hoilc', 'Fatpandac', 'nczitzk'],
7
7
  };
@@ -1,36 +1,36 @@
1
1
  module.exports = {
2
2
  'hk01.com': {
3
3
  _name: '香港01',
4
- www: [
4
+ '.': [
5
5
  {
6
- title: '最 Hit',
7
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
6
+ title: '热门',
7
+ docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-re-men',
8
8
  source: ['/hot', '/'],
9
9
  target: '/hk01/hot',
10
10
  },
11
11
  {
12
- title: 'zone',
13
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
14
- source: '/zone/:id/:title',
15
- target: '/hk01/zone/:id',
12
+ title: '栏目',
13
+ docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-lan-mu',
14
+ source: ['/zone/:id', '/'],
15
+ target: '/hk01/zone/:id?',
16
16
  },
17
17
  {
18
- title: 'channel',
19
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
20
- source: '/channel/:id/:title',
21
- target: '/hk01/channel/:id',
18
+ title: '子栏目',
19
+ docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-zi-lan-mu',
20
+ source: ['/channel/:id', '/'],
21
+ target: '/hk01/channel/:id?',
22
22
  },
23
23
  {
24
- title: 'issue',
25
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
26
- source: '/issue/:id/:title',
27
- target: '/hk01/issue/:id',
24
+ title: '专题',
25
+ docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-zhuan-ti',
26
+ source: ['/issue/:id', '/'],
27
+ target: '/hk01/issue/:id?',
28
28
  },
29
29
  {
30
- title: 'tag',
31
- docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01',
32
- source: '/tag/:id/:title',
33
- target: '/hk01/tag/:id',
30
+ title: '标签',
31
+ docs: 'https://docs.rsshub.app/traditional-media.html#xiang-gang-01-biao-qian',
32
+ source: ['/tag/:id', '/'],
33
+ target: '/hk01/tag/:id?',
34
34
  },
35
35
  ],
36
36
  },
@@ -1,7 +1,7 @@
1
1
  module.exports = function (router) {
2
- router.get('/channel/:id', require('./channel'));
2
+ router.get('/channel/:id?', require('./channel'));
3
3
  router.get('/hot', require('./hot'));
4
- router.get('/issue/:id', require('./issue'));
5
- router.get('/tag/:id', require('./tag'));
6
- router.get('/zone/:id', require('./zone'));
4
+ router.get('/issue/:id?', require('./issue'));
5
+ router.get('/tag/:id?', require('./tag'));
6
+ router.get('/zone/:id?', require('./zone'));
7
7
  };
@@ -1,23 +1,22 @@
1
1
  const got = require('@/utils/got');
2
- const { parseDate } = require('@/utils/parse-date');
2
+ const { rootUrl, apiRootUrl, ProcessItems } = require('./utils');
3
3
 
4
4
  module.exports = async (ctx) => {
5
- const id = ctx.params.id;
5
+ const id = ctx.params.id ?? '1';
6
6
 
7
- const response = await got(`https://web-data.api.hk01.com/v2/page/tag/${id}`);
8
- const data = response.data;
9
- const list = data.articles;
7
+ const currentUrl = `${rootUrl}/tag/${id}`;
8
+ const apiUrl = `${apiRootUrl}/v2/feed/tag/${id}`;
9
+
10
+ const response = await got({
11
+ method: 'get',
12
+ url: apiUrl,
13
+ });
14
+
15
+ const items = await ProcessItems(response.data.items, ctx.query.limit, ctx.cache.tryGet);
10
16
 
11
17
  ctx.state.data = {
12
- title: `香港01 - ${data.tag.tagName}`,
13
- description: data.meta.metaDesc,
14
- link: data.tag.publishUrl,
15
- item: list.map((item) => ({
16
- title: item.data.title,
17
- author: item.data.authors && item.data.authors.map((e) => e.publishName).join(', '),
18
- description: `<p>${item.data.description}</p><img style="width: 100%" src="${item.data.mainImage.cdnUrl}" />`,
19
- pubDate: parseDate(item.data.lastModifyTime * 1000),
20
- link: item.data.canonicalUrl,
21
- })),
18
+ title: `${id} | 香港01`,
19
+ link: currentUrl,
20
+ item: items,
22
21
  };
23
22
  };