rsshub 1.0.0-master.f2c8f0c → 1.0.0-master.f2eee10

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 (77) hide show
  1. package/lib/router.js +4 -3
  2. package/lib/utils/wechat-mp.js +1 -1
  3. package/lib/v2/2048/index.js +7 -5
  4. package/lib/v2/agirls/index.js +14 -42
  5. package/lib/v2/agirls/topic.js +16 -43
  6. package/lib/v2/agirls/topic_list.js +14 -14
  7. package/lib/v2/agirls/utils.js +37 -0
  8. package/lib/v2/apnews/topics.js +24 -30
  9. package/lib/v2/baozimh/index.js +9 -14
  10. package/lib/v2/bilibili/followers.js +12 -1
  11. package/lib/v2/bilibili/followings.js +16 -1
  12. package/lib/v2/bilibili/liveSearch.js +18 -10
  13. package/lib/v2/bilibili/maintainer.js +2 -2
  14. package/lib/v2/bilibili/router.js +2 -2
  15. package/lib/v2/blizzard/maintainer.js +3 -0
  16. package/lib/{routes → v2}/blizzard/news.js +14 -15
  17. package/lib/v2/blizzard/radar.js +13 -0
  18. package/lib/v2/blizzard/router.js +3 -0
  19. package/lib/v2/caixin/latest.js +5 -5
  20. package/lib/v2/copymanga/comic.js +74 -58
  21. package/lib/v2/copymanga/templates/comic.art +1 -1
  22. package/lib/v2/dhu/maintainer.js +1 -0
  23. package/lib/v2/dhu/news/xsxx.js +42 -0
  24. package/lib/v2/dhu/radar.js +8 -0
  25. package/lib/v2/dhu/router.js +1 -0
  26. package/lib/v2/globallawreview/index.js +55 -0
  27. package/lib/v2/globallawreview/maintainer.js +3 -0
  28. package/lib/v2/globallawreview/radar.js +13 -0
  29. package/lib/v2/globallawreview/router.js +3 -0
  30. package/lib/v2/gov/cac/index.js +4 -4
  31. package/lib/v2/gov/maintainer.js +1 -0
  32. package/lib/v2/gov/nifdc/index.js +2 -17
  33. package/lib/v2/gov/nmpa/generic.js +5 -27
  34. package/lib/v2/gov/nrta/dsj.js +59 -0
  35. package/lib/v2/gov/radar.js +13 -0
  36. package/lib/v2/gov/router.js +1 -0
  37. package/lib/v2/huoxian/maintainer.js +3 -0
  38. package/lib/v2/huoxian/radar.js +11 -0
  39. package/lib/v2/huoxian/router.js +3 -0
  40. package/lib/v2/huoxian/zone.js +19 -0
  41. package/lib/v2/javdb/utils.js +5 -4
  42. package/lib/v2/jike/radar.js +20 -0
  43. package/lib/v2/keylol/index.js +82 -0
  44. package/lib/v2/keylol/maintainer.js +3 -0
  45. package/lib/v2/keylol/radar.js +18 -0
  46. package/lib/v2/keylol/router.js +3 -0
  47. package/lib/v2/line/utils.js +18 -2
  48. package/lib/v2/macupdate/app.js +43 -0
  49. package/lib/v2/macupdate/maintainer.js +3 -0
  50. package/lib/v2/macupdate/radar.js +13 -0
  51. package/lib/v2/macupdate/router.js +3 -0
  52. package/lib/v2/radiofrance/templates/article.art +3 -1
  53. package/lib/v2/sec-in/index.js +19 -0
  54. package/lib/v2/sec-in/maintainer.js +3 -0
  55. package/lib/v2/sec-in/radar.js +11 -0
  56. package/lib/v2/sec-in/router.js +3 -0
  57. package/lib/v2/sec-wiki/maintainer.js +3 -0
  58. package/lib/v2/sec-wiki/radar.js +11 -0
  59. package/lib/v2/sec-wiki/router.js +3 -0
  60. package/lib/v2/sec-wiki/weekly.js +16 -0
  61. package/lib/v2/shu/index.js +48 -0
  62. package/lib/v2/shu/jwb.js +45 -0
  63. package/lib/v2/shu/maintainer.js +4 -0
  64. package/lib/v2/shu/radar.js +21 -0
  65. package/lib/v2/shu/router.js +5 -0
  66. package/lib/v2/stheadline/std/realtime.js +1 -1
  67. package/lib/v2/wikinews/index.js +28 -29
  68. package/lib/v2/wxkol/show.js +5 -34
  69. package/lib/v2/yangtzeu/dongke.js +60 -0
  70. package/lib/v2/yangtzeu/maintainer.js +3 -0
  71. package/lib/v2/yangtzeu/radar.js +18 -0
  72. package/lib/v2/yangtzeu/router.js +3 -0
  73. package/lib/v2/zaobao/util.js +38 -31
  74. package/package.json +3 -3
  75. package/lib/routes/universities/shu/index.js +0 -75
  76. package/lib/routes/universities/shu/jwc.js +0 -62
  77. package/lib/v2/agirls/templates/description.art +0 -1
@@ -5,37 +5,36 @@ module.exports = async (ctx) => {
5
5
  const category = ctx.params.category || '';
6
6
  const language = ctx.params.language || 'en-us';
7
7
 
8
- const rootUrl = `https://${language === 'zh-cn' ? 'cn.' : ''}news.blizzard.com`;
8
+ const rootUrl = 'https://news.blizzard.com';
9
9
  const currentUrl = `${rootUrl}/${language}/${category}`;
10
- const response = await got({
11
- method: 'get',
12
- url: currentUrl,
10
+ const apiUrl = `${rootUrl}/${language}/blog/list`;
11
+ const response = await got(apiUrl, {
12
+ searchParams: {
13
+ community: category === '' ? 'all' : category,
14
+ },
13
15
  });
14
16
 
15
- const $ = cheerio.load(response.data);
17
+ const $ = cheerio.load(response.data.html, null, false);
16
18
 
17
- const list = $('.FeaturedArticle-text a, .ArticleListItem article a')
18
- .slice(0, 10)
19
- .map((_, item) => {
19
+ const list = $('.FeaturedArticle-text > a, .ArticleListItem > article > a')
20
+ .slice(0, ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30)
21
+ .toArray()
22
+ .map((item) => {
20
23
  item = $(item);
21
24
  return {
22
25
  title: item.text(),
23
26
  link: `${rootUrl}${item.attr('href')}`,
24
27
  };
25
- })
26
- .get();
28
+ });
27
29
 
28
30
  const items = await Promise.all(
29
31
  list.map((item) =>
30
32
  ctx.cache.tryGet(item.link, async () => {
31
- const detailResponse = await got({
32
- method: 'get',
33
- url: item.link,
34
- });
33
+ const detailResponse = await got(item.link);
35
34
  const content = cheerio.load(detailResponse.data);
36
35
 
37
36
  item.author = content('.ArticleDetail-bylineAuthor').text();
38
- item.description = content('.ArticleDetail-content').html();
37
+ item.description = content('.ArticleDetail-headingImageBlock').html() + content('.ArticleDetail-content').html();
39
38
  item.pubDate = content('.ArticleDetail-subHeadingLeft time').attr('timestamp');
40
39
 
41
40
  return item;
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'blizzard.com': {
3
+ _name: 'Blizzard',
4
+ news: [
5
+ {
6
+ title: 'News',
7
+ docs: 'https://docs.rsshub.app/game.html#blizzard',
8
+ source: ['/:language/:category?', '/:language'],
9
+ target: '/blizzard/news/:language/:category?',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = (router) => {
2
+ router.get('/news/:language?/:category?', require('./news'));
3
+ };
@@ -6,13 +6,13 @@ const { art } = require('@/utils/render');
6
6
  const path = require('path');
7
7
 
8
8
  module.exports = async (ctx) => {
9
- const li_r = await got('https://www.caixin.com/2021-08-22/101758426.html');
9
+ const li_r = await got('https://www.caixin.com/search/scroll/0.jsp');
10
10
 
11
11
  const $ = cheerio.load(li_r.data);
12
- const list = $('div.columnBox a[name="new_artical"]~ul.list li')
12
+ const list = $('div.news_content dl dd')
13
13
  .toArray()
14
- .map((li) => ({
15
- link: $(li).find('a').first().attr('href').replace('http://', 'https://'),
14
+ .map((dd) => ({
15
+ link: $(dd).find('a').first().attr('href').replace('http://', 'https://'),
16
16
  }))
17
17
  .filter((item) => !item.link.startsWith('https://fm.caixin.com/') && !item.link.startsWith('https://video.caixin.com/') && !item.link.startsWith('https://datanews.caixin.com/')); // content filter
18
18
 
@@ -22,7 +22,7 @@ module.exports = async (ctx) => {
22
22
  const entry_r = await got(item.link);
23
23
  const $ = cheerio.load(entry_r.data);
24
24
  // title
25
- const h1 = $('div#conTit h1').text();
25
+ const h1 = $('#conTit h1').text();
26
26
 
27
27
  // desc
28
28
  const desc = art(path.join(__dirname, 'templates/article.art'), {
@@ -3,59 +3,70 @@ const got = require('@/utils/got');
3
3
  const { parseDate } = require('@/utils/parse-date');
4
4
  const { art } = require('@/utils/render');
5
5
  const path = require('path');
6
+ const config = require('@/config').value;
7
+ const asyncPool = require('tiny-async-pool');
6
8
 
7
- const host = 'copymanga.site';
8
- const baseUrl = `https://${host}`;
9
- const apiBaseUrl = `https://api.${host}`;
10
-
11
- // 直接调用拷贝漫画的接口
12
9
  module.exports = async (ctx) => {
13
10
  const { id } = ctx.params;
14
11
  // 用于控制返回的章节数量
15
- const chapterCnt = Number(ctx.params.chapterCnt || 0);
16
- // 获取漫画列表
17
- let bHasNextPage = false;
18
- const iReqLimit = (ctx.queries && ctx.queries.limit) || 100;
19
- let iReqOffSet = 0;
12
+ const chapterCnt = Number(ctx.params.chapterCnt || 10);
13
+ // 直接调用拷贝漫画的接口
14
+ const host = 'copymanga.site';
15
+ const baseUrl = `https://${host}`;
16
+ const apiBaseUrl = `https://api.${host}`;
20
17
  const strBaseUrl = `${apiBaseUrl}/api/v3/comic/${id}/group/default/chapters`;
21
- let chapterArray = [];
18
+ const iReqLimit = 500;
19
+ // 获取漫画列表
20
+ const chapterArray = await ctx.cache.tryGet(
21
+ strBaseUrl,
22
+ async () => {
23
+ let bHasNextPage = false;
24
+ let chapters = [];
25
+ let iReqOffSet = 0;
22
26
 
23
- do {
24
- bHasNextPage = false;
25
- // eslint-disable-next-line no-await-in-loop
26
- const { data } = await got(strBaseUrl, {
27
- headers: {
28
- platform: 1,
29
- },
30
- searchParams: {
31
- limit: iReqLimit,
32
- offset: iReqOffSet === 0 ? undefined : iReqOffSet,
33
- },
34
- });
35
- const { code, results } = data;
27
+ do {
28
+ bHasNextPage = false;
29
+ // eslint-disable-next-line no-await-in-loop
30
+ const { data } = await got(strBaseUrl, {
31
+ headers: {
32
+ platform: 1,
33
+ },
34
+ searchParams: {
35
+ limit: iReqLimit,
36
+ offset: iReqOffSet,
37
+ },
38
+ });
39
+ const { code, results } = data;
36
40
 
37
- if (code !== 200) {
38
- break;
39
- }
41
+ if (code !== 200) {
42
+ break;
43
+ }
40
44
 
41
- if (results.limit + results.offset < results.total) {
42
- bHasNextPage = true;
43
- }
44
- iReqOffSet += iReqLimit;
45
+ if (results.limit + results.offset < results.total) {
46
+ bHasNextPage = true;
47
+ }
48
+ iReqOffSet += iReqLimit;
49
+
50
+ chapters = [...chapters, ...results.list];
51
+ } while (bHasNextPage);
45
52
 
46
- chapterArray = [...chapterArray, ...results.list];
47
- } while (bHasNextPage);
53
+ chapters = chapters
54
+ .map(({ comic_path_word, uuid, name, size, datetime_created, ordered /* , index*/ }) => ({
55
+ link: `${baseUrl}/comic/${comic_path_word}/chapter/${uuid}`,
56
+ uuid,
57
+ title: name,
58
+ size,
59
+ pubDate: parseDate(datetime_created, 'YYYY-MM-DD'),
60
+ ordered,
61
+ // index,
62
+ }))
63
+ .sort((a, b) => b.ordered - a.ordered);
48
64
 
49
- chapterArray = chapterArray
50
- .map(({ comic_path_word, uuid, name, size, datetime_created /* , index*/ }) => ({
51
- link: `${baseUrl}/comic/${comic_path_word}/chapter/${uuid}`,
52
- uuid,
53
- title: name,
54
- size,
55
- pubDate: datetime_created,
56
- // index,
57
- }))
58
- .reverse();
65
+ return chapters;
66
+ },
67
+ config.cache.routeExpire,
68
+ false
69
+ );
59
70
 
60
71
  // 获取漫画标题、介绍
61
72
  const { bookTitle, bookIntro } = await ctx.cache.tryGet(`${baseUrl}/comic/${id}`, async () => {
@@ -69,20 +80,20 @@ module.exports = async (ctx) => {
69
80
 
70
81
  const genResult = async (chapter) => {
71
82
  const {
72
- data: { results },
73
- } = await got(`${apiBaseUrl}/api/v3/comic/${id}/chapter2/${chapter.uuid}`, {
83
+ data: { code, results },
84
+ } = await got(`${apiBaseUrl}/api/v3/comic/${id}/chapter/${chapter.uuid}`, {
74
85
  headers: {
75
86
  webp: 1,
76
87
  },
77
88
  });
78
89
 
79
- const pageNumbers = Object.values(results.chapter.words);
80
- const contents = results.chapter.contents
81
- .map((content, index) => ({
82
- page: pageNumbers[index],
83
- url: content.url,
84
- }))
85
- .sort((a, b) => a.page - b.page);
90
+ let contents;
91
+ if (code === 210) {
92
+ // Request was throttled. Expected available in x seconds.
93
+ contents = [];
94
+ } else {
95
+ contents = results.chapter.contents.map((content) => ({ url: content.url.replace('.c800x.', '.c1500x.') }));
96
+ }
86
97
 
87
98
  return {
88
99
  link: chapter.link,
@@ -91,20 +102,25 @@ module.exports = async (ctx) => {
91
102
  size: chapter.size,
92
103
  contents,
93
104
  }),
94
- pubDate: parseDate(chapter.pubDate, 'YYYY-MM-DD'),
105
+ pubDate: chapter.pubDate,
95
106
  };
96
107
  };
97
108
 
98
- let itemsLen = chapterArray.length;
109
+ const asyncPoolAll = async (...args) => {
110
+ const results = [];
111
+ for await (const result of asyncPool(...args)) {
112
+ results.push(result);
113
+ }
114
+ return results;
115
+ };
99
116
 
100
- if (chapterCnt > 0) {
101
- itemsLen = chapterCnt;
102
- }
117
+ const result = await asyncPoolAll(3, chapterArray.slice(0, chapterCnt), (chapter) => ctx.cache.tryGet(chapter.link, () => genResult(chapter)));
118
+ const items = [...result, ...chapterArray.slice(chapterCnt)];
103
119
 
104
120
  ctx.state.data = {
105
121
  title: `拷贝漫画 - ${bookTitle}`,
106
122
  link: `${baseUrl}/comic/${id}`,
107
123
  description: bookIntro,
108
- item: await Promise.all(chapterArray.slice(0, itemsLen).map((chapter) => ctx.cache.tryGet(chapter.link, () => genResult(chapter)))),
124
+ item: items,
109
125
  };
110
126
  };
@@ -1,4 +1,4 @@
1
1
  <h1>{{ size }}p</h1><br>
2
2
  {{ each contents img }}
3
- <img src="{{ img.url }}" alt="{{ img.page }}">
3
+ <img src="{{ img.url }}">
4
4
  {{ /each }}
@@ -1,5 +1,6 @@
1
1
  module.exports = {
2
2
  '/jiaowu/news/:type?': ['KiraKiseki'],
3
+ '/news/xsxx': ['fox2049'],
3
4
  '/xxgk/news': ['KiraKiseki'],
4
5
  '/yjs/zs/:type?': ['fox2049'],
5
6
  };
@@ -0,0 +1,42 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+
5
+ const baseUrl = 'https://news.dhu.edu.cn/_wp3services/generalQuery?queryObj=articles&siteId=14&columnId=6410&pageIndex=1&rows=20';
6
+
7
+ module.exports = async (ctx) => {
8
+ const { data } = await got(baseUrl, {
9
+ headers: {
10
+ Referer: 'https://news.dhu.edu.cn/6410/',
11
+ },
12
+ });
13
+ // 从 API 响应中提取相关数据
14
+ const list = data.data.map((item) => ({
15
+ // 文章标题
16
+ title: item.title,
17
+ // 文章链接
18
+ link: item.wapUrl,
19
+ // 文章发布日期
20
+ pubDate: parseDate(item.publishTime),
21
+ // 文章作者
22
+ author: item.publisher,
23
+ }));
24
+
25
+ // item content
26
+ const items = await Promise.all(
27
+ list.map((item) =>
28
+ ctx.cache.tryGet(item.link, async () => {
29
+ const { data: response } = await got(item.link);
30
+ const $ = cheerio.load(response);
31
+ item.description = $('.new_zwCot').first().html();
32
+ return item;
33
+ })
34
+ )
35
+ );
36
+
37
+ ctx.state.data = {
38
+ title: '学术信息',
39
+ link: 'https://news.dhu.edu.cn/6410',
40
+ item: items,
41
+ };
42
+ };
@@ -7,6 +7,14 @@ module.exports = {
7
7
  docs: 'https://docs.rsshub.app/university.html#dong-hua-da-xue',
8
8
  },
9
9
  ],
10
+ news: [
11
+ {
12
+ title: '学术信息',
13
+ docs: 'https://docs.rsshub.app/university.html#dong-hua-da-xue',
14
+ source: ['/6410'],
15
+ target: '/dhu/news/xsxx',
16
+ },
17
+ ],
10
18
  xxgk: [
11
19
  {
12
20
  title: '最新信息公开',
@@ -1,5 +1,6 @@
1
1
  module.exports = function (router) {
2
2
  router.get('/jiaowu/news/:type?', require('./jiaowu/news'));
3
+ router.get('/news/xsxx', require('./news/xsxx'));
3
4
  router.get('/xxgk/news', require('./xxgk/news'));
4
5
  router.get('/yjs/zs/:type?', require('./yjs/zs'));
5
6
  };
@@ -0,0 +1,55 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+
4
+ module.exports = async (ctx) => {
5
+ const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
6
+
7
+ const rootUrl = 'http://www.globallawreview.org';
8
+
9
+ const { data: firstResponse } = await got(rootUrl);
10
+
11
+ let $ = cheerio.load(firstResponse);
12
+
13
+ const currentUrl = new URL($('p.tabBtn span a').prop('href'), rootUrl).href;
14
+
15
+ const { data: response } = await got(currentUrl);
16
+
17
+ $ = cheerio.load(response);
18
+
19
+ const items = $('ul.digest li')
20
+ .slice(0, limit)
21
+ .toArray()
22
+ .map((item) => {
23
+ item = $(item);
24
+
25
+ const a = item.find('p.p1 a');
26
+ const link = new URL(a.prop('href'), rootUrl).href;
27
+
28
+ return {
29
+ title: a.text(),
30
+ link,
31
+ description: item.find('p.p2').html(),
32
+ author: item.find('p.p3 span').text() || a.text().split(':')[0],
33
+ category: [
34
+ item
35
+ .find('p.p4')
36
+ .text()
37
+ .match(/] (\d+\.\d+);/)[1],
38
+ ],
39
+ enclosure_url: link,
40
+ enclosure_length:
41
+ item
42
+ .find('p.p4')
43
+ .text()
44
+ .match(/(\d+(\.\d+)?)\sKB/)[1] * 1000,
45
+ };
46
+ });
47
+
48
+ ctx.state.data = {
49
+ item: items,
50
+ title: $('title').text(),
51
+ link: currentUrl,
52
+ language: 'zh-cn',
53
+ author: '中国社会科学院法学研究所',
54
+ };
55
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/': ['nczitzk'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'globallawreview.org': {
3
+ _name: '环球法律评论',
4
+ '.': [
5
+ {
6
+ title: '期刊',
7
+ docs: 'https://docs.rsshub.app/journal.html#huan-qiu-fa-lu-ping-lun',
8
+ source: ['/Magazine/GetIssueContentList', '/'],
9
+ target: '/globallawreview',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get('/', require('./'));
3
+ };
@@ -19,8 +19,8 @@ module.exports = async (ctx) => {
19
19
  .toArray()
20
20
  .map((item) => {
21
21
  const href = $(item).attr('href');
22
- if (href && href.startsWith('http://www.cac.gov.cn/')) {
23
- const matchArray = href.match(/http:\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/);
22
+ if (href && href.match(/(?:http:)?\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/)) {
23
+ const matchArray = href.match(/(?:http:)?\/\/www\.cac\.gov\.cn(.*?)\/(A.*?\.htm)/);
24
24
  if (matchArray && matchArray.length > 2) {
25
25
  const path = matchArray[1];
26
26
  const htmlName = matchArray[2];
@@ -41,14 +41,14 @@ module.exports = async (ctx) => {
41
41
  const completeUrl = pathList.find((item) => item && item.path === path).completeUrl;
42
42
  const { data: channelResponse } = await got(completeUrl);
43
43
  const $1 = cheerio.load(channelResponse);
44
- const items = $1('li.clearfix')
44
+ const items = $1('div#loadingInfoPage li')
45
45
  .toArray()
46
46
  .map((item) => {
47
47
  const c = $1(item);
48
48
  const a = c.find('a');
49
49
  const articleHref = a.attr('href');
50
50
  const title = a.text();
51
- const date = parseDate(c.find('span.times').text());
51
+ const date = parseDate(c.find('.times').text());
52
52
  return {
53
53
  link: articleHref,
54
54
  pubDate: timezone(date),
@@ -36,6 +36,7 @@ module.exports = {
36
36
  '/nmpa/:path+': ['TonyRL'],
37
37
  '/nopss/:path+': ['nczitzk'],
38
38
  '/nrta/news/:category?': ['yuxinliu-alex'],
39
+ '/nrta/dsj/:category?': ['nczitzk'],
39
40
  '/nsfc/news/:type?': ['Derekmini', 'nczitzk'],
40
41
  '/pbc/goutongjiaoliu': ['nczitzk'],
41
42
  '/pbc/gzlw': ['Fatpandac'],
@@ -36,29 +36,16 @@ module.exports = async (ctx) => {
36
36
  };
37
37
  });
38
38
 
39
- const browser = await require('@/utils/puppeteer')();
40
-
41
39
  items = await Promise.all(
42
40
  items.map((item) =>
43
41
  ctx.cache.tryGet(item.link, async () => {
44
42
  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();
43
+ const { data: html } = await got(item.link);
58
44
 
59
45
  const content = cheerio.load(html);
60
46
 
61
47
  item.description = content('.text').html();
48
+ item.pubDate = timezone(parseDate($('meta[name="PubDate"]').attr('content')), +8);
62
49
  } else {
63
50
  const detailResponse = await got({
64
51
  method: 'get',
@@ -76,8 +63,6 @@ module.exports = async (ctx) => {
76
63
  )
77
64
  );
78
65
 
79
- await browser.close();
80
-
81
66
  ctx.state.data = {
82
67
  title: $('title').text().replace(/----/, ' - '),
83
68
  link: currentUrl,
@@ -1,28 +1,18 @@
1
1
  const cheerio = require('cheerio');
2
+ const timezone = require('@/utils/timezone');
2
3
  const { parseDate } = require('@/utils/parse-date');
3
4
  const { finishArticleItem } = require('@/utils/wechat-mp');
4
5
  const config = require('@/config').value;
5
6
  const baseUrl = 'https://www.nmpa.gov.cn';
7
+ const got = require('@/utils/got');
6
8
 
7
9
  module.exports = async (ctx) => {
8
10
  const path = ctx.params[0];
9
11
  const url = `${baseUrl}/${path.endsWith('/') ? path.slice(0, -1) : path}/index.html`;
10
- const browser = await require('@/utils/puppeteer')({ stealth: true });
11
12
  const data = await ctx.cache.tryGet(
12
13
  url,
13
14
  async () => {
14
- const page = await browser.newPage();
15
- await page.setRequestInterception(true);
16
- page.on('request', (request) => {
17
- request.resourceType() === 'document' || request.resourceType() === 'script' ? request.continue() : request.abort();
18
- });
19
- await page.goto(url, {
20
- waitUntil: 'domcontentloaded',
21
- });
22
- await page.waitForSelector('.list');
23
-
24
- const html = await page.evaluate(() => document.documentElement.innerHTML);
25
- await page.close();
15
+ const { data: html } = await got(url);
26
16
  const $ = cheerio.load(html);
27
17
 
28
18
  return {
@@ -48,20 +38,10 @@ module.exports = async (ctx) => {
48
38
  data.items.map((item) => {
49
39
  if (/^https:\/\/www\.nmpa\.gov\.cn\//.test(item.link)) {
50
40
  return ctx.cache.tryGet(item.link, async () => {
51
- const page = await browser.newPage();
52
- await page.setRequestInterception(true);
53
- page.on('request', (request) => {
54
- request.resourceType() === 'document' || request.resourceType() === 'script' ? request.continue() : request.abort();
55
- });
56
- await page.goto(item.link, {
57
- waitUntil: 'domcontentloaded',
58
- });
59
- await page.waitForSelector('.text');
60
-
61
- const html = await page.evaluate(() => document.documentElement.innerHTML);
62
- await page.close();
41
+ const { data: html } = await got(item.link);
63
42
  const $ = cheerio.load(html);
64
43
  item.description = $('.text').html();
44
+ item.pubDate = timezone(parseDate($('meta[name="PubDate"]').attr('content')), +8);
65
45
  return item;
66
46
  });
67
47
  } else if (/^https:\/\/mp\.weixin\.qq\.com\//.test(item.link)) {
@@ -72,8 +52,6 @@ module.exports = async (ctx) => {
72
52
  })
73
53
  );
74
54
 
75
- await browser.close();
76
-
77
55
  ctx.state.data = {
78
56
  title: data.title,
79
57
  description: data.description,
@@ -0,0 +1,59 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const { parseDate } = require('@/utils/parse-date');
4
+ const asyncPool = require('tiny-async-pool');
5
+
6
+ module.exports = async (ctx) => {
7
+ const { category = 'note' } = ctx.params;
8
+ const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 15;
9
+
10
+ const rootUrl = 'https://dsj.nrta.gov.cn';
11
+ const currentUrl = new URL(`tims/site/views/applications.shanty?appName=${category}`, rootUrl).href;
12
+
13
+ const { data: response } = await got(currentUrl);
14
+
15
+ const $ = cheerio.load(response);
16
+
17
+ const items = $('img[src="/site/styles/default/images/icon_arrow_r.gif"]')
18
+ .slice(0, limit)
19
+ .toArray()
20
+ .map((item) => {
21
+ item = $(item).next();
22
+
23
+ const pubDateMatches = item.text().match(/(\d+年\d+月)/);
24
+
25
+ return {
26
+ title: item.text(),
27
+ link: new URL(item.prop('href'), rootUrl).href,
28
+ pubDate: pubDateMatches ? parseDate(pubDateMatches[1], ['YYYY年MM月', 'YYYY年M月']) : undefined,
29
+ };
30
+ });
31
+
32
+ const results = [];
33
+
34
+ for await (const item of asyncPool(5, items, (item) =>
35
+ ctx.cache.tryGet(item.link, async () => {
36
+ const { data: detailResponse } = await got(item.link);
37
+
38
+ const content = cheerio.load(detailResponse);
39
+
40
+ content('table').last().remove();
41
+
42
+ item.description = content('td.newstext').html() || content('table').last().parent().parent().html();
43
+
44
+ return item;
45
+ })
46
+ )) {
47
+ results.push(item);
48
+ }
49
+
50
+ ctx.state.data = {
51
+ item: results,
52
+ title: `${$('title').text()}-${$('div.headbottom_menu_selected').text()}`,
53
+ link: currentUrl,
54
+ description: $('td').last().text(),
55
+ language: 'zh-cn',
56
+ image: $('img').first().prop('src'),
57
+ author: '国家广播电影电视总局电视剧管理司',
58
+ };
59
+ };
@@ -828,6 +828,19 @@ module.exports = {
828
828
  target: (params) => `/gov/nrta/news/${params.category.replace('col', '').replace('/index.html', '')}`,
829
829
  },
830
830
  ],
831
+ dsj: [
832
+ {
833
+ title: '电视剧政务平台',
834
+ docs: 'https://docs.rsshub.app/government.html#guo-jia-guang-bo-dian-shi-zong-ju',
835
+ source: ['/tims/site/views/applications.shanty', '/'],
836
+ target: (params, url) => {
837
+ url = new URL(url);
838
+ const category = url.searchParams.get('appName');
839
+
840
+ return `/gov/nrta/dsj/${category}`;
841
+ },
842
+ },
843
+ ],
831
844
  },
832
845
  'nsfc.gov.cn': {
833
846
  _name: '国家自然科学基金委员会',