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,44 @@
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
+ module.exports = async (ctx) => {
8
+ const rootUrl = 'https://news.pts.org.tw';
9
+ const currentUrl = `${rootUrl}/projects`;
10
+
11
+ const response = await got({
12
+ method: 'get',
13
+ url: currentUrl,
14
+ });
15
+
16
+ const $ = cheerio.load(response.data);
17
+
18
+ const items = $('h3 a')
19
+ .toArray()
20
+ .map((item) => {
21
+ item = $(item);
22
+
23
+ const projectDiv = item.parent().parent();
24
+ const description = projectDiv.find('p').text();
25
+
26
+ return {
27
+ title: item.text(),
28
+ link: item.attr('href'),
29
+ pubDate: parseDate(projectDiv.find('time').text()),
30
+ description: art(path.join(__dirname, 'templates/description.art'), {
31
+ image: projectDiv.parent().find('.cover-fit')?.attr('src') ?? projectDiv.parent().parent().find('.cover-fit').attr('src'),
32
+ description: description ? `<p>${description}</p>` : '',
33
+ }),
34
+ };
35
+ });
36
+
37
+ ctx.state.data = {
38
+ title: $('title')
39
+ .text()
40
+ .replace(/第\d+頁 | /, ''),
41
+ link: currentUrl,
42
+ item: items,
43
+ };
44
+ };
@@ -3,11 +3,47 @@ module.exports = {
3
3
  _name: '公視新聞網 PNN',
4
4
  news: [
5
5
  {
6
- title: '即時',
6
+ title: '即時新聞',
7
7
  docs: 'https://docs.rsshub.app/traditional-media.html#gong-shi-xin-wen-wang-ji-shi-xin-wen',
8
- source: ['/dailynews'],
8
+ source: ['/dailynews', '/'],
9
9
  target: '/pts/dailynews',
10
10
  },
11
+ {
12
+ title: '專題策展',
13
+ docs: 'https://docs.rsshub.app/traditional-media.html#gong-shi-xin-wen-wang-zhuan-ti-ce-zhan',
14
+ source: ['/curations', '/'],
15
+ target: '/pts/curations',
16
+ },
17
+ {
18
+ title: '觀點',
19
+ docs: 'https://docs.rsshub.app/traditional-media.html#gong-shi-xin-wen-wang-guan-dian',
20
+ source: ['/opinion', '/'],
21
+ target: '/pts/opinion',
22
+ },
23
+ {
24
+ title: '數位敘事',
25
+ docs: 'https://docs.rsshub.app/traditional-media.html#gong-shi-xin-wen-wang-shu-wei-xu-shi',
26
+ source: ['/projects', '/'],
27
+ target: '/pts/projects',
28
+ },
29
+ {
30
+ title: '深度報導',
31
+ docs: 'https://docs.rsshub.app/traditional-media.html#gong-shi-xin-wen-wang-shen-du-bao-dao',
32
+ source: ['/report', '/'],
33
+ target: '/pts/report',
34
+ },
35
+ {
36
+ title: '分類',
37
+ docs: 'https://docs.rsshub.app/traditional-media.html#gong-shi-xin-wen-wang-fen-lei',
38
+ source: ['/category/:id', '/'],
39
+ target: '/pts/category/:id',
40
+ },
41
+ {
42
+ title: '標籤',
43
+ docs: 'https://docs.rsshub.app/traditional-media.html#gong-shi-xin-wen-wang-biao-qian',
44
+ source: ['/tag/:id', '/'],
45
+ target: '/pts/tag/:id',
46
+ },
11
47
  ],
12
48
  },
13
49
  };
@@ -1,3 +1,6 @@
1
1
  module.exports = function (router) {
2
- router.get('/dailynews', require('./dailynews'));
2
+ router.get('/curations', require('./curations'));
3
+ router.get('/projects', require('./projects'));
4
+ router.get(/([\w-/]+)?/, require('./index'));
5
+ router.get('', require('./index'));
3
6
  };
@@ -0,0 +1,6 @@
1
+ {{ if image }}
2
+ <img src="{{ image }}">
3
+ {{ /if }}
4
+ {{ if description }}
5
+ {{@ description }}
6
+ {{ /if }}
@@ -24,7 +24,7 @@ module.exports = async (ctx) => {
24
24
  return {
25
25
  title: item.text(),
26
26
  author: item.find('.name').text(),
27
- link: `${rootUrl}${item.attr('href')}`,
27
+ link: `${rootUrl}${item.attr('href').split('?')[0]}`,
28
28
  };
29
29
  });
30
30
 
@@ -1,3 +1,4 @@
1
1
  module.exports = {
2
2
  '/blog/:id?': ['victor21813', 'nczitzk'],
3
+ '/news': ['nczitzk'],
3
4
  };
@@ -0,0 +1,51 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+
5
+ module.exports = async (ctx) => {
6
+ const rootUrl = 'https://sakurazaka46.com';
7
+ const currentUrl = `${rootUrl}/s/s46/news/list`;
8
+
9
+ const response = await got({
10
+ method: 'get',
11
+ url: currentUrl,
12
+ });
13
+
14
+ const $ = cheerio.load(response.data);
15
+
16
+ let items = $('.com-news-part .box a')
17
+ .slice(0, ctx.query.limit ? parseInt(ctx.query.limit) : 30)
18
+ .toArray()
19
+ .map((item) => {
20
+ item = $(item);
21
+
22
+ return {
23
+ title: item.find('.lead').text(),
24
+ link: `${rootUrl}${item.attr('href').split('?')[0]}`,
25
+ pubDate: parseDate(item.find('.date').text()),
26
+ };
27
+ });
28
+
29
+ items = await Promise.all(
30
+ items.map((item) =>
31
+ ctx.cache.tryGet(item.link, async () => {
32
+ const detailResponse = await got({
33
+ method: 'get',
34
+ url: item.link,
35
+ });
36
+
37
+ const content = cheerio.load(detailResponse.data);
38
+
39
+ item.description = content('.article').html();
40
+
41
+ return item;
42
+ })
43
+ )
44
+ );
45
+
46
+ ctx.state.data = {
47
+ title: $('title').text(),
48
+ link: currentUrl,
49
+ item: items,
50
+ };
51
+ };
@@ -8,6 +8,12 @@ module.exports = {
8
8
  source: ['/s/s46/diary/blog/list', '/'],
9
9
  target: (params, url) => `/sakurazaka46/blog/${new URL(url).searchParams.get('ct')}`,
10
10
  },
11
+ {
12
+ title: 'ニュース',
13
+ docs: 'https://docs.rsshub.app/new-media.html#ban-dao-xi-lie-guan-wang-zi-xun-ying-ban-46-xin-wen',
14
+ source: ['/s/s46/news/list', '/'],
15
+ target: '/sakurazaka46/news',
16
+ },
11
17
  ],
12
18
  },
13
19
  };
@@ -1,3 +1,4 @@
1
1
  module.exports = function (router) {
2
2
  router.get('/blog/:id?', require('./blog'));
3
+ router.get('/news', require('./news'));
3
4
  };
@@ -1,10 +1,6 @@
1
- const got = require('@/utils/got');
2
1
  const cheerio = require('cheerio');
3
- const path = require('path');
4
- const { art } = require('@/utils/render');
5
-
6
- const { CookieJar } = require('tough-cookie');
7
- const cookieJar = new CookieJar();
2
+ const { puppeteerGet, renderDesc } = require('./utils');
3
+ const config = require('@/config').value;
8
4
 
9
5
  module.exports = async (ctx) => {
10
6
  const pub = ctx.params.pub;
@@ -12,56 +8,47 @@ module.exports = async (ctx) => {
12
8
  const host = `https://${pub}.scitation.org`;
13
9
  const jrnlUrl = `${host}/toc/${jrn}/current?size=all`;
14
10
 
15
- const response = await got(jrnlUrl, {
16
- cookieJar,
17
- });
18
- const $ = cheerio.load(response.data);
19
- const jrnlName = $('.header-journal-title').text();
20
- const list = $('.card')
21
- .map((_, item) => {
22
- $(item).find('.access-text').remove();
23
- const title = $(item).find('.hlFld-Title').text();
24
- const authors = $(item).find('.entryAuthor.all').text();
25
- const img = $(item).find('img').attr('src');
26
- const link = $(item).find('.ref.nowrap').attr('href');
27
- const doi = link.replace('/doi/full/', '');
28
- return {
29
- title,
30
- link,
31
- doi,
32
- authors,
33
- img,
34
- };
35
- })
36
- .get();
11
+ // use Puppeteer due to the obstacle by cloudflare challenge
12
+ const browser = await require('@/utils/puppeteer')();
37
13
 
38
- const renderDesc = (item) =>
39
- art(path.join(__dirname, 'templates/description.art'), {
40
- item,
41
- });
42
- const items = await Promise.all(
43
- list.map((item) =>
44
- ctx.cache.tryGet(item.link, async () => {
45
- const response2 = await got.post(`${host}/action/PB2showAjaxAbstract`, {
46
- cookieJar,
47
- body: 'doi=' + item.doi,
48
- headers: {
49
- 'X-Requested-With': 'XMLHttpRequest',
50
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
51
- 'Accept-Encoding': 'gzip, deflate, br',
52
- },
14
+ const { jrnlName, list } = await ctx.cache.tryGet(
15
+ jrnlUrl,
16
+ async () => {
17
+ const response = await puppeteerGet(jrnlUrl, browser);
18
+ const $ = cheerio.load(response);
19
+ const jrnlName = $('.header-journal-title').text();
20
+ const list = $('.card')
21
+ .toArray()
22
+ .map((item) => {
23
+ $(item).find('.access-text').remove();
24
+ const title = $(item).find('.hlFld-Title').text();
25
+ const authors = $(item).find('.entryAuthor.all').text();
26
+ const img = $(item).find('img').attr('src');
27
+ const link = $(item).find('.ref.nowrap').attr('href');
28
+ const doi = link.replace('/doi/full/', '');
29
+ const description = renderDesc(title, authors, doi, img);
30
+ return {
31
+ title,
32
+ link,
33
+ doi,
34
+ description,
35
+ };
53
36
  });
54
- const $2 = cheerio.load(response2.data);
55
- item.abstract = $2('span').text();
56
- item.description = renderDesc(item);
57
- return item;
58
- })
59
- )
37
+ return {
38
+ jrnlName,
39
+ list,
40
+ };
41
+ },
42
+ config.cache.routeExpire,
43
+ false
60
44
  );
61
45
 
46
+ browser.close();
47
+
62
48
  ctx.state.data = {
63
49
  title: jrnlName,
64
50
  link: jrnlUrl,
65
- item: items,
51
+ item: list,
52
+ allowEmpty: true,
66
53
  };
67
54
  };
@@ -1,10 +1,6 @@
1
- const got = require('@/utils/got');
2
1
  const cheerio = require('cheerio');
3
- const path = require('path');
4
- const { art } = require('@/utils/render');
5
-
6
- const { CookieJar } = require('tough-cookie');
7
- const cookieJar = new CookieJar();
2
+ const { puppeteerGet, renderDesc } = require('./utils');
3
+ const config = require('@/config').value;
8
4
 
9
5
  module.exports = async (ctx) => {
10
6
  const pub = ctx.params.pub;
@@ -13,17 +9,18 @@ module.exports = async (ctx) => {
13
9
  const host = `https://${pub}.scitation.org`;
14
10
  const jrnlUrl = `${host}/toc/${jrn}/current?size=all`;
15
11
 
16
- const response = await got(jrnlUrl, {
17
- cookieJar,
18
- });
19
- const $ = cheerio.load(response.data);
12
+ // use Puppeteer due to the obstacle by cloudflare challenge
13
+ const browser = await require('@/utils/puppeteer')();
14
+
15
+ const response = await puppeteerGet(jrnlUrl, browser);
16
+ const $ = cheerio.load(response);
20
17
  const jrnlName = $('.header-journal-title').text();
21
18
  const issueUrl = $('.row.js_issue.highlighted').find('a').attr('href');
22
19
  const section = $('.subject-heading')
23
- .map((_, item) => ({
20
+ .toArray()
21
+ .map((item) => ({
24
22
  name: $(item).text(),
25
- }))
26
- .get();
23
+ }));
27
24
 
28
25
  let ifContainSection = false;
29
26
  for (let i = 0, l = section.length; i < l; i++) {
@@ -31,56 +28,41 @@ module.exports = async (ctx) => {
31
28
  ifContainSection = true;
32
29
  }
33
30
  }
31
+
34
32
  let list;
35
33
  if (ifContainSection === true) {
36
34
  const secUrl = `${issueUrl}?tocSection=${sec}`;
37
- const response2 = await got(secUrl, {
38
- cookieJar,
39
- });
40
- const $2 = cheerio.load(response2.data);
41
- list = $2('.card')
42
- .map((_, item) => {
43
- $2(item).find('.access-text').remove();
44
- const title = $2(item).find('.hlFld-Title').text();
45
- const authors = $2(item).find('.entryAuthor.all').text();
46
- const img = $2(item).find('img').attr('src');
47
- const link = $2(item).find('.ref.nowrap').attr('href');
48
- const doi = link.replace('/doi/full/', '');
49
- return {
50
- title,
51
- link,
52
- doi,
53
- authors,
54
- img,
55
- };
56
- })
57
- .get();
58
-
59
- const renderDesc = (item) =>
60
- art(path.join(__dirname, 'templates/description.art'), {
61
- item,
62
- });
63
- list = await Promise.all(
64
- list.map((item) =>
65
- ctx.cache.tryGet(item.link, async () => {
66
- const response3 = await got.post(host.concat('/action/PB2showAjaxAbstract'), {
67
- cookieJar,
68
- body: 'doi=' + item.doi,
69
- headers: {
70
- 'X-Requested-With': 'XMLHttpRequest',
71
- 'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
72
- 'Accept-Encoding': 'gzip, deflate, br',
73
- },
35
+ list = await ctx.cache.tryGet(
36
+ secUrl,
37
+ async () => {
38
+ const response2 = await puppeteerGet(secUrl, browser);
39
+ const $2 = cheerio.load(response2);
40
+ list = $2('.card')
41
+ .toArray()
42
+ .map((item) => {
43
+ $2(item).find('.access-text').remove();
44
+ const title = $2(item).find('.hlFld-Title').text();
45
+ const authors = $2(item).find('.entryAuthor.all').text();
46
+ const img = $2(item).find('img').attr('src');
47
+ const link = $2(item).find('.ref.nowrap').attr('href');
48
+ const doi = link.replace('/doi/full/', '');
49
+ const description = renderDesc(title, authors, doi, img);
50
+ return {
51
+ title,
52
+ link,
53
+ doi,
54
+ description,
55
+ };
74
56
  });
75
- const $3 = cheerio.load(response3.data);
76
- item.abstract = $3('span').text();
77
- item.description = renderDesc(item);
78
- return item;
79
- })
80
- )
57
+ return list;
58
+ },
59
+ config.cache.routeExpire,
60
+ false
81
61
  );
82
62
  }
83
63
 
64
+ browser.close();
65
+
84
66
  ctx.state.data = {
85
67
  title: jrnlName.concat(' - ', sec),
86
68
  link: jrnlUrl,
@@ -1,11 +1,8 @@
1
1
  <p>
2
- <span><big>{{ item.title }}</big></span><br>
2
+ <span><big>{{ title }}</big></span><br>
3
3
  </p>
4
4
  <p>
5
- <span><small><i>{{ item.authors }}</i></small></span><br>
6
- <span><small><i>https://doi.org/{{ item.doi }}</i></small></span><br>
7
- {{ if item.img }}<img src={{ item.img }}>{{ /if }}
8
- </p>
9
- <p>
10
- <span>{{ item.abstract }}</span><br>
5
+ <span><small><i>{{ authors }}</i></small></span><br>
6
+ <span><small><i>https://doi.org/{{ doi }}</i></small></span><br>
7
+ {{ if img }}<img src={{ img }}>{{ /if }}
11
8
  </p>
@@ -0,0 +1,29 @@
1
+ const path = require('path');
2
+ const { art } = require('@/utils/render');
3
+
4
+ const puppeteerGet = async (url, browser) => {
5
+ const page = await browser.newPage();
6
+ // await page.setExtraHTTPHeaders({ referer: host });
7
+ await page.setRequestInterception(true);
8
+ page.on('request', (request) => {
9
+ request.resourceType() === 'document' ? request.continue() : request.abort();
10
+ });
11
+ await page.goto(url, {
12
+ waitUntil: 'domcontentloaded',
13
+ });
14
+ const html = await page.evaluate(() => document.documentElement.innerHTML);
15
+ return html;
16
+ };
17
+
18
+ const renderDesc = (title, authors, doi, img) =>
19
+ art(path.join(__dirname, 'templates/description.art'), {
20
+ title,
21
+ authors,
22
+ doi,
23
+ img,
24
+ });
25
+
26
+ module.exports = {
27
+ puppeteerGet,
28
+ renderDesc,
29
+ };
@@ -0,0 +1,68 @@
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
+ const { art } = require('@/utils/render');
6
+ const path = require('path');
7
+
8
+ module.exports = async (ctx) => {
9
+ const rootUrl = 'https://www.sinchew.com.my';
10
+ const currentUrl = `${rootUrl}${ctx.path === '/' ? '' : ctx.path}`;
11
+
12
+ const response = await got({
13
+ method: 'get',
14
+ url: currentUrl,
15
+ });
16
+
17
+ const $ = cheerio.load(response.data);
18
+
19
+ let items = $('.title .internalLink')
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.attr('data-title'),
29
+ link: /^http/.test(link) ? link : `${rootUrl}${link}`,
30
+ pubDate: timezone(parseDate(item.text()), +8),
31
+ };
32
+ });
33
+
34
+ items = await Promise.all(
35
+ items.map((item) =>
36
+ ctx.cache.tryGet(item.link, async () => {
37
+ const detailResponse = await got({
38
+ method: 'get',
39
+ url: item.link,
40
+ });
41
+
42
+ const content = cheerio.load(detailResponse.data);
43
+
44
+ content('.ads-frame, .read-more-msg').remove();
45
+
46
+ content('figure').each(function () {
47
+ content(this).replaceWith(
48
+ art(path.join(__dirname, 'templates/images.art'), {
49
+ image: content(this).find('img').attr('src'),
50
+ caption: content(this).find('figcaption').text(),
51
+ })
52
+ );
53
+ });
54
+
55
+ item.description = content('.article-page-content').html();
56
+ item.pubDate = timezone(parseDate(content('meta[property="article:published_time"]').attr('content')), +8);
57
+
58
+ return item;
59
+ })
60
+ )
61
+ );
62
+
63
+ ctx.state.data = {
64
+ title: $('title').text(),
65
+ link: currentUrl,
66
+ item: items,
67
+ };
68
+ };
@@ -0,0 +1,5 @@
1
+ module.exports = {
2
+ '/category/:category?': ['nczitzk'],
3
+ '/latest': ['nczitzk'],
4
+ '/': ['nczitzk'],
5
+ };
@@ -0,0 +1,25 @@
1
+ module.exports = {
2
+ 'sinchew.com.my': {
3
+ _name: '星洲网',
4
+ '.': [
5
+ {
6
+ title: '首页',
7
+ docs: 'https://docs.rsshub.app/traditional-media.html#xing-zhou-wang-shou-ye',
8
+ source: ['/'],
9
+ target: '/sinchew',
10
+ },
11
+ {
12
+ title: '最新',
13
+ docs: 'https://docs.rsshub.app/traditional-media.html#xing-zhou-wang-zui-xin',
14
+ source: ['/latest', '/'],
15
+ target: '/sinchew/latest',
16
+ },
17
+ {
18
+ title: '分类',
19
+ docs: 'https://docs.rsshub.app/traditional-media.html#xing-zhou-wang-fen-lei',
20
+ source: ['/category/:category', '/'],
21
+ target: (params, url) => `/sinchew/category/${new URL(url).toString().match(/\/category\/(.*)$/)[1]}`,
22
+ },
23
+ ],
24
+ },
25
+ };
@@ -0,0 +1,4 @@
1
+ module.exports = function (router) {
2
+ router.get(/([\w/-]+)?/, require('./index'));
3
+ router.get('', require('./index'));
4
+ };
@@ -0,0 +1,4 @@
1
+ <figure>
2
+ <img src="{{ image }}">
3
+ <figcaption>{{ caption }}</figcaption>
4
+ </figure>
@@ -0,0 +1,52 @@
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.taiwannews.com.tw';
6
+
7
+ module.exports = async (ctx) => {
8
+ const { lang = 'en' } = ctx.params;
9
+ const url = `${baseUrl}/${lang}/index`;
10
+ const response = await got(url);
11
+ const $ = cheerio.load(response.data);
12
+
13
+ const list = $('.mod_group-columns .container-fluid .row')
14
+ .toArray()
15
+ .map((item) => {
16
+ item = $(item);
17
+ const a = item.find('a');
18
+ return {
19
+ title: a.attr('title'),
20
+ link: new URL(a.attr('href'), baseUrl).href,
21
+ pubDate: timezone(parseDate(item.find('.entry-date span').eq(1).text(), 'YYYY/MM/DD HH:mm'), +8),
22
+ };
23
+ });
24
+
25
+ const items = await Promise.all(
26
+ list.map((item) =>
27
+ ctx.cache.tryGet(item.link, async () => {
28
+ const response = await got(item.link);
29
+ const $ = cheerio.load(response.data);
30
+
31
+ item.author = $('.article-author').text();
32
+ item.category = $('.tagcloud a')
33
+ .toArray()
34
+ .map((a) => $(a).attr('title'));
35
+
36
+ $('.article-head-wrapper, div[id^=div-gpt-ad-], div[class^=hidden-], footer').remove();
37
+ $('.container-fluid').eq(2).remove();
38
+
39
+ item.description = $('.mod_single-column').html();
40
+ return item;
41
+ })
42
+ )
43
+ );
44
+
45
+ ctx.state.data = {
46
+ title: `${$('.categories').eq(0).text()} - ${$('head title').text()}`,
47
+ description: $('meta[name="description"]').attr('content'),
48
+ link: url,
49
+ item: items,
50
+ language: lang,
51
+ };
52
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/hot/:lang?': ['TonyRL'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'taiwannews.com.tw': {
3
+ _name: '台灣英文新聞',
4
+ '.': [
5
+ {
6
+ title: '最新熱門消息',
7
+ docs: 'httsp://docs.rsshub.app/traditional-media.html#tai-wan-ying-wen-xin-wen',
8
+ source: '/:lang/index',
9
+ target: '/taiwannews/hot/:lang',
10
+ },
11
+ ],
12
+ },
13
+ };