rsshub 1.0.0-master.e52c829 → 1.0.0-master.e555c61
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.
- package/lib/config.js +2 -0
- package/lib/router.js +4 -3
- package/lib/routes/hopper/index.js +2 -2
- package/lib/utils/got.js +5 -1
- package/lib/utils/request-wrapper.js +53 -13
- package/lib/v2/2048/index.js +7 -5
- package/lib/v2/agefans/detail.js +20 -15
- package/lib/v2/agefans/radar.js +20 -17
- package/lib/v2/agefans/update.js +17 -8
- package/lib/v2/agefans/utils.js +5 -0
- package/lib/v2/aisixiang/column.js +22 -13
- package/lib/v2/aisixiang/maintainer.js +1 -0
- package/lib/v2/aisixiang/radar.js +6 -0
- package/lib/v2/aisixiang/router.js +1 -0
- package/lib/v2/aisixiang/thinktank.js +13 -13
- package/lib/v2/aisixiang/toplist.js +21 -15
- package/lib/v2/aisixiang/utils.js +16 -10
- package/lib/v2/aisixiang/zhuanti.js +45 -0
- package/lib/v2/apnews/topics.js +24 -29
- package/lib/v2/bilibili/followers.js +12 -1
- package/lib/v2/bilibili/followings.js +16 -1
- package/lib/v2/bilibili/maintainer.js +2 -2
- package/lib/v2/bilibili/router.js +2 -2
- package/lib/v2/blizzard/maintainer.js +3 -0
- package/lib/{routes → v2}/blizzard/news.js +14 -15
- package/lib/v2/blizzard/radar.js +13 -0
- package/lib/v2/blizzard/router.js +3 -0
- package/lib/v2/bloomberg/react-renderer.js +190 -0
- package/lib/v2/bloomberg/templates/chart_media.art +21 -0
- package/lib/v2/bloomberg/templates/image_figure.art +1 -1
- package/lib/v2/bloomberg/utils.js +41 -8
- package/lib/v2/cbaigui/index.js +100 -0
- package/lib/v2/cbaigui/maintainer.js +3 -0
- package/lib/v2/cbaigui/radar.js +18 -0
- package/lib/v2/cbaigui/router.js +3 -0
- package/lib/v2/cbaigui/templates/figure.art +3 -0
- package/lib/v2/cbaigui/utils.js +18 -0
- package/lib/v2/copymanga/comic.js +74 -58
- package/lib/v2/copymanga/templates/comic.art +1 -1
- package/lib/v2/dhu/maintainer.js +1 -0
- package/lib/v2/dhu/radar.js +6 -0
- package/lib/v2/dhu/router.js +1 -0
- package/lib/v2/dhu/yjs/news.js +47 -0
- package/lib/v2/gov/maintainer.js +2 -0
- package/lib/v2/gov/nrta/dsj.js +59 -0
- package/lib/v2/gov/radar.js +21 -0
- package/lib/v2/gov/router.js +2 -0
- package/lib/v2/gov/shanghai/wgj/templates/wgj.art +15 -0
- package/lib/v2/gov/shanghai/wgj/wgj.js +72 -0
- package/lib/v2/javdb/lists.js +28 -0
- package/lib/v2/javdb/maintainer.js +5 -4
- package/lib/v2/javdb/radar.js +6 -0
- package/lib/v2/javdb/router.js +5 -4
- package/lib/v2/javdb/search.js +9 -2
- package/lib/v2/javdb/utils.js +6 -5
- package/lib/v2/npr/full.js +89 -0
- package/lib/v2/npr/maintainer.js +3 -0
- package/lib/v2/npr/radar.js +11 -0
- package/lib/v2/npr/router.js +3 -0
- package/lib/v2/qidian/chapter.js +14 -18
- package/lib/v2/qidian/maintainer.js +2 -2
- package/lib/v2/sec-in/index.js +19 -0
- package/lib/v2/sec-in/maintainer.js +3 -0
- package/lib/v2/sec-in/radar.js +11 -0
- package/lib/v2/sec-in/router.js +3 -0
- package/lib/v2/sec-wiki/maintainer.js +3 -0
- package/lib/v2/sec-wiki/radar.js +11 -0
- package/lib/v2/sec-wiki/router.js +3 -0
- package/lib/v2/sec-wiki/weekly.js +16 -0
- package/lib/v2/shu/index.js +48 -0
- package/lib/v2/shu/jwb.js +45 -0
- package/lib/v2/shu/maintainer.js +4 -0
- package/lib/v2/shu/radar.js +21 -0
- package/lib/v2/shu/router.js +5 -0
- package/lib/v2/stheadline/std/realtime.js +1 -1
- package/lib/v2/twitter/utils.js +10 -4
- package/lib/v2/twitter/web-api/constants.js +6 -3
- package/lib/v2/twitter/web-api/twitter-api.js +14 -38
- package/lib/v2/twitter/web-api/twitter-got.js +11 -7
- package/lib/v2/v2rayshare/index.js +22 -0
- package/lib/v2/v2rayshare/maintainer.js +3 -0
- package/lib/v2/v2rayshare/radar.js +13 -0
- package/lib/v2/v2rayshare/router.js +3 -0
- package/lib/v2/wikinews/index.js +28 -29
- package/package.json +31 -25
- package/lib/routes/universities/shu/index.js +0 -75
- package/lib/routes/universities/shu/jwc.js +0 -62
package/lib/config.js
CHANGED
|
@@ -73,6 +73,8 @@ const calculateValue = () => {
|
|
|
73
73
|
auth: envs.PROXY_AUTH,
|
|
74
74
|
url_regex: envs.PROXY_URL_REGEX || '.*',
|
|
75
75
|
},
|
|
76
|
+
proxyStrategy: envs.PROXY_STRATEGY || 'all', // all / on_retry
|
|
77
|
+
reverseProxyUrl: envs.REVERSE_PROXY_URL,
|
|
76
78
|
// auth
|
|
77
79
|
authentication: {
|
|
78
80
|
name: envs.HTTP_BASIC_AUTH_NAME || 'usernam3',
|
package/lib/router.js
CHANGED
|
@@ -744,8 +744,9 @@ router.get('/zjut/:type', lazyloadRouteHandler('./routes/universities/zjut/index
|
|
|
744
744
|
router.get('/zjut/design/:type', lazyloadRouteHandler('./routes/universities/zjut/design'));
|
|
745
745
|
|
|
746
746
|
// 上海大学
|
|
747
|
-
router.get('/shu/:type?', lazyloadRouteHandler('./routes/universities/shu/index'));
|
|
748
|
-
router.get('/shu/jwc/:type?', lazyloadRouteHandler('./routes/universities/shu/jwc'));
|
|
747
|
+
// router.get('/shu/:type?', lazyloadRouteHandler('./routes/universities/shu/index'));
|
|
748
|
+
// router.get('/shu/jwc/:type?', lazyloadRouteHandler('./routes/universities/shu/jwc'));
|
|
749
|
+
// router.get('/shu/jwb/:type?', lazyloadRouteHandler('./routes/universities/shu/jwc'));
|
|
749
750
|
|
|
750
751
|
// 北京科技大学天津学院
|
|
751
752
|
// router.get('/ustb/tj/news/:type?', lazyloadRouteHandler('./routes/universities/ustb/tj/news'));
|
|
@@ -3408,7 +3409,7 @@ router.get('/rescuetime/release-notes/:os?', lazyloadRouteHandler('./routes/resc
|
|
|
3408
3409
|
router.get('/totalcommander/whatsnew', lazyloadRouteHandler('./routes/totalcommander/whatsnew'));
|
|
3409
3410
|
|
|
3410
3411
|
// Blizzard
|
|
3411
|
-
router.get('/blizzard/news/:language?/:category?', lazyloadRouteHandler('./routes/blizzard/news'));
|
|
3412
|
+
// router.get('/blizzard/news/:language?/:category?', lazyloadRouteHandler('./routes/blizzard/news'));
|
|
3412
3413
|
|
|
3413
3414
|
// DeepMind
|
|
3414
3415
|
// router.get('/deepmind/blog/:category?', lazyloadRouteHandler('./routes/deepmind/blog'));
|
|
@@ -72,8 +72,8 @@ const formatDesc = (e) => {
|
|
|
72
72
|
|
|
73
73
|
const description = `<table><tbody><tr><th align="left" style="border: 1px solid black;">From</th><th align="left" style="border: 1px solid black;">To</th><th align="left" style="border: 1px solid black;">Price</th></tr><tr><td style="border: 1px solid black;">
|
|
74
74
|
${origin}</td><td style="border: 1px solid black;">${destination}</td><td style="border: 1px solid black;">${price}</td></tr></tbody></table>${dayjs(departureDate).format('YYYY MMM DD')} ✈ ${dayjs(returnDate).format(
|
|
75
|
-
|
|
76
|
-
|
|
75
|
+
'YYYY MMM DD'
|
|
76
|
+
)}`;
|
|
77
77
|
return {
|
|
78
78
|
title,
|
|
79
79
|
description,
|
package/lib/utils/got.js
CHANGED
|
@@ -3,11 +3,15 @@ const config = require('@/config').value;
|
|
|
3
3
|
const got = require('got');
|
|
4
4
|
|
|
5
5
|
const custom = got.extend({
|
|
6
|
-
retry:
|
|
6
|
+
retry: {
|
|
7
|
+
limit: config.requestRetry,
|
|
8
|
+
statusCodes: [400, 401, 402, 403, 404, 405, 406, 407, 408, 409, 410, 411, 412, 413, 414, 415, 416, 417, 421, 422, 423, 424, 426, 428, 429, 431, 451, 500, 501, 502, 503, 504, 505, 506, 507, 508, 510, 511, 521, 522, 524],
|
|
9
|
+
},
|
|
7
10
|
hooks: {
|
|
8
11
|
beforeRetry: [
|
|
9
12
|
(options, err, count) => {
|
|
10
13
|
logger.error(`Request ${options.url} fail, retry attempt #${count}: ${err}`);
|
|
14
|
+
options.retryCount = count;
|
|
11
15
|
},
|
|
12
16
|
],
|
|
13
17
|
afterResponse: [
|
|
@@ -20,7 +20,13 @@ if (agent) {
|
|
|
20
20
|
const proxyRegex = new RegExp(proxyObj.url_regex);
|
|
21
21
|
const protocolMatch = (protocolLike) => protocolLike && protocolLike.toLowerCase().startsWith('http');
|
|
22
22
|
|
|
23
|
-
proxyWrapper = (url, options
|
|
23
|
+
proxyWrapper = (url, options) => {
|
|
24
|
+
let urlHandler;
|
|
25
|
+
try {
|
|
26
|
+
urlHandler = new URL(url);
|
|
27
|
+
} catch (error) {
|
|
28
|
+
// ignore
|
|
29
|
+
}
|
|
24
30
|
if (proxyRegex.test(url)) {
|
|
25
31
|
if ((protocolMatch(options.protocol) || protocolMatch(url)) && (!urlHandler || urlHandler.host !== proxyUrlHandler.host)) {
|
|
26
32
|
options.agent = agent;
|
|
@@ -32,40 +38,73 @@ if (agent) {
|
|
|
32
38
|
}
|
|
33
39
|
return false;
|
|
34
40
|
};
|
|
41
|
+
} else if (config.reverseProxyUrl) {
|
|
42
|
+
proxyWrapper = (url, options) => {
|
|
43
|
+
const urlIn = options.url?.toString() || url;
|
|
44
|
+
const proxyRegex = new RegExp(proxyObj.url_regex);
|
|
45
|
+
if (
|
|
46
|
+
proxyRegex.test(urlIn) &&
|
|
47
|
+
!urlIn.startsWith(config.reverseProxyUrl) &&
|
|
48
|
+
!options.cookieJar &&
|
|
49
|
+
!options.headers['user-agent']?.startsWith('PixivIOSApp') &&
|
|
50
|
+
!options.headers['x-goog-api-client'] &&
|
|
51
|
+
options.headers.accept !== 'application/dns-json'
|
|
52
|
+
) {
|
|
53
|
+
options.url = new URL(`${config.reverseProxyUrl}${encodeURIComponent(urlIn)}`);
|
|
54
|
+
|
|
55
|
+
return true;
|
|
56
|
+
}
|
|
57
|
+
return false;
|
|
58
|
+
};
|
|
35
59
|
}
|
|
36
60
|
|
|
37
|
-
const requestWrapper = (
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
} catch (error) {
|
|
42
|
-
// ignore
|
|
61
|
+
const requestWrapper = (
|
|
62
|
+
url,
|
|
63
|
+
options = {
|
|
64
|
+
headers: {},
|
|
43
65
|
}
|
|
66
|
+
) => {
|
|
44
67
|
options.headers = options.headers || {};
|
|
45
68
|
const headersLowerCaseKeys = Object.keys(options.headers).map((key) => key.toLowerCase());
|
|
46
69
|
|
|
47
|
-
|
|
70
|
+
let prxied = false;
|
|
71
|
+
if (config.proxyStrategy === 'all') {
|
|
72
|
+
prxied = proxyWrapper(url, options);
|
|
73
|
+
} else if (config.proxyStrategy === 'on_retry') {
|
|
74
|
+
if (options.retryCount) {
|
|
75
|
+
prxied = proxyWrapper(url, options);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
if (prxied) {
|
|
79
|
+
logger.debug(`Proxy for ${url}`);
|
|
80
|
+
} else {
|
|
81
|
+
logger.debug(`Requesting ${url}`);
|
|
82
|
+
}
|
|
48
83
|
|
|
49
84
|
// ua
|
|
50
85
|
if (!headersLowerCaseKeys.includes('user-agent')) {
|
|
51
86
|
options.headers['user-agent'] = config.ua;
|
|
52
87
|
}
|
|
53
88
|
|
|
89
|
+
let urlHandler;
|
|
90
|
+
try {
|
|
91
|
+
urlHandler = new URL(options.url || url);
|
|
92
|
+
} catch (error) {
|
|
93
|
+
// ignore
|
|
94
|
+
}
|
|
95
|
+
|
|
54
96
|
if (urlHandler) {
|
|
55
97
|
// referer
|
|
56
98
|
if (!headersLowerCaseKeys.includes('referer')) {
|
|
57
99
|
options.headers.referer = urlHandler.origin;
|
|
58
100
|
}
|
|
59
|
-
// host
|
|
60
|
-
if (!headersLowerCaseKeys.includes('host')) {
|
|
61
|
-
options.headers.host = urlHandler.host;
|
|
62
|
-
}
|
|
63
101
|
}
|
|
64
102
|
};
|
|
65
103
|
|
|
66
104
|
const httpWrap = (func) => {
|
|
67
105
|
const origin = func;
|
|
68
106
|
return function (url, request) {
|
|
107
|
+
const args = Array.prototype.slice.call(arguments);
|
|
69
108
|
if (typeof url === 'object') {
|
|
70
109
|
if (url instanceof URL) {
|
|
71
110
|
requestWrapper(url.toString(), request);
|
|
@@ -76,7 +115,8 @@ const httpWrap = (func) => {
|
|
|
76
115
|
} else {
|
|
77
116
|
requestWrapper(url, request);
|
|
78
117
|
}
|
|
79
|
-
|
|
118
|
+
args[0] = request?.url || url;
|
|
119
|
+
return origin.apply(this, args);
|
|
80
120
|
};
|
|
81
121
|
};
|
|
82
122
|
|
package/lib/v2/2048/index.js
CHANGED
|
@@ -17,6 +17,7 @@ module.exports = async (ctx) => {
|
|
|
17
17
|
});
|
|
18
18
|
|
|
19
19
|
const $ = cheerio.load(response.data);
|
|
20
|
+
const currentHost = `https://${new URL(response.url).host}`; // redirected host
|
|
20
21
|
|
|
21
22
|
$('#shortcut').remove();
|
|
22
23
|
$('tr[onmouseover="this.className=\'tr3 t_two\'"]').remove();
|
|
@@ -24,19 +25,20 @@ module.exports = async (ctx) => {
|
|
|
24
25
|
const list = $('#ajaxtable tbody .tr2')
|
|
25
26
|
.last()
|
|
26
27
|
.nextAll('.tr3')
|
|
27
|
-
.
|
|
28
|
+
.toArray()
|
|
29
|
+
.map((item) => {
|
|
28
30
|
item = $(item).find('.subject');
|
|
29
31
|
|
|
30
32
|
return {
|
|
31
33
|
title: item.text(),
|
|
32
|
-
link: `${
|
|
34
|
+
link: `${currentHost}/2048/${item.attr('href')}`,
|
|
35
|
+
guid: `${rootUrl}/2048/${item.attr('href')}`,
|
|
33
36
|
};
|
|
34
|
-
})
|
|
35
|
-
.get();
|
|
37
|
+
});
|
|
36
38
|
|
|
37
39
|
const items = await Promise.all(
|
|
38
40
|
list.map((item) =>
|
|
39
|
-
ctx.cache.tryGet(item.
|
|
41
|
+
ctx.cache.tryGet(item.guid, async () => {
|
|
40
42
|
const detailResponse = await got({
|
|
41
43
|
method: 'get',
|
|
42
44
|
url: item.link,
|
package/lib/v2/agefans/detail.js
CHANGED
|
@@ -1,26 +1,31 @@
|
|
|
1
1
|
const got = require('@/utils/got');
|
|
2
2
|
const cheerio = require('cheerio');
|
|
3
|
+
const { rootUrl } = require('./utils');
|
|
3
4
|
|
|
4
5
|
module.exports = async (ctx) => {
|
|
5
|
-
const response = await got(
|
|
6
|
+
const response = await got(`${rootUrl}/detail/${ctx.params.id}`);
|
|
6
7
|
const $ = cheerio.load(response.data);
|
|
7
8
|
|
|
8
|
-
const
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
.
|
|
12
|
-
.
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const ldJson = JSON.parse($('script[type="application/ld+json"]').text());
|
|
10
|
+
|
|
11
|
+
const items = $('.video_detail_episode')
|
|
12
|
+
.first()
|
|
13
|
+
.find('li')
|
|
14
|
+
.toArray()
|
|
15
|
+
.map((item) => {
|
|
16
|
+
item = $(item);
|
|
17
|
+
const a = item.find('a');
|
|
18
|
+
return {
|
|
19
|
+
title: a.text(),
|
|
20
|
+
link: a.attr('href').replace('http://', 'https://'),
|
|
21
|
+
};
|
|
22
|
+
})
|
|
23
|
+
.reverse();
|
|
19
24
|
|
|
20
25
|
ctx.state.data = {
|
|
21
|
-
title: `AGE动漫 - ${
|
|
22
|
-
link:
|
|
23
|
-
description:
|
|
26
|
+
title: `AGE动漫 - ${ldJson.name}`,
|
|
27
|
+
link: `${rootUrl}/detail/${ctx.params.id}`,
|
|
28
|
+
description: ldJson.description,
|
|
24
29
|
item: items,
|
|
25
30
|
};
|
|
26
31
|
};
|
package/lib/v2/agefans/radar.js
CHANGED
|
@@ -1,19 +1,22 @@
|
|
|
1
|
+
const ageFans = {
|
|
2
|
+
_name: 'AGE动漫',
|
|
3
|
+
'.': [
|
|
4
|
+
{
|
|
5
|
+
title: '最近更新',
|
|
6
|
+
docs: 'https://docs.rsshub.app/anime.html#age-dong-man',
|
|
7
|
+
source: ['/update', '/'],
|
|
8
|
+
target: '/agefans/update',
|
|
9
|
+
},
|
|
10
|
+
{
|
|
11
|
+
title: '番剧详情',
|
|
12
|
+
docs: 'https://docs.rsshub.app/anime.html#age-dong-man',
|
|
13
|
+
source: ['/detail/:id'],
|
|
14
|
+
target: '/agefans/detail/:id',
|
|
15
|
+
},
|
|
16
|
+
],
|
|
17
|
+
};
|
|
18
|
+
|
|
1
19
|
module.exports = {
|
|
2
|
-
'agemys.cc':
|
|
3
|
-
|
|
4
|
-
'.': [
|
|
5
|
-
{
|
|
6
|
-
title: '最近更新',
|
|
7
|
-
docs: 'https://docs.rsshub.app/anime.html#age-dong-man',
|
|
8
|
-
source: ['/update', '/'],
|
|
9
|
-
target: '/agefans/update',
|
|
10
|
-
},
|
|
11
|
-
{
|
|
12
|
-
title: '番剧详情',
|
|
13
|
-
docs: 'https://docs.rsshub.app/anime.html#age-dong-man',
|
|
14
|
-
source: ['/detail/:id'],
|
|
15
|
-
target: '/agefans/detail/:id',
|
|
16
|
-
},
|
|
17
|
-
],
|
|
18
|
-
},
|
|
20
|
+
'agemys.cc': ageFans,
|
|
21
|
+
'agemys.org': ageFans,
|
|
19
22
|
};
|
package/lib/v2/agefans/update.js
CHANGED
|
@@ -1,23 +1,24 @@
|
|
|
1
1
|
const got = require('@/utils/got');
|
|
2
2
|
const cheerio = require('cheerio');
|
|
3
|
+
const { rootUrl } = require('./utils');
|
|
3
4
|
|
|
4
5
|
module.exports = async (ctx) => {
|
|
5
|
-
const rootUrl = 'https://www.agemys.cc';
|
|
6
6
|
const currentUrl = `${rootUrl}/update`;
|
|
7
7
|
const response = await got(currentUrl);
|
|
8
8
|
|
|
9
9
|
const $ = cheerio.load(response.data);
|
|
10
10
|
|
|
11
|
-
const list = $('.
|
|
12
|
-
.
|
|
11
|
+
const list = $('.video_item')
|
|
12
|
+
.toArray()
|
|
13
|
+
.map((item) => {
|
|
13
14
|
item = $(item);
|
|
15
|
+
const link = item.find('a').attr('href').replace('http://', 'https://');
|
|
14
16
|
return {
|
|
15
17
|
title: item.text(),
|
|
16
|
-
link
|
|
17
|
-
guid: `${
|
|
18
|
+
link,
|
|
19
|
+
guid: `${link}#${item.find('.video_item--info').text()}`,
|
|
18
20
|
};
|
|
19
|
-
})
|
|
20
|
-
.get();
|
|
21
|
+
});
|
|
21
22
|
|
|
22
23
|
const items = await Promise.all(
|
|
23
24
|
list.map((item) =>
|
|
@@ -25,7 +26,15 @@ module.exports = async (ctx) => {
|
|
|
25
26
|
const detailResponse = await got(item.link);
|
|
26
27
|
const content = cheerio.load(detailResponse.data);
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
content('img').each((_, ele) => {
|
|
30
|
+
if (ele.attribs['data-original']) {
|
|
31
|
+
ele.attribs.src = ele.attribs['data-original'];
|
|
32
|
+
delete ele.attribs['data-original'];
|
|
33
|
+
}
|
|
34
|
+
});
|
|
35
|
+
content('.video_detail_collect').remove();
|
|
36
|
+
|
|
37
|
+
item.description = content('.video_detail_left').html();
|
|
29
38
|
|
|
30
39
|
return item;
|
|
31
40
|
})
|
|
@@ -1,36 +1,45 @@
|
|
|
1
1
|
const got = require('@/utils/got');
|
|
2
2
|
const cheerio = require('cheerio');
|
|
3
|
-
const
|
|
3
|
+
const timezone = require('@/utils/timezone');
|
|
4
|
+
const { parseDate } = require('@/utils/parse-date');
|
|
5
|
+
|
|
6
|
+
const { rootUrl, ossUrl, ProcessFeed } = require('./utils');
|
|
4
7
|
|
|
5
8
|
module.exports = async (ctx) => {
|
|
6
|
-
const id = ctx.params
|
|
7
|
-
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 30;
|
|
9
|
+
const { id } = ctx.params;
|
|
10
|
+
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
|
|
8
11
|
|
|
9
|
-
const currentUrl =
|
|
12
|
+
const currentUrl = new URL(`/data/search?column=${id}`, rootUrl).href;
|
|
10
13
|
|
|
11
|
-
const response = await got(
|
|
12
|
-
method: 'get',
|
|
13
|
-
url: currentUrl,
|
|
14
|
-
});
|
|
14
|
+
const { data: response } = await got(currentUrl);
|
|
15
15
|
|
|
16
|
-
const $ = cheerio.load(response
|
|
16
|
+
const $ = cheerio.load(response);
|
|
17
17
|
|
|
18
18
|
const title = $('div.article-title a').first().text().replace(/\[|\]/g, '');
|
|
19
19
|
|
|
20
|
-
const items = $('div.
|
|
20
|
+
const items = $('div.article-title')
|
|
21
|
+
.slice(0, limit)
|
|
21
22
|
.toArray()
|
|
22
23
|
.map((item) => {
|
|
23
24
|
item = $(item);
|
|
24
25
|
|
|
26
|
+
const a = item.find('a[title]');
|
|
27
|
+
|
|
25
28
|
return {
|
|
26
|
-
title:
|
|
27
|
-
link: new URL(
|
|
29
|
+
title: a.text(),
|
|
30
|
+
link: new URL(a.prop('href'), rootUrl).href,
|
|
31
|
+
author: a.text().split(':')[0],
|
|
32
|
+
pubDate: timezone(parseDate(item.find('span').text()), +8),
|
|
28
33
|
};
|
|
29
34
|
});
|
|
30
35
|
|
|
31
36
|
ctx.state.data = {
|
|
37
|
+
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
|
|
32
38
|
title: `爱思想 - ${title}`,
|
|
33
39
|
link: currentUrl,
|
|
34
|
-
|
|
40
|
+
description: $('div.tips').text(),
|
|
41
|
+
language: 'zh-cn',
|
|
42
|
+
image: new URL('images/logo.jpg', ossUrl).href,
|
|
43
|
+
subtitle: title,
|
|
35
44
|
};
|
|
36
45
|
};
|
|
@@ -8,6 +8,12 @@ module.exports = {
|
|
|
8
8
|
source: ['/data/search', '/'],
|
|
9
9
|
target: (params, url) => `/aisixiang/column/${new URL(url).searchParams.get('column')}`,
|
|
10
10
|
},
|
|
11
|
+
{
|
|
12
|
+
title: '专题',
|
|
13
|
+
docs: 'https://docs.rsshub.app/reading.html#ai-si-xiang',
|
|
14
|
+
source: ['/zhuanti', '/'],
|
|
15
|
+
target: (params, url) => `/aisixiang/zhuanti/${new URL(url).href.match(/\/zhuanti\/(.*?)\.html/)[1]}`,
|
|
16
|
+
},
|
|
11
17
|
{
|
|
12
18
|
title: '排行',
|
|
13
19
|
docs: 'https://docs.rsshub.app/reading.html#ai-si-xiang',
|
|
@@ -3,4 +3,5 @@ module.exports = function (router) {
|
|
|
3
3
|
router.get('/ranking/:id?/:period?', require('./toplist'));
|
|
4
4
|
router.get('/toplist/:id?/:period?', require('./toplist'));
|
|
5
5
|
router.get('/thinktank/:id/:type?', require('./thinktank'));
|
|
6
|
+
router.get('/zhuanti/:id', require('./zhuanti'));
|
|
6
7
|
};
|
|
@@ -1,20 +1,17 @@
|
|
|
1
1
|
const got = require('@/utils/got');
|
|
2
2
|
const cheerio = require('cheerio');
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
const { rootUrl, ossUrl, ProcessFeed } = require('./utils');
|
|
4
5
|
|
|
5
6
|
module.exports = async (ctx) => {
|
|
6
|
-
const id = ctx.params
|
|
7
|
-
const
|
|
8
|
-
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 30;
|
|
7
|
+
const { id, type = '' } = ctx.params;
|
|
8
|
+
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
|
|
9
9
|
|
|
10
|
-
const currentUrl =
|
|
10
|
+
const currentUrl = new URL(`thinktank/${id}.html`, rootUrl).href;
|
|
11
11
|
|
|
12
|
-
const response = await got(
|
|
13
|
-
method: 'get',
|
|
14
|
-
url: currentUrl,
|
|
15
|
-
});
|
|
12
|
+
const { data: response } = await got(currentUrl);
|
|
16
13
|
|
|
17
|
-
const $ = cheerio.load(response
|
|
14
|
+
const $ = cheerio.load(response);
|
|
18
15
|
|
|
19
16
|
const title = `${$('h2').first().text().trim()}${type}`;
|
|
20
17
|
|
|
@@ -31,19 +28,22 @@ module.exports = async (ctx) => {
|
|
|
31
28
|
items = [...items, ...$(l).parent().find('ul li a').toArray()];
|
|
32
29
|
}
|
|
33
30
|
|
|
34
|
-
items = items.map((item) => {
|
|
31
|
+
items = items.slice(0, limit).map((item) => {
|
|
35
32
|
item = $(item);
|
|
36
33
|
|
|
37
34
|
return {
|
|
38
35
|
title: item.text().split(':').pop(),
|
|
39
|
-
link: new URL(item.
|
|
36
|
+
link: new URL(item.prop('href'), rootUrl).href,
|
|
40
37
|
};
|
|
41
38
|
});
|
|
42
39
|
|
|
43
40
|
ctx.state.data = {
|
|
41
|
+
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
|
|
44
42
|
title: `爱思想 - ${title}`,
|
|
45
43
|
link: currentUrl,
|
|
46
|
-
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
|
|
47
44
|
description: $('div.thinktank-author-description-box p').text(),
|
|
45
|
+
language: 'zh-cn',
|
|
46
|
+
image: new URL('images/logo_thinktank.jpg', ossUrl).href,
|
|
47
|
+
subtitle: title,
|
|
48
48
|
};
|
|
49
49
|
};
|
|
@@ -1,37 +1,43 @@
|
|
|
1
1
|
const got = require('@/utils/got');
|
|
2
2
|
const cheerio = require('cheerio');
|
|
3
|
-
const {
|
|
3
|
+
const { parseDate } = require('@/utils/parse-date');
|
|
4
|
+
|
|
5
|
+
const { rootUrl, ossUrl, ProcessFeed } = require('./utils');
|
|
4
6
|
|
|
5
7
|
module.exports = async (ctx) => {
|
|
6
|
-
const id =
|
|
7
|
-
const
|
|
8
|
-
const limit = ctx.query.limit ? parseInt(ctx.query.limit) : 30;
|
|
8
|
+
const { id = '1', period = '1' } = ctx.params;
|
|
9
|
+
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
|
|
9
10
|
|
|
10
|
-
const currentUrl =
|
|
11
|
+
const currentUrl = new URL(`toplist${id ? `?id=${id}${id === '1' ? `&period=${period}` : ''}` : ''}`, rootUrl).href;
|
|
11
12
|
|
|
12
|
-
const response = await got(
|
|
13
|
-
method: 'get',
|
|
14
|
-
url: currentUrl,
|
|
15
|
-
});
|
|
13
|
+
const { data: response } = await got(currentUrl);
|
|
16
14
|
|
|
17
|
-
const $ = cheerio.load(response
|
|
15
|
+
const $ = cheerio.load(response);
|
|
18
16
|
|
|
19
|
-
const title = `${$('.hl').text() || ''}${$('title').text().split('_')[0]}`;
|
|
17
|
+
const title = `${$('a.hl').text() || ''}${$('title').text().split('_')[0]}`;
|
|
20
18
|
|
|
21
|
-
const items = $('div.
|
|
19
|
+
const items = $('div.tops_list')
|
|
20
|
+
.slice(0, limit)
|
|
22
21
|
.toArray()
|
|
23
22
|
.map((item) => {
|
|
24
23
|
item = $(item);
|
|
25
24
|
|
|
25
|
+
const a = item.find('div.tips a');
|
|
26
|
+
|
|
26
27
|
return {
|
|
27
|
-
title:
|
|
28
|
-
link: new URL(
|
|
28
|
+
title: a.text(),
|
|
29
|
+
link: new URL(a.prop('href'), rootUrl).href,
|
|
30
|
+
author: item.find('div.name').text(),
|
|
31
|
+
pubDate: parseDate(item.find('div.times').text()),
|
|
29
32
|
};
|
|
30
33
|
});
|
|
31
34
|
|
|
32
35
|
ctx.state.data = {
|
|
36
|
+
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
|
|
33
37
|
title: `爱思想 - ${title}`,
|
|
34
38
|
link: currentUrl,
|
|
35
|
-
|
|
39
|
+
language: 'zh-cn',
|
|
40
|
+
image: new URL('images/logo_toplist.jpg', ossUrl).href,
|
|
41
|
+
subtitle: title,
|
|
36
42
|
};
|
|
37
43
|
};
|
|
@@ -3,28 +3,33 @@ const cheerio = require('cheerio');
|
|
|
3
3
|
const timezone = require('@/utils/timezone');
|
|
4
4
|
const { parseDate } = require('@/utils/parse-date');
|
|
5
5
|
|
|
6
|
-
const
|
|
6
|
+
const ossUrl = 'https://oss.aisixiang.com';
|
|
7
|
+
const rootUrl = 'https://www.aisixiang.com';
|
|
7
8
|
|
|
8
9
|
const ProcessFeed = (limit, tryGet, items) =>
|
|
9
10
|
Promise.all(
|
|
10
11
|
items.slice(0, limit).map((item) =>
|
|
11
12
|
tryGet(item.link, async () => {
|
|
12
|
-
const detailResponse = await got(
|
|
13
|
-
method: 'get',
|
|
14
|
-
url: item.link,
|
|
15
|
-
});
|
|
13
|
+
const { data: detailResponse } = await got(item.link);
|
|
16
14
|
|
|
17
|
-
const content = cheerio.load(detailResponse
|
|
15
|
+
const content = cheerio.load(detailResponse);
|
|
18
16
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
const commentMatches = content('h3.comment-header')
|
|
18
|
+
.text()
|
|
19
|
+
.match(/评论(\d+)/);
|
|
20
|
+
|
|
21
|
+
item.title = content('h3').first().text().split(':').pop();
|
|
22
|
+
item.description = content('div.article-content').html();
|
|
23
|
+
item.author = content('div.about strong').first().text();
|
|
22
24
|
item.category = content('u')
|
|
23
25
|
.first()
|
|
24
26
|
.parent()
|
|
25
27
|
.find('u')
|
|
26
28
|
.toArray()
|
|
27
|
-
.map((
|
|
29
|
+
.map((c) => content(c).text());
|
|
30
|
+
item.pubDate = timezone(parseDate(content('div.info').text().split('时间:').pop()), +8);
|
|
31
|
+
item.upvotes = content('span.like-num').text() ? parseInt(content('span.like-num').text(), 10) : 0;
|
|
32
|
+
item.comments = commentMatches ? parseInt(commentMatches[1], 10) : 0;
|
|
28
33
|
|
|
29
34
|
return item;
|
|
30
35
|
})
|
|
@@ -33,5 +38,6 @@ const ProcessFeed = (limit, tryGet, items) =>
|
|
|
33
38
|
|
|
34
39
|
module.exports = {
|
|
35
40
|
rootUrl,
|
|
41
|
+
ossUrl,
|
|
36
42
|
ProcessFeed,
|
|
37
43
|
};
|
|
@@ -0,0 +1,45 @@
|
|
|
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
|
+
const { rootUrl, ossUrl, ProcessFeed } = require('./utils');
|
|
7
|
+
|
|
8
|
+
module.exports = async (ctx) => {
|
|
9
|
+
const { id } = ctx.params;
|
|
10
|
+
const limit = ctx.query.limit ? parseInt(ctx.query.limit, 10) : 30;
|
|
11
|
+
|
|
12
|
+
const currentUrl = new URL(`zhuanti/${id}.html`, rootUrl).href;
|
|
13
|
+
|
|
14
|
+
const { data: response } = await got(currentUrl);
|
|
15
|
+
|
|
16
|
+
const $ = cheerio.load(response);
|
|
17
|
+
|
|
18
|
+
const title = $('div.tips h2').first().text();
|
|
19
|
+
|
|
20
|
+
const items = $('div.article-title')
|
|
21
|
+
.slice(0, limit)
|
|
22
|
+
.toArray()
|
|
23
|
+
.map((item) => {
|
|
24
|
+
item = $(item);
|
|
25
|
+
|
|
26
|
+
const a = item.find('a');
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
title: a.text(),
|
|
30
|
+
link: new URL(a.prop('href'), rootUrl).href,
|
|
31
|
+
author: a.text().split(':')[0],
|
|
32
|
+
pubDate: timezone(parseDate(item.find('span').text()), +8),
|
|
33
|
+
};
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
ctx.state.data = {
|
|
37
|
+
item: await ProcessFeed(limit, ctx.cache.tryGet, items),
|
|
38
|
+
title: `爱思想 - ${title}`,
|
|
39
|
+
link: currentUrl,
|
|
40
|
+
description: $('div.tips p').text(),
|
|
41
|
+
language: 'zh-cn',
|
|
42
|
+
image: new URL('images/logo_zhuanti.jpg', ossUrl).href,
|
|
43
|
+
subtitle: title,
|
|
44
|
+
};
|
|
45
|
+
};
|