rsshub 1.0.0-master.e09393e → 1.0.0-master.e0d44f2

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 (52) hide show
  1. package/README.md +2 -1
  2. package/lib/config.js +3 -0
  3. package/lib/router.js +23 -5
  4. package/lib/routes/caixin/latest.js +8 -4
  5. package/lib/routes/cctv/lm.js +78 -0
  6. package/lib/routes/curseforge/files.js +23 -39
  7. package/lib/routes/dbaplus/activity.js +35 -0
  8. package/lib/routes/douban/people/status.js +1 -1
  9. package/lib/routes/dsndsht23/index.js +13 -6
  10. package/lib/routes/dykszx/news.js +57 -0
  11. package/lib/routes/fashionnetwork/news.js +70 -0
  12. package/lib/routes/infzm/news.js +3 -1
  13. package/lib/routes/instagram/utils.js +5 -1
  14. package/lib/routes/odaily/activity.js +47 -0
  15. package/lib/routes/pixiv/bookmarks.js +2 -8
  16. package/lib/routes/pixiv/illustfollow.js +3 -8
  17. package/lib/routes/pixiv/ranking.js +2 -8
  18. package/lib/routes/pixiv/search.js +2 -8
  19. package/lib/routes/pixiv/user.js +2 -8
  20. package/lib/routes/pixiv/utils.js +17 -0
  21. package/lib/routes/questmobile/report.js +122 -0
  22. package/lib/routes/researchgate/publications.js +60 -0
  23. package/lib/routes/rss3/blog.js +47 -0
  24. package/lib/routes/twitter/developer-api/search.js +22 -0
  25. package/lib/routes/twitter/developer-api/user.js +29 -0
  26. package/lib/routes/twitter/keyword.js +5 -19
  27. package/lib/routes/twitter/media.js +7 -0
  28. package/lib/routes/twitter/user.js +4 -47
  29. package/lib/routes/twitter/utils.js +46 -23
  30. package/lib/routes/twitter/web-api/media.js +20 -0
  31. package/lib/routes/twitter/web-api/search.js +16 -0
  32. package/lib/routes/twitter/web-api/twitter-api.js +123 -0
  33. package/lib/routes/twitter/web-api/twitter-got.js +87 -0
  34. package/lib/routes/twitter/web-api/user.js +32 -0
  35. package/lib/routes/who/news.js +43 -0
  36. package/lib/v2/fisher-spb/maintainer.js +3 -0
  37. package/lib/v2/fisher-spb/news.js +49 -0
  38. package/lib/v2/fisher-spb/radar.js +13 -0
  39. package/lib/v2/fisher-spb/router.js +3 -0
  40. package/lib/v2/fisher-spb/templates/image.art +1 -0
  41. package/lib/v2/fisher-spb/templates/video.art +1 -0
  42. package/lib/v2/hotukdeals/index.js +34 -0
  43. package/lib/v2/hotukdeals/maintainer.js +3 -0
  44. package/lib/v2/hotukdeals/radar.js +31 -0
  45. package/lib/v2/hotukdeals/router.js +3 -0
  46. package/lib/v2/independent/maintainer.js +3 -0
  47. package/lib/v2/independent/ps5-stock-uk.js +27 -0
  48. package/lib/v2/independent/radar.js +13 -0
  49. package/lib/v2/independent/router.js +3 -0
  50. package/package.json +1 -1
  51. package/lib/routes/toutiao/today.js +0 -32
  52. package/lib/routes/toutiao/user.js +0 -38
package/README.md CHANGED
@@ -32,7 +32,7 @@ RSSHub 是一个开源、简单易用、易于扩展的 RSS 生成器,可以
32
32
  ### Special Sponsors
33
33
 
34
34
  <div>
35
- <a href="https://rss3.io/" target="_blank"><img height="60px" src="https://i.imgur.com/v7TF0jp.jpg"></a>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<a href="https://sa.net/" target="_blank"><img height="60px" src="https://i.imgur.com/3rM8nWI.png"></a>
35
+ <a href="https://rss3.io/" target="_blank"><img height="60px" src="https://i.imgur.com/v7TF0jp.jpg"></a>
36
36
  </div>
37
37
 
38
38
  ### Sponsors
@@ -85,6 +85,7 @@ You can support RSSHub via donations.
85
85
 
86
86
  Recurring donors will be rewarded via express issue response, or even have your name displayed on our GitHub page and website.
87
87
 
88
+ - Become a Sponser on [GitHub](https://github.com/sponsors/DIYgod)
88
89
  - Become a Sponser on [Patreon](https://www.patreon.com/DIYgod)
89
90
  - Become a Sponser on [爱发电](https://afdian.net/@diygod)
90
91
  - Contact us directly: i@diygod.me
package/lib/config.js CHANGED
@@ -55,6 +55,7 @@ const calculateValue = () => {
55
55
  bypassCdn: envs.PIXIV_BYPASS_CDN !== '0' && envs.PIXIV_BYPASS_CDN !== 'false',
56
56
  bypassCdnHostname: envs.PIXIV_BYPASS_HOSTNAME || 'public-api.secure.pixiv.net',
57
57
  bypassCdnDoh: envs.PIXIV_BYPASS_DOH || 'https://1.1.1.1/dns-query',
58
+ imgProxy: envs.PIXIV_IMG_PROXY || 'https://i.pixiv.cat',
58
59
  },
59
60
  fanbox: {
60
61
  session: envs.FANBOX_SESSION_ID,
@@ -66,6 +67,8 @@ const calculateValue = () => {
66
67
  consumer_key: envs.TWITTER_CONSUMER_KEY,
67
68
  consumer_secret: envs.TWITTER_CONSUMER_SECRET,
68
69
  tokens: twitter_tokens,
70
+ authorization: envs.TWITTER_WEBAPI_AUTHORIZAION || 'Bearer AAAAAAAAAAAAAAAAAAAAANRILgAAAAAAnNwIzUejRCOuH5E6I8xnZz4puTs%3D1Zv7ttfk8LF81IUq16cHjhLTvJu4FA33AGWWjCpTnA',
71
+ // 此处硬编码参考自https://github.com/mikf/gallery-dl/blob/master/gallery_dl/extractor/twitter.py#L550
69
72
  },
70
73
  youtube: {
71
74
  key: envs.YOUTUBE_KEY,
package/lib/router.js CHANGED
@@ -203,10 +203,6 @@ router.get('/dapenti/subject/:id', lazyloadRouteHandler('./routes/dapenti/subjec
203
203
  // Dockone
204
204
  router.get('/dockone/weekly', lazyloadRouteHandler('./routes/dockone/weekly'));
205
205
 
206
- // 开发者头条
207
- router.get('/toutiao/today', lazyloadRouteHandler('./routes/toutiao/today'));
208
- router.get('/toutiao/user/:id', lazyloadRouteHandler('./routes/toutiao/user'));
209
-
210
206
  // 众成翻译
211
207
  router.get('/zcfy', lazyloadRouteHandler('./routes/zcfy/index'));
212
208
  router.get('/zcfy/index', lazyloadRouteHandler('./routes/zcfy/index')); // 废弃
@@ -223,8 +219,9 @@ router.get('/twitter/user/:id/:routeParams?', lazyloadRouteHandler('./routes/twi
223
219
  router.get('/twitter/list/:id/:name/:routeParams?', lazyloadRouteHandler('./routes/twitter/list'));
224
220
  router.get('/twitter/likes/:id/:routeParams?', lazyloadRouteHandler('./routes/twitter/likes'));
225
221
  router.get('/twitter/followings/:id/:routeParams?', lazyloadRouteHandler('./routes/twitter/followings'));
226
- router.get('/twitter/keyword/:keyword/:routeParams?', lazyloadRouteHandler('./routes/twitter/keyword'));
222
+ router.get('/twitter/keyword/:keyword/:routeParams?/:limit?', lazyloadRouteHandler('./routes/twitter/keyword'));
227
223
  router.get('/twitter/trends/:woeid?', lazyloadRouteHandler('./routes/twitter/trends'));
224
+ router.get('/twitter/media/:id/:routeParams?', lazyloadRouteHandler('./routes/twitter/media'));
228
225
 
229
226
  // YouTube
230
227
  router.get('/youtube/user/:username/:embed?', lazyloadRouteHandler('./routes/youtube/user'));
@@ -371,6 +368,7 @@ router.get('/mihoyo/bh2/:type', lazyloadRouteHandler('./routes/mihoyo/bh2'));
371
368
  router.get('/cctv/xwlb', lazyloadRouteHandler('./routes/cctv/xwlb'));
372
369
 
373
370
  // 央视新闻
371
+ router.get('/cctv/lm/:id?', require('./routes/cctv/lm'));
374
372
  router.get('/cctv/:category', lazyloadRouteHandler('./routes/cctv/category'));
375
373
  router.get('/cctv/photo/jx', lazyloadRouteHandler('./routes/cctv/jx'));
376
374
  router.get('/cctv-special/:id?', lazyloadRouteHandler('./routes/cctv/special'));
@@ -1694,6 +1692,7 @@ router.get('/nintendo/system-update', lazyloadRouteHandler('./routes/nintendo/sy
1694
1692
 
1695
1693
  // 世界卫生组织
1696
1694
  router.get('/who/news-room/:type', lazyloadRouteHandler('./routes/who/news-room'));
1695
+ router.get('/who/news/:language?', require('./routes/who/news'));
1697
1696
 
1698
1697
  // 福利资源-met.red
1699
1698
  router.get('/metred/fuli', lazyloadRouteHandler('./routes/metred/fuli'));
@@ -4065,6 +4064,7 @@ router.get('/wainao-reads/all-articles', lazyloadRouteHandler('./routes/wainao/i
4065
4064
  router.get('/react/react-native-weekly', lazyloadRouteHandler('./routes/react/react-native-weekly'));
4066
4065
 
4067
4066
  // dbaplus 社群
4067
+ router.get('/dbaplus/activity/:type?', require('./routes/dbaplus/activity.js'));
4068
4068
  router.get('/dbaplus/:tab?', lazyloadRouteHandler('./routes/dbaplus/tab'));
4069
4069
 
4070
4070
  // 梨园
@@ -4211,4 +4211,22 @@ router.get('/s-hentai/:id?', lazyloadRouteHandler('./routes/s-hentai'));
4211
4211
 
4212
4212
  // Deprecated: DO NOT ADD ROUTE HERE
4213
4213
 
4214
+ // Research Gate
4215
+ router.get('/researchgate/publications/:id', require('./routes/researchgate/publications'));
4216
+
4217
+ // QuestMobile
4218
+ router.get('/questmobile/report/:category?/:label?', require('./routes/questmobile/report'));
4219
+
4220
+ // RSS3
4221
+ router.get('/rss3/blog', require('./routes/rss3/blog'));
4222
+
4223
+ // 星球日报
4224
+ router.get('/odaily/activity', require('./routes/odaily/activity'));
4225
+
4226
+ // Fashion Network
4227
+ router.get('/fashionnetwork/news/:sectors?/:categories?/:language?', require('./routes/fashionnetwork/news.js'));
4228
+
4229
+ // dykszx
4230
+ router.get('/dykszx/news/:type?', require('./routes/dykszx/news'));
4231
+
4214
4232
  module.exports = router;
@@ -1,10 +1,13 @@
1
1
  const got = require('@/utils/got');
2
2
  const cheerio = require('cheerio');
3
3
 
4
+ const { parseDate } = require('@/utils/parse-date');
5
+ const timezone = require('@/utils/timezone');
6
+
4
7
  module.exports = async (ctx) => {
5
8
  const li_r = await got({
6
9
  method: 'get',
7
- url: 'http://finance.caixin.com/2020-11-03/101622309.html',
10
+ url: 'https://www.caixin.com/2021-08-22/101758426.html',
8
11
  });
9
12
 
10
13
  const $ = cheerio.load(li_r.data);
@@ -13,7 +16,7 @@ module.exports = async (ctx) => {
13
16
  const tasks = [];
14
17
 
15
18
  list.map((_index, li) => $(li).find('a').first().attr('href'))
16
- .filter((_index, link) => link.indexOf('fm.caixin.com') === -1 && link.indexOf('video.caixin.com') === -1) // content filter
19
+ .filter((_index, link) => !link.includes('fm.caixin.com') && !link.includes('video.caixin.com') && !link.includes('datanews.caixin.com')) // content filter
17
20
  .each((_index, link) => {
18
21
  const entry = ctx.cache.tryGet(link, async () => {
19
22
  const entry_r = await got.get(link);
@@ -46,15 +49,16 @@ module.exports = async (ctx) => {
46
49
  desc = `<blockquote><p>${subhead}</p></blockquote><img src="${pic_url}" alt="${pic_alt}">${content}`;
47
50
  }
48
51
  // time
52
+ /*
49
53
  const [, year, month, day, hour, minute] = $('div#artInfo.artInfo')
50
54
  .text()
51
55
  .match(/(\d+)年(\d+)月(\d+)日 *(\d+):(\d+)/);
52
- const time = new Date(`${year}-${month}-${day}T${hour}:${minute}:00+0800`).toUTCString();
56
+ */
53
57
 
54
58
  return {
55
59
  title: h1,
56
60
  description: desc,
57
- pubDate: time,
61
+ pubDate: timezone(parseDate($('div#artInfo.artInfo').text(), 'YYYY年MM月DD日 HH:mm'), +8),
58
62
  link,
59
63
  };
60
64
  });
@@ -0,0 +1,78 @@
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.id || 'xwzk';
8
+
9
+ const rootUrl = 'https://tv.cctv.com';
10
+ const apiRootUrl = 'https://api.cntv.cn';
11
+ const vdnRootUrl = 'https://vdn.apps.cntv.cn';
12
+
13
+ const currentUrl = `${rootUrl}/lm/${id}/videoset`;
14
+
15
+ const titleResponse = await got({
16
+ method: 'get',
17
+ url: currentUrl,
18
+ });
19
+
20
+ const $ = cheerio.load(titleResponse.data);
21
+
22
+ const topId = titleResponse.data.match(/(TOPC\d{16})/)[1];
23
+ const apiUrl = `${apiRootUrl}/NewVideo/getVideoListByColumn?id=${topId}&n=20&sort=desc&p=1&mode=0&serviceId=tvcctv`;
24
+
25
+ const response = await got({
26
+ method: 'get',
27
+ url: apiUrl,
28
+ });
29
+
30
+ const list = response.data.data.list.map((item) => ({
31
+ url: item.url,
32
+ guid: item.guid,
33
+ image: item.image,
34
+ title: item.title,
35
+ pubDate: timezone(parseDate(item.time), +8),
36
+ link: `${vdnRootUrl}/api/getHttpVideoInfo.do?pid=${item.guid}`,
37
+ description: `<p>${item.brief.replace(/\r\n/g, '</p><p>')}</p>`,
38
+ }));
39
+
40
+ const items = await Promise.all(
41
+ list.map(
42
+ async (item) =>
43
+ await ctx.cache.tryGet(item.link, async () => {
44
+ const detailResponse = await got({
45
+ method: 'get',
46
+ url: item.link,
47
+ });
48
+ const data = detailResponse.data;
49
+
50
+ item.description += `<video src="${data.hls_url}" controls="controls" poster="${item.image}" width="100%"></video><br>`;
51
+
52
+ for (const c of data.video.chapters) {
53
+ item.description += `<video src="${c.url}" controls="controls" poster="${c.image}" width="100%"></video><br>`;
54
+ }
55
+
56
+ for (let i = 2; data.video[`chapters${i}`]; i++) {
57
+ for (const c of data.video[`chapters${i}`]) {
58
+ item.description += `<video src="${c.url}" controls="controls" poster="${c.image}" width="100%"></video><br>`;
59
+ }
60
+ }
61
+
62
+ item.link = item.url;
63
+
64
+ delete item.url;
65
+ delete item.image;
66
+
67
+ return item;
68
+ })
69
+ )
70
+ );
71
+
72
+ ctx.state.data = {
73
+ title: $('title').text(),
74
+ link: currentUrl,
75
+ item: items,
76
+ description: $('meta[name=description]').attr('content'),
77
+ };
78
+ };
@@ -1,47 +1,31 @@
1
1
  const got = require('@/utils/got');
2
- const cheerio = require('cheerio');
3
2
 
4
- const BASE_URL = 'https://minecraft.curseforge.com/';
3
+ const API_BASE_URL = 'https://addons-ecs.forgesvc.net/api/v2/addon';
5
4
 
6
5
  module.exports = async (ctx) => {
7
6
  const { project } = ctx.params;
8
- const projectLink = `${BASE_URL}/projects/${project}/files`;
9
- const projectFilesReq = await got.get(projectLink);
10
- const { data } = projectFilesReq;
11
- const $ = cheerio.load(data);
12
- const projectName = $('.project-title span').text();
13
- const reqs = $('.project-file-name-container > a')
14
- .get()
15
- .map(async (item) => {
16
- const el = $(item);
17
- const document = {};
18
- const link = el.attr('href');
19
- document.link = `${BASE_URL}${link}`;
20
- const cache = await ctx.cache.get(document.link);
21
-
22
- if (cache) {
23
- return JSON.parse(cache);
24
- }
25
-
26
- const itemReq = await got.get(document.link);
27
- const $item = cheerio.load(itemReq.data);
28
- const supportVersions = $item('.details-versions li')
29
- .get()
30
- .map((item) => $item(item).text())
31
- .join(', ');
32
- document.author = $item('.user-tag a').text();
33
- document.title = $item('.details-header > h3').text();
34
- document.description = `${projectName} 的 ${document.author} 发布了新的文件: ${document.title}. ` + `</br> 支持的版本为: ${supportVersions}`;
35
-
36
- document.pubDate = new Date(Number($item('.standard-datetime').attr('data-epoch')) * 1000).toUTCString();
37
- document.guid = $item('.md5').text();
38
-
39
- ctx.cache.set(document.link, JSON.stringify(document));
40
-
41
- return document;
42
- });
43
-
44
- const item = await Promise.all(reqs);
7
+
8
+ const projectAPILink = `${API_BASE_URL}/${project}`;
9
+ const projectFilesAPILink = `${projectAPILink}/files`;
10
+
11
+ const [projectDesc, projectFiles] = (await Promise.all([got.get(projectAPILink), got.get(projectFilesAPILink)])).map((resp) => resp.data);
12
+
13
+ const projectName = projectDesc.name;
14
+ const projectLink = projectDesc.websiteUrl;
15
+ const author = projectDesc.authors[0].name;
16
+
17
+ const item = projectFiles.map((file) => {
18
+ const doc = {};
19
+ doc.link = projectLink;
20
+ doc.author = author;
21
+ doc.title = file.displayName;
22
+ const supportVersions = file.gameVersion;
23
+
24
+ doc.description = `${projectName} 发布了新的文件: ${file.displayName}. </br> 支持的版本为: ${supportVersions}`;
25
+ doc.pubDate = new Date(file.fileDate).toUTCString();
26
+ doc.guid = file.id;
27
+ return doc;
28
+ });
45
29
 
46
30
  ctx.state.data = {
47
31
  title: `CurseForge 更新 - ${projectName}`,
@@ -0,0 +1,35 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const timezone = require('@/utils/timezone');
4
+
5
+ module.exports = async (ctx) => {
6
+ const type = ctx.params.type || 'online';
7
+
8
+ const rootUrl = 'https://dbaplus.cn';
9
+ const currentUrl = `${rootUrl}/activity-${type === 'online' ? '12' : '48'}-1.html`;
10
+ const response = await got({
11
+ method: 'get',
12
+ url: currentUrl,
13
+ });
14
+
15
+ const $ = cheerio.load(response.data);
16
+
17
+ const items = $('.media')
18
+ .map((_, item) => {
19
+ item = $(item);
20
+
21
+ return {
22
+ title: item.find('.media-heading').text(),
23
+ link: item.find('.pull-left').attr('href'),
24
+ description: `<img src="${item.find('.media-object').attr('src')}">`,
25
+ pubDate: timezone(new Date(item.find('.time').text().replace('时间:', '')), +8),
26
+ };
27
+ })
28
+ .get();
29
+
30
+ ctx.state.data = {
31
+ title: $('title').text().split(':')[0],
32
+ link: currentUrl,
33
+ item: items,
34
+ };
35
+ };
@@ -474,7 +474,7 @@ module.exports = async (ctx) => {
474
474
  const r = getContentByActivity(ctx, item);
475
475
  return {
476
476
  title: r.title,
477
- link: item.status.sharing_url,
477
+ link: item.status.sharing_url.replace(/\?_i=(.*)/, ''),
478
478
  pubDate: new Date(Date.parse(item.status.create_time + ' GMT+0800')).toUTCString(),
479
479
  description: r.description,
480
480
  };
@@ -92,18 +92,25 @@ module.exports = async (ctx) => {
92
92
  }
93
93
  const description = (postMessage.html() || '抓取原帖失败').replace(/ignore_js_op/g, 'div');
94
94
 
95
- const magnet = postMessage.find('div.blockcode li').text();
96
- const isMag = magnet.startsWith('magnet');
97
- const enclosureUrl = isMag ? magnet : url.resolve(host, postMessage.find('a[href^=forum\\.php\\?mod\\=attachment]:not([href$=nothumb\\=yes])').attr('href'));
98
-
99
95
  const single = {
100
96
  title,
101
97
  link: itemUrl,
102
98
  description,
103
99
  pubDate: new Date(date).toUTCString(),
104
- enclosure_url: enclosureUrl,
105
- enclosure_type: isMag ? 'application/x-bittorrent' : 'application/octet-stream',
106
100
  };
101
+ const magnet = postMessage.find('div.blockcode li').text();
102
+ const isMag = magnet.startsWith('magnet');
103
+ const torrent = postMessage.find('a[href^=forum\\.php\\?mod\\=attachment]:not([href$=nothumb\\=yes])').attr('href');
104
+
105
+ const hasEnclosureUrl = isMag || torrent !== undefined;
106
+ if (hasEnclosureUrl) {
107
+ const enclosureUrl = isMag ? magnet : url.resolve(host, torrent);
108
+ const enclosure = {
109
+ enclosure_url: enclosureUrl,
110
+ enclosure_type: isMag ? 'application/x-bittorrent' : 'application/octet-stream',
111
+ };
112
+ Object.assign(single, enclosure);
113
+ }
107
114
  if (description !== '抓取原帖失败') {
108
115
  ctx.cache.set(itemUrl, JSON.stringify(single));
109
116
  }
@@ -0,0 +1,57 @@
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 host = 'https://www.dykszx.com';
6
+
7
+ const getContent = (href, caches) => {
8
+ const newsPage = `${host}${href}`;
9
+ return caches.tryGet(newsPage, async () => {
10
+ const response = await got.get(newsPage);
11
+ const data = response.data;
12
+ const $ = cheerio.load(data);
13
+ const newsTime = $('body > div:nth-child(3) > div.page.w > div.shuxing.w')
14
+ .text()
15
+ .trim()
16
+ .match(/时间:(.*?)点击/g)[0];
17
+ // 移除二维码
18
+ $('.sjlook').remove();
19
+ const content = $('#show-body').html();
20
+ return { newsTime, content, newsPage };
21
+ });
22
+ };
23
+
24
+ const newsTypeObj = {
25
+ all: { selector: '#nrs > li > b', name: '新闻中心' },
26
+ gwy: { selector: 'body > div:nth-child(3) > div:nth-child(8) > ul > li', name: '公务员考试' },
27
+ sydw: { selector: 'body > div:nth-child(3) > div:nth-child(9) > ul > li', name: '事业单位考试' },
28
+ zyzc: { selector: 'body > div:nth-child(3) > div:nth-child(10) > ul > li', name: '执(职)业资格、职称考试' },
29
+ other: { selector: 'body > div:nth-child(3) > div:nth-child(11) > ul > li', name: '其他考试' },
30
+ };
31
+
32
+ module.exports = async (ctx) => {
33
+ const newsType = ctx.params.type || 'all';
34
+ const response = await got.get(host);
35
+ const data = response.data;
36
+ const $ = cheerio.load(data);
37
+ const newsList = $(newsTypeObj[newsType].selector).toArray();
38
+
39
+ const newsDetail = await Promise.all(
40
+ newsList.map(async (item) => {
41
+ const href = item.children[0].attribs.href;
42
+ const newsContent = await getContent(href, ctx.cache);
43
+ return {
44
+ title: item.children[0].children[0].data,
45
+ description: newsContent.content,
46
+ link: newsContent.newsPage,
47
+ pubDate: timezone(parseDate(newsContent.newsTime, '时间:YYYY-MM-DD HH:mm:ss'), +8),
48
+ };
49
+ })
50
+ );
51
+ ctx.state.data = {
52
+ title: `德阳人事考试网 - ${newsTypeObj[newsType].name}`,
53
+ link: host,
54
+ description: '德阳人事考试网 考试新闻发布',
55
+ item: newsDetail,
56
+ };
57
+ };
@@ -0,0 +1,70 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+
4
+ module.exports = async (ctx) => {
5
+ const country = ctx.params.country || 'ww';
6
+ let sectors = ctx.params.sectors || '';
7
+ let categories = ctx.params.categories || '';
8
+
9
+ sectors = sectors === 'all' ? '' : sectors;
10
+ categories = categories === 'all' ? '' : categories;
11
+
12
+ const sectorsUrl = sectors ? 'sectors%5B%5D=' + sectors.split(',').join('&sectors%5B%5D=') : '';
13
+ const categoriesUrl = categories ? 'categs%5B%5D=' + categories.split(',').join('&categs%5B%5D=') : '';
14
+
15
+ const rootUrl = `https://${country}.fashionnetwork.com`;
16
+ const currentUrl = `${rootUrl}/news/s.jsonp?${sectorsUrl}&${categoriesUrl}`;
17
+ const response = await got({
18
+ method: 'get',
19
+ url: currentUrl,
20
+ });
21
+
22
+ const $ = cheerio.load(
23
+ unescape(response.data.match(/"html":"(.*)","relatedUrl"/)[1].replace(/\\(u[0-9a-fA-F]{4})/gm, '%$1'))
24
+ .replace(/\\n/g, '')
25
+ .replace(/\\\//g, '/')
26
+ );
27
+
28
+ const list = $('.list-ui__title')
29
+ .slice(0, 10)
30
+ .map((_, item) => {
31
+ item = $(item);
32
+ return {
33
+ title: item.text(),
34
+ link: item.attr('href'),
35
+ pubDate: Date.parse(item.parent().find('time').attr('datetime')),
36
+ };
37
+ })
38
+ .get();
39
+
40
+ const items = await Promise.all(
41
+ list.map(
42
+ async (item) =>
43
+ await ctx.cache.tryGet(item.link, async () => {
44
+ const detailResponse = await got({
45
+ method: 'get',
46
+ url: item.link,
47
+ });
48
+ const content = cheerio.load(detailResponse.data);
49
+
50
+ content('.newsTitle, .ads').remove();
51
+
52
+ item.description = content('div[itemprop="text"]').html();
53
+
54
+ return item;
55
+ })
56
+ )
57
+ );
58
+
59
+ const labels = [];
60
+
61
+ $('.filter__label').each(function () {
62
+ labels.push($(this).text());
63
+ });
64
+
65
+ ctx.state.data = {
66
+ title: `${labels.join(',') || 'All'} - FashionNetwork`,
67
+ link: `${rootUrl}/news/s?${sectorsUrl}&${categoriesUrl}`,
68
+ item: items,
69
+ };
70
+ };
@@ -1,4 +1,5 @@
1
1
  const got = require('@/utils/got');
2
+ const timezone = require('@/utils/timezone');
2
3
  const cheerio = require('cheerio');
3
4
 
4
5
  const baseUrl = 'http://www.infzm.com/contents';
@@ -16,7 +17,8 @@ module.exports = async (ctx) => {
16
17
  const data = response.data.data;
17
18
  const resultItem = await Promise.all(
18
19
  data.contents.map(async ({ id, subject, author, publish_time }) => {
19
- const date = new Date(publish_time);
20
+ // the timezone is GMT+8
21
+ const date = timezone(publish_time, +8);
20
22
  const link = `http://www.infzm.com/contents/${id}`;
21
23
  let description = '';
22
24
 
@@ -8,7 +8,11 @@ async function login(ig) {
8
8
  if (process.env.IG_USERNAME && process.env.IG_PASSWORD) {
9
9
  try {
10
10
  ig.state.generateDevice(process.env.IG_USERNAME);
11
- await ig.simulate.preLoginFlow();
11
+ try {
12
+ await ig.simulate.preLoginFlow();
13
+ } catch (error) {
14
+ logger.info('Instagram preLoginFlow fail: ' + error);
15
+ }
12
16
  await ig.account.login(process.env.IG_USERNAME, process.env.IG_PASSWORD);
13
17
  process.nextTick(() => ig.simulate.postLoginFlow());
14
18
  logger.info('Instagram login success.');
@@ -0,0 +1,47 @@
1
+ const got = require('@/utils/got');
2
+ const cheerio = require('cheerio');
3
+ const timezone = require('@/utils/timezone');
4
+
5
+ module.exports = async (ctx) => {
6
+ const rootUrl = 'https://www.odaily.com';
7
+ const currentUrl = `${rootUrl}/service/scheme/group/8?page=1&per_page=10`;
8
+
9
+ const response = await got({
10
+ method: 'get',
11
+ url: currentUrl,
12
+ });
13
+
14
+ const list = response.data.data.items.data.map((item) => ({
15
+ title: item.title,
16
+ link: `${rootUrl}/activity/${item.id}`,
17
+ pubDate: timezone(new Date(item.published_at), +8),
18
+ }));
19
+
20
+ const items = await Promise.all(
21
+ list.map(
22
+ async (item) =>
23
+ await ctx.cache.tryGet(item.link, async () => {
24
+ const detailResponse = await got({
25
+ method: 'get',
26
+ url: item.link,
27
+ });
28
+
29
+ const content = cheerio.load(detailResponse.data.match(/"content":"(.*)"}},"secondaryList":/)[1]);
30
+
31
+ content('img').each(function () {
32
+ content(this).attr('src', content(this).attr('src').replace(/\\"/g, ''));
33
+ });
34
+
35
+ item.description = content.html();
36
+
37
+ return item;
38
+ })
39
+ )
40
+ );
41
+
42
+ ctx.state.data = {
43
+ title: '活动 - Odaily星球日报',
44
+ link: `${rootUrl}/activityPage`,
45
+ item: items,
46
+ };
47
+ };
@@ -2,6 +2,7 @@ const getToken = require('./token');
2
2
  const getBookmarks = require('./api/getBookmarks');
3
3
  const getUserDetail = require('./api/getUserDetail');
4
4
  const config = require('@/config').value;
5
+ const pixivUtils = require('./utils');
5
6
 
6
7
  module.exports = async (ctx) => {
7
8
  if (!config.pixiv || !config.pixiv.refreshToken) {
@@ -25,14 +26,7 @@ module.exports = async (ctx) => {
25
26
  link: `https://www.pixiv.net/users/${id}/bookmarks/artworks`,
26
27
  description: `${username} 的 pixiv 最新收藏`,
27
28
  item: illusts.map((illust) => {
28
- const images = [];
29
- if (illust.page_count === 1) {
30
- images.push(`<p><img src='https://pixiv.cat/${illust.id}.jpg'/></p>`);
31
- } else {
32
- for (let i = 0; i < illust.page_count; i++) {
33
- images.push(`<p><img src='https://pixiv.cat/${illust.id}-${i + 1}.jpg'/></p>`);
34
- }
35
- }
29
+ const images = pixivUtils.getImgs(illust);
36
30
  return {
37
31
  title: illust.title,
38
32
  author: illust.user.name,
@@ -1,6 +1,8 @@
1
1
  const getToken = require('./token');
2
2
  const getIllustFollows = require('./api/getIllustFollows');
3
3
  const config = require('@/config').value;
4
+ const pixivUtils = require('./utils');
5
+
4
6
  module.exports = async (ctx) => {
5
7
  if (!config.pixiv || !config.pixiv.refreshToken) {
6
8
  throw 'pixiv RSS is disabled due to the lack of <a href="https://docs.rsshub.app/install/#%E9%83%A8%E5%88%86-rss-%E6%A8%A1%E5%9D%97%E9%85%8D%E7%BD%AE">relevant config</a>';
@@ -18,14 +20,7 @@ module.exports = async (ctx) => {
18
20
  link: 'https://www.pixiv.net/bookmark_new_illust.php',
19
21
  description: `Pixiv关注的画师们的最新作品`,
20
22
  item: illusts.map((illust) => {
21
- const images = [];
22
- if (illust.page_count === 1) {
23
- images.push(`<p><img src='https://pixiv.cat/${illust.id}.jpg'/></p>`);
24
- } else {
25
- for (let i = 0; i < illust.page_count; i++) {
26
- images.push(`<p><img src='https://pixiv.cat/${illust.id}-${i + 1}.jpg'/></p>`);
27
- }
28
- }
23
+ const images = pixivUtils.getImgs(illust);
29
24
  return {
30
25
  title: illust.title,
31
26
  author: illust.user.name,
@@ -1,6 +1,7 @@
1
1
  const getToken = require('./token');
2
2
  const getRanking = require('./api/getRanking');
3
3
  const config = require('@/config').value;
4
+ const pixivUtils = require('./utils');
4
5
 
5
6
  const titles = {
6
7
  day: 'pixiv 日排行',
@@ -71,14 +72,7 @@ module.exports = async (ctx) => {
71
72
  link: links[mode],
72
73
  description: dateStr + titles[mode],
73
74
  item: illusts.map((illust, index) => {
74
- const images = [];
75
- if (illust.page_count === 1) {
76
- images.push(`<p><img src="https://pixiv.cat/${illust.id}.jpg"/></p>`);
77
- } else {
78
- for (let i = 0; i < illust.page_count; i++) {
79
- images.push(`<p><img src="https://pixiv.cat/${illust.id}-${i + 1}.jpg"/></p>`);
80
- }
81
- }
75
+ const images = pixivUtils.getImgs(illust);
82
76
  return {
83
77
  title: `#${index + 1} ${illust.title}`,
84
78
  pubDate: new Date(illust.create_date).toUTCString(),