rsshub 1.0.0-master.e03f0b8 → 1.0.0-master.e046f52

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.
@@ -213,7 +213,7 @@ const fetchArticle = (ctx, url, bypassHostCheck = false) => {
213
213
  }
214
214
 
215
215
  let pubDate;
216
- const publish_time_script = $('script[nonce][type="text/javascript"]:contains("var ct")').first().html();
216
+ const publish_time_script = $('script[nonce][type="text/javascript"]:contains("var ct")').text();
217
217
  const publish_time_match = publish_time_script && publish_time_script.match(/var ct *= *"?(\d{10})"?/);
218
218
  const publish_timestamp = publish_time_match && publish_time_match[1];
219
219
  if (publish_timestamp) {
@@ -1,4 +1,6 @@
1
1
  const got = require('@/utils/got');
2
+ const utils = require('./utils');
3
+ const cache = require('./cache');
2
4
 
3
5
  module.exports = async (ctx) => {
4
6
  const key = ctx.params.key;
@@ -15,26 +17,32 @@ module.exports = async (ctx) => {
15
17
  orderTitle = '人气直播';
16
18
  break;
17
19
  }
20
+ const verifyString = await cache.getVerifyString(ctx);
21
+ let params = `__refresh__=true&_extra=&context=&page=1&page_size=42&order=${order}&duration=&from_source=&from_spmid=333.337&platform=pc&highlight=1&single_column=0&keyword=${urlEncodedKey}&ad_resource=&source_tag=3&gaia_vtoken=&category_id=&search_type=live&dynamic_offset=0&web_location=1430654`;
22
+ params = utils.addVerifyInfo(params, verifyString);
18
23
 
19
24
  const response = await got({
20
25
  method: 'get',
21
- url: `https://api.bilibili.com/x/web-interface/search/type?search_type=live_room&keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1`,
26
+ url: `https://api.bilibili.com/x/web-interface/wbi/search/type?${params}`,
22
27
  headers: {
23
- Referer: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`,
28
+ Referer: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&from_source=webtop_search&spm_id_from=444.7&search_source=3&search_type=live_room`,
29
+ Cookie: await cache.getCookie(ctx),
24
30
  },
25
31
  });
26
- const data = response.data.data.result;
32
+ const data = response.data.data.result.live_room;
27
33
 
28
34
  ctx.state.data = {
29
35
  title: `哔哩哔哩直播-${key}-${orderTitle}`,
30
36
  link: `https://search.bilibili.com/live?keyword=${urlEncodedKey}&order=${order}&coverType=user_cover&page=1&search_type=live`,
31
37
  description: `哔哩哔哩直播-${key}-${orderTitle}`,
32
- item: data.map((item) => ({
33
- title: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
34
- description: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
35
- pubDate: new Date(item.live_time.replace(' ', 'T') + '+08:00').toUTCString(),
36
- guid: `https://live.bilibili.com/${item.roomid} ${item.live_time}`,
37
- link: `https://live.bilibili.com/${item.roomid}`,
38
- })),
38
+ item:
39
+ data &&
40
+ data.map((item) => ({
41
+ title: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
42
+ description: `${item.uname} ${item.title} (${item.cate_name}-${item.live_time})`,
43
+ pubDate: new Date(item.live_time.replace(' ', 'T') + '+08:00').toUTCString(),
44
+ guid: `https://live.bilibili.com/${item.roomid} ${item.live_time}`,
45
+ link: `https://live.bilibili.com/${item.roomid}`,
46
+ })),
39
47
  };
40
48
  };
@@ -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'), {
@@ -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
  };
@@ -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,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,3 @@
1
+ module.exports = {
2
+ '/zone': ['p7e4'],
3
+ };
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ 'huoxian.cn': {
3
+ _name: '火线',
4
+ zone: [
5
+ {
6
+ title: 'Zone',
7
+ docs: 'https://docs.rsshub.app/bbs.html#huo-xian',
8
+ },
9
+ ],
10
+ },
11
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = (router) => {
2
+ router.get('/zone', require('./zone'));
3
+ };
@@ -0,0 +1,19 @@
1
+ const got = require('@/utils/got');
2
+ const { parseDate } = require('@/utils/parse-date');
3
+
4
+ module.exports = async (ctx) => {
5
+ const { data } = await got('https://zone.huoxian.cn/api/discussions?sort=-createdAt');
6
+ const items = data.data.map((item) => ({
7
+ title: item.attributes.title,
8
+ link: `https://zone.huoxian.cn/d/${item.attributes.slug}`,
9
+ description: data.included.find((i) => i.id === item.relationships.firstPost.data.id).attributes.contentHtml,
10
+ pubDate: parseDate(item.attributes.createdAt),
11
+ author: data.included.find((i) => i.id === item.relationships.user.data.id).attributes.displayName,
12
+ category: data.included.filter((i) => item.relationships.tags.data.map((t) => t.id).includes(i.id) && i.type === 'tags').map((i) => i.attributes.name),
13
+ }));
14
+ ctx.state.data = {
15
+ title: '火线 Zone-安全攻防社区',
16
+ link: 'https://zone.huoxian.cn/',
17
+ item: items,
18
+ };
19
+ };
@@ -0,0 +1,19 @@
1
+ const got = require('@/utils/got');
2
+ const { parseDate } = require('@/utils/parse-date');
3
+
4
+ module.exports = async (ctx) => {
5
+ const { data } = await got('https://sec-in.com/api/v1/Common/getArticleList?tabs=newest');
6
+ const items = data.result.data.map((item) => ({
7
+ title: item.article_title,
8
+ link: `https://sec-in.com/article/${item.id}`,
9
+ description: item.summary,
10
+ pubDate: parseDate(item.passed_time),
11
+ author: item.member_info.nickname,
12
+ category: item.article_tag,
13
+ }));
14
+ ctx.state.data = {
15
+ title: 'SecIN信息安全技术社区',
16
+ link: 'https://sec-in.com/',
17
+ item: items,
18
+ };
19
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/': ['p7e4'],
3
+ };
@@ -0,0 +1,11 @@
1
+ module.exports = {
2
+ 'sec-in.com': {
3
+ _name: 'SecIN信息安全技术社区',
4
+ '.': [
5
+ {
6
+ title: '最新文章',
7
+ docs: 'https://docs.rsshub.app/bbs.html#secin-xin-xi-an-quan-ji-shu-she-qu',
8
+ },
9
+ ],
10
+ },
11
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = (router) => {
2
+ router.get('/', require('./index'));
3
+ };
@@ -1,22 +1,13 @@
1
1
  const got = require('@/utils/got');
2
2
  const cheerio = require('cheerio');
3
- const { fetchArticle } = require('@/utils/wechat-mp');
3
+ const { finishArticleItem } = require('@/utils/wechat-mp');
4
4
  const config = require('@/config').value;
5
- const asyncPool = require('tiny-async-pool');
6
5
 
7
6
  module.exports = async (ctx) => {
8
7
  const baseUrl = 'https://www.wxkol.com';
9
8
  const { id } = ctx.params;
10
9
  const url = `${baseUrl}/show/${id}.html`;
11
10
 
12
- const asyncPoolAll = async (...args) => {
13
- const results = [];
14
- for await (const result of asyncPool(...args)) {
15
- results.push(result);
16
- }
17
- return results;
18
- };
19
-
20
11
  const feedData = await ctx.cache.tryGet(
21
12
  url,
22
13
  async () => {
@@ -30,13 +21,13 @@ module.exports = async (ctx) => {
30
21
  const a = item.find('.title a');
31
22
  return {
32
23
  title: a.attr('title'),
33
- link: `${baseUrl}${a.attr('href')}`,
24
+ link: a.attr('href'),
34
25
  };
35
26
  });
36
27
 
37
28
  return {
38
29
  feedTitle: $('head title').text(),
39
- feedDescription: $('head description').text(),
30
+ feedDescription: $('.info_left .description i').text(),
40
31
  feedImage: $('.main .logo .avatar')
41
32
  .attr('style')
42
33
  .match(/url\('(.+)'\)/)[1],
@@ -47,34 +38,14 @@ module.exports = async (ctx) => {
47
38
  false
48
39
  );
49
40
 
50
- const urlList = await asyncPoolAll(2, feedData.feedItem, (item) =>
51
- ctx.cache.tryGet(item.link, async () => {
52
- const { data: response } = await got(item.link);
53
- const $ = cheerio.load(response);
54
- item.link = `${baseUrl}${$('.source a').attr('href')}`;
55
- return item;
56
- })
57
- );
58
-
59
- const items = await asyncPoolAll(4, urlList, async (item) => {
60
- const { title, author, description, summary, pubDate, mpName, link: itemLink } = await fetchArticle(ctx, item.link, true);
61
-
62
- item.title = title;
63
- item.author = author;
64
- item.description = description;
65
- item.summary = summary;
66
- item.pubDate = pubDate;
67
- item.author = mpName;
68
- item.link = itemLink;
69
-
70
- return item;
71
- });
41
+ const items = await Promise.all(feedData.feedItem.map((item) => finishArticleItem(ctx, item)));
72
42
 
73
43
  ctx.state.data = {
74
44
  title: feedData.feedTitle,
75
45
  description: feedData.feedDescription,
76
46
  link: url,
77
47
  image: feedData.feedImage,
48
+ icon: feedData.feedImage,
78
49
  item: items,
79
50
  };
80
51
  };
@@ -0,0 +1,60 @@
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 limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 10;
8
+
9
+ const rootUrl = 'https://dongke.yangtzeu.edu.cn';
10
+ const currentUrl = new URL(`${ctx.path.replace(/^\/dongke/, '') || '/yqzl/xyxw'}.htm`, rootUrl).href;
11
+
12
+ const { data: response } = await got(currentUrl);
13
+
14
+ const $ = cheerio.load(response);
15
+
16
+ let items = $('ul.list-item li a')
17
+ .slice(0, limit)
18
+ .toArray()
19
+ .map((item) => {
20
+ item = $(item);
21
+
22
+ return {
23
+ title: item.text(),
24
+ link: new URL(item.prop('href'), rootUrl).href,
25
+ };
26
+ });
27
+
28
+ items = await Promise.all(
29
+ items.map((item) =>
30
+ ctx.cache.tryGet(item.link, async () => {
31
+ const { data: detailResponse } = await got(item.link);
32
+
33
+ const content = cheerio.load(detailResponse);
34
+
35
+ item.title = content('title').text();
36
+ item.description = content('div.v_news_content').html();
37
+ item.category = content('meta[name="keywords"]').prop('content').split(',');
38
+ item.pubDate = timezone(
39
+ parseDate(
40
+ content('p.content-info')
41
+ .text()
42
+ .match(/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/)[1]
43
+ ),
44
+ +8
45
+ );
46
+
47
+ return item;
48
+ })
49
+ )
50
+ );
51
+
52
+ ctx.state.data = {
53
+ item: items,
54
+ title: $('title').text(),
55
+ link: currentUrl,
56
+ language: 'zh-cn',
57
+ image: new URL($('#head-img a img').prop('src'), rootUrl).href,
58
+ author: '长江大学动物科学学院',
59
+ };
60
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/dongke/:path+': ['nczitzk'],
3
+ };
@@ -0,0 +1,18 @@
1
+ module.exports = {
2
+ 'yangtzeu.edu.cn': {
3
+ _name: '长江大学',
4
+ '.': [
5
+ {
6
+ title: '动物科学学院',
7
+ docs: 'https://docs.rsshub.app/universities.html#chang-jiang-da-xue-dong-wu-ke-xue-xue-yuan',
8
+ source: ['/:category', '/'],
9
+ target: (params, url) => {
10
+ url = new URL(url);
11
+ const path = /\.edu\.cn(.*?)\.htm/.test(url.href) ? url.href.match(/\.edu\.cn(.*?)\.htm/)[1] : '';
12
+
13
+ return `/yangtzeu/dongke${path}`;
14
+ },
15
+ },
16
+ ],
17
+ },
18
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = function (router) {
2
+ router.get(/dongke([\w-/]+)?/, require('./dongke'));
3
+ };
@@ -4,6 +4,7 @@ const date = require('@/utils/date');
4
4
  const timezone = require('@/utils/timezone');
5
5
  const { art } = require('@/utils/render');
6
6
  const path = require('path');
7
+ const { base32 } = require('rfc4648');
7
8
 
8
9
  const baseUrl = 'https://www.zaobao.com';
9
10
  const got_ins = got.extend({
@@ -35,22 +36,14 @@ const parseList = async (ctx, sectionUrl) => {
35
36
  data = $('.clearfix').find('.list-block');
36
37
  }
37
38
 
38
- const title = $('#breadcrumbs > a')
39
- .toArray()
40
- .reduce((acc, cV, cI) => {
41
- if (cI > 0) {
42
- return acc + '-' + $(cV).text();
43
- }
44
- return '';
45
- }, '');
39
+ const title = $('meta[property="og:title"]').attr('content');
40
+
46
41
  const resultList = await Promise.all(
47
- data.toArray().map(async (item) => {
42
+ data.toArray().map((item) => {
48
43
  const $item = $(item);
49
44
  // addBack: for HK version
50
45
  let link = $item.find('a').addBack('a')[0].attribs.href;
51
46
 
52
- let resultItem = {};
53
-
54
47
  if (link[0] !== '/') {
55
48
  // https://www.zaobao.com/interactive-graphics
56
49
  const title = $item.find('a').text();
@@ -71,31 +64,29 @@ const parseList = async (ctx, sectionUrl) => {
71
64
  pubDate = pubDate === dateString ? undefined : timezone(pubDate, +8);
72
65
  }
73
66
 
74
- resultItem = {
67
+ return {
75
68
  title,
76
69
  description: title,
77
70
  pubDate,
78
71
  link,
79
72
  };
80
- return Promise.resolve(resultItem);
81
- } else {
82
- link = baseUrl + link;
83
73
  }
84
74
 
85
- const value = await ctx.cache.get(link);
75
+ link = baseUrl + link;
86
76
 
87
- if (value) {
88
- resultItem = JSON.parse(value);
89
- } else {
77
+ return ctx.cache.tryGet(link, async () => {
90
78
  const article = await got_ins.get(link);
91
79
  const $1 = cheerio.load(article.data);
92
80
 
93
- let time = $1('.date-published', '.content').slice(0, 1).text().trim();
94
- if (!time) {
95
- // for HK version
96
- time = $1('.author-info').find('.mgt10').slice(0, 1).text().trim();
97
- }
98
- time = time.replace('年', '-').replace('月', '-').replace('日', '').replace('发布 /', '');
81
+ const time = (() => {
82
+ if ($1("head script[type='application/json']").text() !== '') {
83
+ // SG
84
+ return new Date(Number(JSON.parse($1("head script[type='application/json']").text())?.articleDetails?.created) * 1000);
85
+ } else {
86
+ // HK
87
+ return new Date(JSON.parse($1("head script[type='application/ld+json']").eq(1).text())?.datePublished);
88
+ }
89
+ })();
99
90
 
100
91
  $1('.overlay-microtransaction').remove();
101
92
  $1('#video-freemium-player').remove();
@@ -104,6 +95,7 @@ const parseList = async (ctx, sectionUrl) => {
104
95
  let articleBodyNode = $1('.article-content-rawhtml');
105
96
  if (articleBodyNode.length === 0) {
106
97
  // for HK version
98
+ orderContent($1('.article-body'));
107
99
  articleBodyNode = $1('.article-body');
108
100
  }
109
101
 
@@ -152,20 +144,17 @@ const parseList = async (ctx, sectionUrl) => {
152
144
  });
153
145
  }
154
146
 
155
- resultItem = {
147
+ return {
156
148
  // <- for SG version -> for HK version
157
149
  title: $1('h1', '.content').text().trim() || $1('h1.article-title').text(),
158
150
  description: art(path.join(__dirname, 'templates/zaobao.art'), {
159
151
  articleBody,
160
152
  imageDataArray,
161
153
  }),
162
- pubDate: timezone(time, +8), // zaobao seems always UTC+8
154
+ pubDate: time,
163
155
  link,
164
156
  };
165
- ctx.cache.set(link, JSON.stringify(resultItem));
166
- }
167
-
168
- return Promise.resolve(resultItem);
157
+ });
169
158
  })
170
159
  );
171
160
  return {
@@ -173,6 +162,24 @@ const parseList = async (ctx, sectionUrl) => {
173
162
  resultList,
174
163
  };
175
164
  };
165
+
166
+ const orderContent = (parent) => {
167
+ parent
168
+ .children()
169
+ .toArray()
170
+ .sort((a, b) => {
171
+ const index = Buffer.from(base32.parse('GM======')).toString(); // substring(3)
172
+ a = Buffer.from(base32.parse(parent.find(a).data('s').substring(index))).toString();
173
+ b = Buffer.from(base32.parse(parent.find(b).data('s').substring(index))).toString();
174
+ return a - b;
175
+ })
176
+ .forEach((e, i) => {
177
+ parent.find(e).attr('s', i);
178
+ parent.append(e);
179
+ });
180
+ };
181
+
176
182
  module.exports = {
177
183
  parseList,
184
+ orderContent,
178
185
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "rsshub",
3
- "version": "1.0.0-master.e03f0b8",
3
+ "version": "1.0.0-master.e046f52",
4
4
  "description": "Make RSS Great Again!",
5
5
  "keywords": [
6
6
  "RSS"
@@ -111,6 +111,7 @@
111
111
  "rand-user-agent": "1.0.109",
112
112
  "re2": "1.19.1",
113
113
  "require-all": "3.0.0",
114
+ "rfc4648": "1.5.2",
114
115
  "rss-parser": "3.13.0",
115
116
  "showdown": "2.1.0",
116
117
  "simplecc-wasm": "0.1.5",