rsshub 1.0.0-master.b08045c → 1.0.0-master.b08abca

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 (298) hide show
  1. package/README.md +2 -2
  2. package/lib/app.js +2 -2
  3. package/lib/config.js +1 -0
  4. package/lib/radar-rules.js +0 -17
  5. package/lib/radar.js +1 -1
  6. package/lib/router.js +26 -29
  7. package/lib/utils/logger.js +14 -2
  8. package/lib/v2/8264/list.js +92 -0
  9. package/lib/v2/8264/maintainer.js +3 -0
  10. package/lib/v2/8264/radar.js +355 -0
  11. package/lib/v2/8264/router.js +3 -0
  12. package/lib/v2/8264/templates/description.art +5 -0
  13. package/lib/v2/abskoop/index.js +21 -31
  14. package/lib/v2/abskoop/nsfw.js +16 -37
  15. package/lib/v2/abskoop/radar.js +13 -2
  16. package/lib/v2/ainvest/article.js +42 -0
  17. package/lib/v2/ainvest/maintainer.js +4 -0
  18. package/lib/v2/ainvest/news.js +39 -0
  19. package/lib/v2/ainvest/radar.js +19 -0
  20. package/lib/v2/ainvest/router.js +4 -0
  21. package/lib/v2/ainvest/utils.js +73 -0
  22. package/lib/v2/alternativeto/maintainer.js +4 -0
  23. package/lib/v2/alternativeto/platform.js +32 -0
  24. package/lib/v2/alternativeto/radar.js +19 -0
  25. package/lib/v2/alternativeto/router.js +4 -0
  26. package/lib/v2/alternativeto/software.js +32 -0
  27. package/lib/v2/alternativeto/utils.js +22 -0
  28. package/lib/v2/apnews/topics.js +1 -0
  29. package/lib/v2/baidu/maintainer.js +1 -0
  30. package/lib/v2/baidu/radar.js +15 -1
  31. package/lib/v2/baidu/router.js +1 -0
  32. package/lib/v2/baidu/templates/tieba_search.art +1 -0
  33. package/lib/v2/baidu/tieba/search.js +63 -0
  34. package/lib/v2/bangumi/maintainer.js +1 -0
  35. package/lib/v2/bangumi/radar.js +9 -9
  36. package/lib/v2/bangumi/router.js +1 -2
  37. package/lib/v2/bangumi/tv/subject/ep.js +4 -3
  38. package/lib/v2/bangumi/tv/subject/index.js +18 -16
  39. package/lib/v2/bangumi/tv/subject/offcial-subject-api.js +3 -2
  40. package/lib/v2/bangumi/tv/subject/utils.js +5 -0
  41. package/lib/{routes → v2}/bbc/index.js +4 -4
  42. package/lib/v2/bbc/maintainer.js +4 -0
  43. package/lib/v2/bbc/radar.js +11 -0
  44. package/lib/v2/bbc/router.js +3 -0
  45. package/lib/v2/bilibili/dynamic.js +26 -12
  46. package/lib/v2/bilibili/followings_dynamic.js +1 -1
  47. package/lib/v2/bilibili/maintainer.js +2 -1
  48. package/lib/v2/bilibili/router.js +1 -0
  49. package/lib/v2/bilibili/utils.js +3 -1
  50. package/lib/v2/bilibili/watchlater.js +44 -0
  51. package/lib/v2/bjfu/grs.js +22 -36
  52. package/lib/v2/bjfu/it/index.js +9 -7
  53. package/lib/v2/bjfu/it/utils.js +38 -29
  54. package/lib/v2/bjfu/jwc/index.js +3 -8
  55. package/lib/v2/bjfu/jwc/utils.js +26 -29
  56. package/lib/v2/bjfu/kjc.js +25 -38
  57. package/lib/v2/bjfu/news/index.js +12 -9
  58. package/lib/v2/bjfu/news/utils.js +17 -19
  59. package/lib/v2/boc/maintainer.js +3 -0
  60. package/lib/v2/boc/radar.js +13 -0
  61. package/lib/v2/boc/router.js +3 -0
  62. package/lib/{routes → v2}/boc/whpj.js +16 -15
  63. package/lib/{routes → v2}/caus/index.js +7 -6
  64. package/lib/v2/caus/maintainer.js +3 -0
  65. package/lib/v2/caus/radar.js +13 -0
  66. package/lib/v2/caus/router.js +3 -0
  67. package/lib/v2/cbc/maintainer.js +3 -0
  68. package/lib/v2/cbc/radar.js +13 -0
  69. package/lib/v2/cbc/router.js +3 -0
  70. package/lib/{routes → v2}/cbc/topics.js +11 -26
  71. package/lib/v2/chinawriter/index.js +88 -0
  72. package/lib/v2/chinawriter/maintainer.js +3 -0
  73. package/lib/v2/chinawriter/radar.js +660 -0
  74. package/lib/v2/chinawriter/router.js +3 -0
  75. package/lib/v2/cna/index.js +63 -0
  76. package/lib/v2/cna/maintainer.js +3 -0
  77. package/lib/v2/cna/radar.js +13 -0
  78. package/lib/v2/cna/router.js +3 -0
  79. package/lib/v2/cyzone/author.js +20 -0
  80. package/lib/v2/cyzone/index.js +27 -0
  81. package/lib/v2/cyzone/label.js +20 -0
  82. package/lib/v2/cyzone/maintainer.js +7 -0
  83. package/lib/v2/cyzone/radar.js +25 -0
  84. package/lib/v2/cyzone/router.js +6 -0
  85. package/lib/v2/cyzone/util.js +125 -0
  86. package/lib/v2/deltaio/blog.js +33 -0
  87. package/lib/v2/deltaio/maintainer.js +3 -0
  88. package/lib/v2/deltaio/radar.js +13 -0
  89. package/lib/v2/deltaio/router.js +3 -0
  90. package/lib/v2/discourse/maintainer.js +1 -1
  91. package/lib/v2/discourse/notifications.js +19 -2
  92. package/lib/v2/discourse/router.js +1 -1
  93. package/lib/v2/discuz/discuz.js +156 -0
  94. package/lib/v2/discuz/maintainer.js +5 -0
  95. package/lib/v2/discuz/radar.js +0 -0
  96. package/lib/v2/discuz/router.js +5 -0
  97. package/lib/v2/dn/maintainer.js +3 -0
  98. package/lib/v2/dn/news.js +90 -0
  99. package/lib/v2/dn/radar.js +55 -0
  100. package/lib/v2/dn/router.js +3 -0
  101. package/lib/v2/dn/templates/description.art +15 -0
  102. package/lib/v2/domp4/detail.js +4 -2
  103. package/lib/v2/domp4/latest.js +7 -4
  104. package/lib/v2/domp4/utils.js +15 -2
  105. package/lib/v2/dorohedoro/news.js +3 -1
  106. package/lib/v2/douyin/live.js +45 -15
  107. package/lib/v2/dribbble/maintainer.js +5 -0
  108. package/lib/v2/dribbble/radar.js +25 -0
  109. package/lib/v2/dribbble/router.js +5 -0
  110. package/lib/v2/dribbble/templates/description.art +15 -0
  111. package/lib/v2/dribbble/utils.js +156 -0
  112. package/lib/v2/fantia/user.js +16 -0
  113. package/lib/v2/gamegene/maintainer.js +3 -0
  114. package/lib/v2/gamegene/news.js +50 -0
  115. package/lib/v2/gamegene/radar.js +13 -0
  116. package/lib/v2/gamegene/router.js +3 -0
  117. package/lib/v2/github/maintainer.js +1 -0
  118. package/lib/v2/github/pulse.js +87 -0
  119. package/lib/v2/github/radar.js +6 -0
  120. package/lib/v2/github/router.js +1 -0
  121. package/lib/v2/github/templates/pulse-description.art +24 -0
  122. package/lib/v2/gov/maintainer.js +1 -0
  123. package/lib/v2/gov/radar.js +8 -0
  124. package/lib/v2/gov/router.js +1 -0
  125. package/lib/v2/gov/shenzhen/zjj/index.js +45 -0
  126. package/lib/v2/hrbeu/radar.js +3 -3
  127. package/lib/v2/hrbeu/router.js +1 -1
  128. package/lib/v2/hrbeu/uae/news.js +66 -0
  129. package/lib/v2/icbc/maintainer.js +3 -0
  130. package/lib/v2/icbc/radar.js +13 -0
  131. package/lib/v2/icbc/router.js +3 -0
  132. package/lib/v2/icbc/whpj.js +57 -0
  133. package/lib/v2/iqiyi/maintainer.js +1 -1
  134. package/lib/v2/iqiyi/video.js +42 -33
  135. package/lib/v2/ithome/tag.js +14 -3
  136. package/lib/v2/japanpost/maintainer.js +3 -0
  137. package/lib/v2/japanpost/radar.js +22 -0
  138. package/lib/v2/japanpost/router.js +3 -0
  139. package/lib/v2/japanpost/templates/track_item_desc.art +14 -0
  140. package/lib/{routes → v2}/japanpost/track.js +32 -29
  141. package/lib/{routes → v2}/japanpost/utils.js +10 -11
  142. package/lib/v2/kamen-rider-official/maintainer.js +3 -0
  143. package/lib/v2/kamen-rider-official/news.js +110 -0
  144. package/lib/v2/kamen-rider-official/radar.js +18 -0
  145. package/lib/v2/kamen-rider-official/router.js +3 -0
  146. package/lib/v2/kamen-rider-official/templates/description.art +10 -0
  147. package/lib/v2/kantarworldpanel/index.js +96 -0
  148. package/lib/v2/kantarworldpanel/maintainer.js +3 -0
  149. package/lib/v2/kantarworldpanel/radar.js +199 -0
  150. package/lib/v2/kantarworldpanel/router.js +3 -0
  151. package/lib/v2/kantarworldpanel/templates/description.art +9 -0
  152. package/lib/v2/kunchengblog/essay.js +35 -19
  153. package/lib/v2/kunchengblog/radar.js +1 -1
  154. package/lib/v2/kunchengblog/router.js +1 -1
  155. package/lib/v2/latepost/index.js +2 -2
  156. package/lib/v2/latepost/radar.js +1 -1
  157. package/lib/v2/lemmy/index.js +61 -0
  158. package/lib/v2/lemmy/maintainer.js +3 -0
  159. package/lib/v2/lemmy/router.js +3 -0
  160. package/lib/v2/liulinblog/index.js +98 -0
  161. package/lib/v2/liulinblog/maintainer.js +6 -2
  162. package/lib/v2/liulinblog/radar.js +39 -19
  163. package/lib/v2/liulinblog/router.js +7 -3
  164. package/lib/v2/lsnu/jiaowc/tzgg.js +52 -0
  165. package/lib/v2/lsnu/maintainer.js +3 -0
  166. package/lib/v2/lsnu/radar.js +13 -0
  167. package/lib/v2/lsnu/router.js +3 -0
  168. package/lib/v2/luxiangdong/archive.js +28 -0
  169. package/lib/v2/luxiangdong/maintainer.js +3 -0
  170. package/lib/v2/luxiangdong/radar.js +13 -0
  171. package/lib/v2/luxiangdong/router.js +3 -0
  172. package/lib/v2/mail/imap.js +99 -0
  173. package/lib/v2/mail/maintainer.js +3 -0
  174. package/lib/v2/mail/router.js +3 -0
  175. package/lib/v2/mihoyo/bbs/img-ranking.js +106 -0
  176. package/lib/v2/mihoyo/{bbs.js → bbs/official.js} +1 -1
  177. package/lib/v2/mihoyo/bbs/static-data.js +137 -0
  178. package/lib/v2/mihoyo/maintainer.js +1 -0
  179. package/lib/v2/mihoyo/radar.js +7 -1
  180. package/lib/v2/mihoyo/router.js +2 -1
  181. package/lib/v2/mixcloud/index.js +5 -22
  182. package/lib/v2/mixcloud/queries.js +187 -179
  183. package/lib/v2/mydrivers/cid.js +38 -0
  184. package/lib/v2/mydrivers/index.js +40 -89
  185. package/lib/v2/mydrivers/maintainer.js +5 -1
  186. package/lib/v2/mydrivers/radar.js +205 -4
  187. package/lib/v2/mydrivers/rank.js +40 -0
  188. package/lib/v2/mydrivers/router.js +4 -1
  189. package/lib/v2/mydrivers/templates/description.art +5 -0
  190. package/lib/v2/mydrivers/util.js +125 -0
  191. package/lib/v2/news/whxw.js +1 -0
  192. package/lib/v2/nytimes/index.js +1 -4
  193. package/lib/v2/nytimes/utils.js +5 -0
  194. package/lib/v2/pornhub/category.js +44 -0
  195. package/lib/v2/pornhub/category_url.js +25 -0
  196. package/lib/v2/pornhub/maintainer.js +8 -0
  197. package/lib/v2/pornhub/model.js +29 -0
  198. package/lib/v2/pornhub/pornstar.js +29 -0
  199. package/lib/v2/pornhub/radar.js +46 -0
  200. package/lib/v2/pornhub/router.js +8 -0
  201. package/lib/v2/pornhub/search.js +23 -0
  202. package/lib/v2/pornhub/templates/description.art +11 -0
  203. package/lib/v2/pornhub/users.js +30 -0
  204. package/lib/v2/pornhub/utils.js +30 -0
  205. package/lib/v2/reuters/common.js +52 -26
  206. package/lib/v2/rfi/maintainer.js +1 -1
  207. package/lib/v2/rfi/news.js +9 -2
  208. package/lib/v2/rfi/router.js +1 -1
  209. package/lib/v2/rsc/journal.js +106 -0
  210. package/lib/v2/rsc/maintainer.js +3 -0
  211. package/lib/v2/rsc/radar.js +23 -0
  212. package/lib/v2/rsc/router.js +3 -0
  213. package/lib/v2/rsc/templates/image.art +5 -0
  214. package/lib/v2/rsshub/maintainer.js +1 -0
  215. package/lib/v2/rsshub/router.js +1 -0
  216. package/lib/v2/rsshub/routes.js +6 -4
  217. package/lib/v2/rsshub/transform/html.js +9 -0
  218. package/lib/v2/rsshub/transform/json.js +1 -0
  219. package/lib/v2/rsshub/transform/sitemap.js +52 -0
  220. package/lib/v2/scut/maintainer.js +1 -0
  221. package/lib/v2/scut/radar.js +34 -0
  222. package/lib/v2/scut/router.js +1 -0
  223. package/lib/v2/scut/smae/notice.js +54 -0
  224. package/lib/v2/sqmc/maintainer.js +3 -0
  225. package/lib/v2/sqmc/radar.js +13 -0
  226. package/lib/v2/sqmc/router.js +3 -0
  227. package/lib/v2/sqmc/www.js +49 -0
  228. package/lib/v2/stheadline/std/realtime.js +8 -6
  229. package/lib/v2/stockedge/daily-news.js +1 -1
  230. package/lib/v2/stockedge/utils.js +1 -0
  231. package/lib/v2/test/index.js +1 -1
  232. package/lib/v2/tfc-taiwan/index.js +36 -0
  233. package/lib/v2/tfc-taiwan/maintainer.js +10 -0
  234. package/lib/v2/tfc-taiwan/radar.js +31 -0
  235. package/lib/v2/tfc-taiwan/router.js +7 -0
  236. package/lib/v2/tfc-taiwan/templates/article.art +7 -0
  237. package/lib/v2/tfc-taiwan/utils.js +56 -0
  238. package/lib/v2/thepaper/utils.js +1 -1
  239. package/lib/v2/toodaylab/index.js +99 -0
  240. package/lib/v2/toodaylab/maintainer.js +7 -0
  241. package/lib/v2/toodaylab/radar.js +37 -0
  242. package/lib/v2/toodaylab/router.js +3 -0
  243. package/lib/v2/udn/breaking-news.js +10 -5
  244. package/lib/v2/ustc/eeis.js +5 -4
  245. package/lib/v2/ustc/sist.js +6 -5
  246. package/lib/v2/v2ex/maintainer.js +5 -0
  247. package/lib/v2/v2ex/post.js +35 -0
  248. package/lib/v2/v2ex/radar.js +35 -0
  249. package/lib/v2/v2ex/router.js +5 -0
  250. package/lib/{routes → v2}/v2ex/tab.js +17 -21
  251. package/lib/{routes → v2}/v2ex/topics.js +1 -1
  252. package/lib/v2/whu/cs.js +71 -0
  253. package/lib/v2/whu/gs/index.js +85 -0
  254. package/lib/v2/whu/maintainer.js +5 -0
  255. package/lib/v2/whu/news.js +102 -0
  256. package/lib/v2/whu/radar.js +27 -0
  257. package/lib/v2/whu/router.js +5 -0
  258. package/lib/v2/xinpianchang/index.js +19 -0
  259. package/lib/v2/xinpianchang/maintainer.js +4 -0
  260. package/lib/v2/xinpianchang/radar.js +28 -0
  261. package/lib/v2/xinpianchang/rank.js +33 -0
  262. package/lib/v2/xinpianchang/router.js +5 -0
  263. package/lib/v2/xinpianchang/templates/description.art +13 -0
  264. package/lib/v2/xinpianchang/util.js +110 -0
  265. package/lib/v2/xmut/jwc/bkjw.js +62 -0
  266. package/lib/v2/xmut/jwc/yjs.js +51 -0
  267. package/lib/v2/xmut/maintainer.js +3 -0
  268. package/lib/v2/xmut/radar.js +13 -0
  269. package/lib/v2/xmut/router.js +4 -0
  270. package/lib/v2/zodgame/forum.js +61 -23
  271. package/lib/v2/zodgame/templates/forum.art +1 -1
  272. package/lib/views/welcome.art +1 -1
  273. package/package.json +46 -17
  274. package/lib/routes/cna/index.js +0 -54
  275. package/lib/routes/cyzone/author.js +0 -55
  276. package/lib/routes/cyzone/label.js +0 -53
  277. package/lib/routes/discuz/discuz.js +0 -148
  278. package/lib/routes/dribbble/utils.js +0 -94
  279. package/lib/routes/kkj/news.js +0 -52
  280. package/lib/routes/mail/imap.js +0 -79
  281. package/lib/routes/pornhub/category.js +0 -22
  282. package/lib/routes/pornhub/category_url.js +0 -34
  283. package/lib/routes/pornhub/model.js +0 -35
  284. package/lib/routes/pornhub/pornstar.js +0 -35
  285. package/lib/routes/pornhub/search.js +0 -22
  286. package/lib/routes/pornhub/users.js +0 -35
  287. package/lib/routes/universities/whu/cs.js +0 -38
  288. package/lib/routes/universities/whu/news.js +0 -128
  289. package/lib/routes/v2ex/post.js +0 -39
  290. package/lib/v2/abskoop/templates/description.art +0 -3
  291. package/lib/v2/hrbeu/uae/list.js +0 -57
  292. package/lib/v2/liulinblog/itnews.js +0 -23
  293. package/lib/v2/liulinblog/kuaixun.js +0 -17
  294. package/lib/v2/liulinblog/utils.js +0 -42
  295. /package/lib/{routes → v2}/bbc/utils.js +0 -0
  296. /package/lib/{routes → v2}/dribbble/keyword.js +0 -0
  297. /package/lib/{routes → v2}/dribbble/popular.js +0 -0
  298. /package/lib/{routes → v2}/dribbble/user.js +0 -0
@@ -1,16 +1,12 @@
1
1
  const got = require('@/utils/got');
2
2
  const cheerio = require('cheerio');
3
3
  const util = require('./utils');
4
- const iconv = require('iconv-lite'); // 转码
4
+ const iconv = require('iconv-lite');
5
5
 
6
6
  module.exports = async (ctx) => {
7
7
  const type = ctx.params.type;
8
8
  let title, path;
9
9
  switch (type) {
10
- case 'lsyw':
11
- title = '绿色要闻';
12
- path = 'lsyw/';
13
- break;
14
10
  case 'xydt':
15
11
  title = '校园动态';
16
12
  path = 'lsxy/';
@@ -27,6 +23,7 @@ module.exports = async (ctx) => {
27
23
  title = '一周排行';
28
24
  path = 'yzph/';
29
25
  break;
26
+ case 'lsyw':
30
27
  default:
31
28
  title = '绿色要闻';
32
29
  path = 'lsyw/';
@@ -35,14 +32,20 @@ module.exports = async (ctx) => {
35
32
 
36
33
  const response = await got({
37
34
  method: 'get',
38
- responseType: 'buffer', // 转码
35
+ responseType: 'buffer',
39
36
  url: base,
40
37
  });
41
38
 
42
- const data = iconv.decode(response.data, 'gb2312'); // 转码
43
- const $ = cheerio.load(data);
39
+ const data = response.data;
40
+ let $ = cheerio.load(iconv.decode(data, 'utf-8'));
41
+ const charset = $('meta[http-equiv="Content-Type"]')
42
+ .attr('content')
43
+ .match(/charset=(.*)/)?.[1];
44
+ if (charset?.toLowerCase() !== 'utf-8') {
45
+ $ = cheerio.load(iconv.decode(data, charset ?? 'utf-8'));
46
+ }
44
47
 
45
- const list = $('.news_ul li').slice(0, 10).get();
48
+ const list = $('.news_ul li').slice(0, 12).toArray();
46
49
 
47
50
  const result = await util.ProcessFeed(base, list, ctx.cache); // 感谢@hoilc指导
48
51
 
@@ -1,16 +1,13 @@
1
1
  const got = require('@/utils/got');
2
2
  const cheerio = require('cheerio');
3
- const iconv = require('iconv-lite'); // 转码
4
3
  const { parseDate } = require('@/utils/parse-date');
5
4
  const timezone = require('@/utils/timezone');
6
5
 
7
6
  // 完整文章页
8
7
  async function load(link) {
9
- const response = await got.get(link, {
10
- responseType: 'buffer',
11
- });
8
+ const response = await got.get(link);
12
9
 
13
- const data = iconv.decode(response.data, 'gb2312'); // 转码
10
+ const data = response.data; // 不用转码
14
11
 
15
12
  // 加载文章内容
16
13
  const $ = cheerio.load(data);
@@ -27,35 +24,36 @@ async function load(link) {
27
24
 
28
25
  // 提取内容
29
26
  const description = $('.article_con').html();
27
+ const title = $('h2').text();
30
28
 
31
29
  // 返回解析的结果
32
- return { description, pubDate };
30
+ return { description, pubDate, title };
33
31
  }
34
32
 
35
33
  const ProcessFeed = (base, list, caches) =>
36
34
  Promise.all(
37
35
  // 遍历每一篇文章
38
- list.map(async (item) => {
36
+ list.map((item) => {
39
37
  const $ = cheerio.load(item);
40
38
 
41
39
  const $title = $('a');
42
40
  // 还原相对链接为绝对链接
43
41
  const itemUrl = new URL($title.attr('href'), base).href; // 感谢@hoilc指导
44
42
 
45
- // 列表上提取到的信息
46
- const single = {
47
- title: $title.text(),
48
- link: itemUrl,
49
- author: '绿色新闻网',
50
- guid: itemUrl,
51
- };
52
-
53
43
  // 使用tryGet方法从缓存获取内容。
54
44
  // 当缓存中无法获取到链接内容的时候,则使用load方法加载文章内容。
55
- const other = await caches.tryGet(itemUrl, () => load(itemUrl));
56
-
57
- // 合并解析后的结果集作为该篇文章最终的输出结果
58
- return { ...single, ...other };
45
+ return caches.tryGet(itemUrl, async () => {
46
+ const { description, pubDate, title } = await load(itemUrl);
47
+
48
+ // 列表上提取到的信息
49
+ return {
50
+ title: $title.text().includes('...') ? title : $title.text(),
51
+ link: itemUrl,
52
+ author: '绿色新闻网',
53
+ description,
54
+ pubDate,
55
+ };
56
+ });
59
57
  })
60
58
  );
61
59
  module.exports = {
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/whpj/:format?': ['LogicJake', 'HenryQW'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'boc.cn': {
3
+ _name: '中国银行',
4
+ '.': [
5
+ {
6
+ title: '外汇牌价',
7
+ docs: 'https://docs.rsshub.app/routes/others#zhong-guo-yin-hang',
8
+ source: ['/sourcedb/whpj', '/'],
9
+ target: '/boc/whpj',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = (router) => {
2
+ router.get('/whpj/:format?', require('./whpj'));
3
+ };
@@ -2,8 +2,8 @@ const got = require('@/utils/got');
2
2
  const cheerio = require('cheerio');
3
3
 
4
4
  module.exports = async (ctx) => {
5
- const link = 'http://www.boc.cn/sourcedb/whpj/';
6
- const response = await got.get(link);
5
+ const link = 'https://www.boc.cn/sourcedb/whpj/';
6
+ const response = await got(link);
7
7
  const $ = cheerio.load(response.data);
8
8
 
9
9
  const format = ctx.params.format;
@@ -40,21 +40,23 @@ module.exports = async (ctx) => {
40
40
 
41
41
  const out = $('div.publish table tbody tr')
42
42
  .slice(2)
43
- .map(function () {
44
- const zh_name = $(this).find('td:nth-child(1)').text();
43
+ .toArray()
44
+ .map((e) => {
45
+ e = $(e);
46
+ const zh_name = e.find('td:nth-child(1)').text();
45
47
  const en_name = en_names[zh_name] || '';
46
- const name = `${zh_name} ${en_name} `;
47
- const date = `${$(this).find('td:nth-child(7)').text()} ${$(this).find('td:nth-child(8)').text()}`;
48
+ const name = `${zh_name} ${en_name}`;
49
+ const date = e.find('td:nth-child(7)').text();
48
50
 
49
- const xhmr = `现汇买入价:${$(this).find('td:nth-child(2)').text()}`;
51
+ const xhmr = `现汇买入价:${e.find('td:nth-child(2)').text()}`;
50
52
 
51
- const xcmr = `现钞买入价:${$(this).find('td:nth-child(3)').text()}`;
53
+ const xcmr = `现钞买入价:${e.find('td:nth-child(3)').text()}`;
52
54
 
53
- const xhmc = `现汇卖出价:${$(this).find('td:nth-child(4)').text()}`;
55
+ const xhmc = `现汇卖出价:${e.find('td:nth-child(4)').text()}`;
54
56
 
55
- const xcmc = `现钞卖出价:${$(this).find('td:nth-child(5)').text()}`;
57
+ const xcmc = `现钞卖出价:${e.find('td:nth-child(5)').text()}`;
56
58
 
57
- const zs = `中行折算价:${$(this).find('td:nth-child(6)').text()}`;
59
+ const zs = `中行折算价:${e.find('td:nth-child(6)').text()}`;
58
60
 
59
61
  const content = `${xhmr} ${xcmr} ${xhmc} ${xcmc} ${zs}`;
60
62
 
@@ -77,7 +79,7 @@ module.exports = async (ctx) => {
77
79
  case 'xcmc':
78
80
  return `${name} ${xcmc}`;
79
81
  default:
80
- return name + content;
82
+ return `${name} ${content}`;
81
83
  }
82
84
  };
83
85
 
@@ -85,11 +87,10 @@ module.exports = async (ctx) => {
85
87
  title: formatTitle(),
86
88
  description: content.replace(/\s/g, '<br>'),
87
89
  pubDate: new Date(date).toUTCString(),
88
- guid: name + date,
90
+ guid: `${name} ${content}`,
89
91
  };
90
92
  return info;
91
- })
92
- .get();
93
+ });
93
94
 
94
95
  ctx.state.data = {
95
96
  title: '中国银行外汇牌价',
@@ -17,9 +17,9 @@ const categories = {
17
17
  title: '快讯',
18
18
  link: 'hours?id=3',
19
19
  },
20
- 4: {
21
- title: '投资理财',
22
- link: 'CFT?id=4',
20
+ 8: {
21
+ title: '财富',
22
+ link: 'fortune?id=8',
23
23
  },
24
24
  6: {
25
25
  title: '生活',
@@ -59,8 +59,10 @@ module.exports = async (ctx) => {
59
59
 
60
60
  const list = (isHome ? response.data.data : response.data.data.articleList).map((item) => ({
61
61
  title: item.title,
62
- link: item.contentId,
62
+ link: `${rootUrl}/detail/${item.contentId}`,
63
+ contentId: item.contentId,
63
64
  pubDate: new Date(item.createTime),
65
+ category: [...new Set([...item.lanmus.map((lanmu) => lanmu.name), ...item.tags.map((tag) => tag.name)])],
64
66
  }));
65
67
 
66
68
  const items = await Promise.all(
@@ -68,10 +70,9 @@ module.exports = async (ctx) => {
68
70
  ctx.cache.tryGet(item.link, async () => {
69
71
  const detailResponse = await got({
70
72
  method: 'get',
71
- url: `${apiRootUrl}/toronto/display/contentWithRelate?contentId=${item.link}`,
73
+ url: `${apiRootUrl}/toronto/display/contentWithRelate?contentId=${item.contentId}`,
72
74
  });
73
75
 
74
- item.link = `${rootUrl}/detail/${item.link}`;
75
76
  item.description = detailResponse.data.data.content.content;
76
77
 
77
78
  return item;
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/:category?': ['nczitzk'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'caus.com': {
3
+ _name: '加美财经',
4
+ '.': [
5
+ {
6
+ title: '分类',
7
+ docs: 'https://docs.rsshub.app/routes/new-media#jia-mei-cai-jing',
8
+ source: ['/home', '/focus_news', '/hours', '/fortune', '/life'],
9
+ target: (_, url) => `/caus/${new URL(url).searchParams.get('id')}`,
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = (router) => {
2
+ router.get('/:category?', require('./index'));
3
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/topics/:topic?': ['wb14123'],
3
+ };
@@ -0,0 +1,13 @@
1
+ module.exports = {
2
+ 'cbc.ca': {
3
+ _name: 'Canadian Broadcasting Corporation',
4
+ '.': [
5
+ {
6
+ title: 'News',
7
+ docs: 'https://docs.rsshub.app/routes/traditional-media#canadian-broadcasting-corporation',
8
+ source: ['/news'],
9
+ target: '/cbc/topics',
10
+ },
11
+ ],
12
+ },
13
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = (router) => {
2
+ router.get('/topics/:topic?', require('./topics'));
3
+ };
@@ -4,12 +4,9 @@ const cheerio = require('cheerio');
4
4
  module.exports = async (ctx) => {
5
5
  const baseUrl = 'https://www.cbc.ca';
6
6
  const topic = ctx.params.topic || '';
7
- const url = `${baseUrl}/news/${topic.replace('-', '/')}`;
7
+ const url = `${baseUrl}/news${topic ? `/${topic.replace('-', '/')}` : ''}`;
8
8
 
9
- const response = await got({
10
- method: 'get',
11
- url,
12
- });
9
+ const response = await got(url);
13
10
 
14
11
  const data = response.data;
15
12
 
@@ -27,13 +24,13 @@ module.exports = async (ctx) => {
27
24
  $('a.card').each(pushLinks);
28
25
 
29
26
  const out = await Promise.all(
30
- links.map(async (link) => {
31
- const [title, author, pubDate, description] = await ctx.cache.tryGet(link, async () => {
32
- const result = await got.get(link);
27
+ links.map((link) =>
28
+ ctx.cache.tryGet(link, async () => {
29
+ const result = await got(link);
33
30
 
34
31
  const $ = cheerio.load(result.data);
35
32
 
36
- const head = JSON.parse($('script[type="application/ld+json"]').html());
33
+ const head = JSON.parse($('script[type="application/ld+json"]').first().text());
37
34
  if (!head) {
38
35
  return [];
39
36
  }
@@ -44,28 +41,16 @@ module.exports = async (ctx) => {
44
41
  author = head.author.map((author) => author.name).join(' & ');
45
42
  }
46
43
  const pubDate = head.datePublished;
47
- const description = $('div.storyWrapper').html();
44
+ const description = $('div[data-cy=storyWrapper]').html();
48
45
 
49
- return [title, author, pubDate, description];
50
- });
51
-
52
- if (!title) {
53
- return Promise.resolve(undefined);
54
- }
55
-
56
- return {
57
- title,
58
- description,
59
- pubDate,
60
- link,
61
- author,
62
- };
63
- })
46
+ return { title, author, pubDate, description, link };
47
+ })
48
+ )
64
49
  );
65
50
 
66
51
  ctx.state.data = {
67
52
  title: $('title').text(),
68
53
  link: url,
69
- item: out.filter((x) => x),
54
+ item: out.filter((x) => x.title),
70
55
  };
71
56
  };
@@ -0,0 +1,88 @@
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 { id } = ctx.params;
8
+ const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 40;
9
+
10
+ const rootUrl = 'http://www.chinawriter.com.cn';
11
+ const currentUrl = `${new URL(id ?? '', rootUrl).href}/`;
12
+
13
+ const { data: response } = await got(currentUrl);
14
+
15
+ const $ = cheerio.load(response);
16
+
17
+ let items = ($('main div.inner').find('a').length === 0 ? $('body') : $('main div.inner'))
18
+ .find('a')
19
+ .toArray()
20
+ .filter((item) => /\/\d{4}\/\d{4}\/\w+-\w+\.html/.test($(item).prop('href')))
21
+ .slice(0, limit)
22
+ .map((item) => {
23
+ item = $(item);
24
+
25
+ const link = item.prop('href');
26
+
27
+ return {
28
+ title: item.text(),
29
+ link: /^http/.test(link) ? link : new URL(item.prop('href'), rootUrl).href,
30
+ };
31
+ });
32
+
33
+ items = await Promise.all(
34
+ items.map((item) =>
35
+ ctx.cache.tryGet(item.link, async () => {
36
+ try {
37
+ const { data: detailResponse } = await got(item.link);
38
+
39
+ const content = cheerio.load(detailResponse);
40
+
41
+ content('div.end_shared').remove();
42
+
43
+ const info = content('div.end_info').text().trim();
44
+
45
+ item.title = content('#newstit').text() || content('h6.end_tit').text();
46
+ item.description = content('div.end_article').html();
47
+ item.author = info ? info.match(/\|(.*)\d{4}/)[1].trim() : '';
48
+ item.category = [
49
+ ...new Set(
50
+ [
51
+ ...content('div.location a.clink')
52
+ .slice(1)
53
+ .toArray()
54
+ .map((c) => content(c).text()),
55
+ info
56
+ ? info
57
+ .match(/^(.*)\|/)[1]
58
+ .replace(/来源:/g, '')
59
+ .trim()
60
+ : undefined,
61
+ ].filter(Boolean)
62
+ ),
63
+ ];
64
+ item.pubDate = content('div.end_info em').text() ? timezone(parseDate(content('div.end_info em').text(), 'YYYY年MM月DD日HH:mm'), +8) : parseDate(content('meta[name="publishdate"]').prop('content'));
65
+ } catch (e) {
66
+ //
67
+ }
68
+
69
+ return item;
70
+ })
71
+ )
72
+ );
73
+
74
+ const icon = new URL($('link[rel="icon"]').prop('href'), rootUrl);
75
+
76
+ ctx.state.data = {
77
+ item: items,
78
+ title: $('title').text().replace(/--/g, ' - '),
79
+ link: currentUrl,
80
+ description: $('meta[name="description"]').prop('content'),
81
+ language: 'zh-cn',
82
+ image: new URL($('h1.logo a img').prop('src'), rootUrl).href,
83
+ icon,
84
+ logo: icon,
85
+ subtitle: $('meta[name="keywords"]').prop('content'),
86
+ allowEmpty: true,
87
+ };
88
+ };
@@ -0,0 +1,3 @@
1
+ module.exports = {
2
+ '/:id?': ['nczitzk'],
3
+ };