rsshub 1.0.0-master.d77d4e5 → 1.0.0-master.d7939a6
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/middleware/anti-hotlink.test.ts +191 -6
- package/lib/middleware/anti-hotlink.ts +28 -0
- package/lib/routes/5eplay/utils.ts +5 -3
- package/lib/routes/agri/index.ts +307 -0
- package/lib/routes/agri/namespace.ts +8 -0
- package/lib/routes/agri/templates/description.art +21 -0
- package/lib/routes/bestblogs/feeds.ts +107 -0
- package/lib/routes/{blockbeats → bestblogs}/namespace.ts +2 -2
- package/lib/routes/bilibili/dynamic.ts +2 -8
- package/lib/routes/binance/announcement.ts +168 -0
- package/lib/routes/binance/types.ts +26 -0
- package/lib/routes/chlinlearn/daily-blog.ts +7 -0
- package/lib/routes/go/namespace.ts +8 -0
- package/lib/routes/go/niid/idwr-dl.ts +104 -0
- package/lib/routes/luma/index.ts +92 -0
- package/lib/routes/luma/namespace.ts +6 -0
- package/lib/routes/sis001/author.ts +1 -1
- package/lib/routes/sis001/common.ts +10 -2
- package/lib/routes/sis001/forum.ts +1 -5
- package/lib/routes/sjtu/namespace.ts +1 -1
- package/lib/routes/sjtu/seiee/index.ts +97 -0
- package/lib/routes/taoguba/blog.ts +1 -1
- package/lib/routes/taoguba/index.ts +1 -1
- package/lib/routes/test/index.ts +44 -7
- package/lib/routes/the/index.ts +1 -0
- package/lib/routes/theblockbeats/index.ts +10 -5
- package/lib/routes/xiaohongshu/user.ts +1 -1
- package/lib/routes/xueqiu/cookies.ts +14 -1
- package/lib/routes/xueqiu/favorite.ts +16 -2
- package/package.json +8 -8
- package/lib/routes/blockbeats/article-choice.ts +0 -64
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
import cache from '@/utils/cache';
|
|
3
|
+
import { load } from 'cheerio';
|
|
4
|
+
import { parseDate } from '@/utils/parse-date';
|
|
5
|
+
import timezone from '@/utils/timezone';
|
|
6
|
+
import ofetch from '@/utils/ofetch';
|
|
7
|
+
|
|
8
|
+
export const route: Route = {
|
|
9
|
+
path: '/seiee/:path/:catID?/:searchCatCode?',
|
|
10
|
+
categories: ['university'],
|
|
11
|
+
example: '/sjtu/seiee/xzzx_notice_bks',
|
|
12
|
+
parameters: { path: "不含'.html'的最后一部分路径", catID: "'本科生人才培养'与'研究生人才培养'的类别ID", searchCatCode: "'本科生人才培养'与'研究生人才培养'下类别名" },
|
|
13
|
+
features: {
|
|
14
|
+
requireConfig: false,
|
|
15
|
+
requirePuppeteer: false,
|
|
16
|
+
antiCrawler: true,
|
|
17
|
+
supportBT: false,
|
|
18
|
+
supportPodcast: false,
|
|
19
|
+
supportScihub: false,
|
|
20
|
+
},
|
|
21
|
+
radar: [
|
|
22
|
+
{
|
|
23
|
+
source: ['www.seiee.sjtu.edu.cn/:path.html'],
|
|
24
|
+
target: '/seiee/:path',
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
name: '电子信息与电气工程学院',
|
|
28
|
+
maintainers: ['dzx-dzx'],
|
|
29
|
+
handler,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
async function handler(ctx) {
|
|
33
|
+
const { path, catID = '', searchCatCode = '' } = ctx.req.param();
|
|
34
|
+
|
|
35
|
+
const rootUrl = 'https://www.seiee.sjtu.edu.cn';
|
|
36
|
+
const currentUrl = `${rootUrl}/${path}.html`;
|
|
37
|
+
const ajaxUrl = `${rootUrl}/active/ajax_article_list.html`;
|
|
38
|
+
const response = catID
|
|
39
|
+
? (
|
|
40
|
+
await ofetch(ajaxUrl, {
|
|
41
|
+
method: 'POST',
|
|
42
|
+
body: new URLSearchParams({
|
|
43
|
+
page: '1',
|
|
44
|
+
cat_id: catID,
|
|
45
|
+
search_cat_code: searchCatCode,
|
|
46
|
+
search_cat_title: '',
|
|
47
|
+
template: 'v_ajax_normal_list1',
|
|
48
|
+
}),
|
|
49
|
+
headers: {
|
|
50
|
+
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
|
51
|
+
},
|
|
52
|
+
parseResponse: JSON.parse,
|
|
53
|
+
})
|
|
54
|
+
).content
|
|
55
|
+
: await ofetch(currentUrl);
|
|
56
|
+
|
|
57
|
+
const $ = load(response);
|
|
58
|
+
|
|
59
|
+
const list = $(catID ? 'li' : '.u10 li')
|
|
60
|
+
.toArray()
|
|
61
|
+
.map((item) => {
|
|
62
|
+
item = $(item);
|
|
63
|
+
|
|
64
|
+
return {
|
|
65
|
+
title: item.find('.name').text().trim(),
|
|
66
|
+
link: item.find('a').attr('href'),
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
const items = await Promise.all(
|
|
71
|
+
list.map((item) =>
|
|
72
|
+
cache.tryGet(item.link, async () => {
|
|
73
|
+
const detailResponse = await ofetch(item.link);
|
|
74
|
+
const content = load(detailResponse);
|
|
75
|
+
|
|
76
|
+
item.description = content('.nr').html();
|
|
77
|
+
item.pubDate = timezone(
|
|
78
|
+
parseDate(
|
|
79
|
+
content('.jj')
|
|
80
|
+
.text()
|
|
81
|
+
.trim()
|
|
82
|
+
.match(/日期:([\d-]+) /)[1]
|
|
83
|
+
),
|
|
84
|
+
+8
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
return item;
|
|
88
|
+
})
|
|
89
|
+
)
|
|
90
|
+
);
|
|
91
|
+
|
|
92
|
+
return {
|
|
93
|
+
title: $('title').text() || load(await ofetch(currentUrl))('title').text(),
|
|
94
|
+
link: currentUrl,
|
|
95
|
+
item: items,
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -64,7 +64,7 @@ async function handler(ctx) {
|
|
|
64
64
|
method: 'get',
|
|
65
65
|
url: item.link,
|
|
66
66
|
});
|
|
67
|
-
if (detailResponse.url
|
|
67
|
+
if (detailResponse.url?.startsWith('https://www.taoguba.com.cn/topic/transfer')) {
|
|
68
68
|
item.description = '登录后查看完整文章';
|
|
69
69
|
return item;
|
|
70
70
|
}
|
|
@@ -51,7 +51,7 @@ async function handler(ctx) {
|
|
|
51
51
|
method: 'get',
|
|
52
52
|
url: item.link,
|
|
53
53
|
});
|
|
54
|
-
if (detailResponse.url
|
|
54
|
+
if (detailResponse.url?.startsWith('https://www.taoguba.com.cn/topic/transfer')) {
|
|
55
55
|
item.description = '登录后查看完整文章';
|
|
56
56
|
return item;
|
|
57
57
|
}
|
package/lib/routes/test/index.ts
CHANGED
|
@@ -33,6 +33,7 @@ async function handler(ctx) {
|
|
|
33
33
|
throw new InvalidParameterError('Test invalid parameter error');
|
|
34
34
|
}
|
|
35
35
|
let item: DataItem[] = [];
|
|
36
|
+
let image: string | null = null;
|
|
36
37
|
switch (ctx.req.param('id')) {
|
|
37
38
|
case 'filter':
|
|
38
39
|
item = [
|
|
@@ -141,6 +142,7 @@ async function handler(ctx) {
|
|
|
141
142
|
break;
|
|
142
143
|
}
|
|
143
144
|
case 'complicated':
|
|
145
|
+
image = 'https://mock.com/DIYgod/RSSHub.png';
|
|
144
146
|
item.push(
|
|
145
147
|
{
|
|
146
148
|
title: `Complicated Title`,
|
|
@@ -166,15 +168,38 @@ async function handler(ctx) {
|
|
|
166
168
|
pubDate: new Date(`2019-3-1`).toUTCString(),
|
|
167
169
|
link: `https://mock.com/DIYgod/RSSHub`,
|
|
168
170
|
author: `DIYgod`,
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
title: `Complicated Title`,
|
|
174
|
+
description: `<a href="/DIYgod/RSSHub"></a>
|
|
175
|
+
<img src="/DIYgod/RSSHub.jpg">
|
|
176
|
+
<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==">`,
|
|
177
|
+
pubDate: new Date(`2019-3-1`).toUTCString(),
|
|
178
|
+
link: `//mock.com/DIYgod/RSSHub`,
|
|
179
|
+
author: `DIYgod`,
|
|
180
|
+
enclosure_url: 'https://mock.com/DIYgod/RSSHub.png',
|
|
181
|
+
enclosure_type: 'image/png',
|
|
182
|
+
itunes_item_image: 'https://mock.com/DIYgod/RSSHub.gif',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
title: `Complicated Title`,
|
|
186
|
+
description: `<a href="/DIYgod/RSSHub"></a>
|
|
187
|
+
<img src="/DIYgod/RSSHub.jpg">
|
|
188
|
+
<img src="data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==">`,
|
|
189
|
+
pubDate: new Date(`2019-3-1`).toUTCString(),
|
|
190
|
+
link: `//mock.com/DIYgod/RSSHub`,
|
|
191
|
+
author: `DIYgod`,
|
|
192
|
+
image: 'https://mock.com/DIYgod/RSSHub.jpg',
|
|
169
193
|
}
|
|
170
194
|
);
|
|
171
195
|
|
|
172
196
|
break;
|
|
173
197
|
|
|
174
198
|
case 'multimedia':
|
|
175
|
-
item.push(
|
|
176
|
-
|
|
177
|
-
|
|
199
|
+
item.push(
|
|
200
|
+
{
|
|
201
|
+
title: `Multimedia Title`,
|
|
202
|
+
description: `<img src="/DIYgod/RSSHub.jpg">
|
|
178
203
|
<video src="/DIYgod/RSSHub.mp4"></video>
|
|
179
204
|
<video poster="/DIYgod/RSSHub.jpg">
|
|
180
205
|
<source src="/DIYgod/RSSHub.mp4" type="video/mp4">
|
|
@@ -182,10 +207,21 @@ async function handler(ctx) {
|
|
|
182
207
|
</video>
|
|
183
208
|
<audio src="/DIYgod/RSSHub.mp3"></audio>
|
|
184
209
|
<iframe src="/DIYgod/RSSHub.html"></iframe>`,
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
210
|
+
pubDate: new Date(`2019-3-1`).toUTCString(),
|
|
211
|
+
link: `https://mock.com/DIYgod/RSSHub`,
|
|
212
|
+
author: `DIYgod`,
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
title: `Multimedia Title`,
|
|
216
|
+
description: `<img src="/DIYgod/RSSHub.jpg">
|
|
217
|
+
<video src="/DIYgod/RSSHub.mp4"></video>`,
|
|
218
|
+
pubDate: new Date(`2019-3-1`).toUTCString(),
|
|
219
|
+
link: `https://mock.com/DIYgod/RSSHub`,
|
|
220
|
+
author: `DIYgod`,
|
|
221
|
+
enclosure_url: 'https://mock.com/DIYgod/RSSHub.mp4',
|
|
222
|
+
enclosure_type: 'video/mp4',
|
|
223
|
+
}
|
|
224
|
+
);
|
|
189
225
|
|
|
190
226
|
break;
|
|
191
227
|
|
|
@@ -369,6 +405,7 @@ async function handler(ctx) {
|
|
|
369
405
|
}
|
|
370
406
|
|
|
371
407
|
return {
|
|
408
|
+
image,
|
|
372
409
|
title: `Test ${ctx.req.param('id')}`,
|
|
373
410
|
itunes_author: ctx.req.param('id') === 'enclosure' ? 'DIYgod' : null,
|
|
374
411
|
link: 'https://github.com/DIYgod/RSSHub',
|
package/lib/routes/the/index.ts
CHANGED
|
@@ -23,6 +23,7 @@ export const handler = async (ctx) => {
|
|
|
23
23
|
|
|
24
24
|
apiSearchParams.append('_embed', 'true');
|
|
25
25
|
apiSearchParams.append('per_page', String(limit));
|
|
26
|
+
apiSearchParams.append('page', '1');
|
|
26
27
|
|
|
27
28
|
const apiUrl = bakeUrl(`${apiSlug}/posts`, rootUrl, apiSearchParams);
|
|
28
29
|
const currentUrl = bakeUrl(getFilterParamsForUrl(filtersWithPair) ?? '', rootUrl, searchParams);
|
|
@@ -40,10 +40,10 @@ const channelMap = {
|
|
|
40
40
|
};
|
|
41
41
|
|
|
42
42
|
export const route: Route = {
|
|
43
|
-
path: '/:channel?',
|
|
43
|
+
path: '/:channel?/:original?',
|
|
44
44
|
categories: ['finance'],
|
|
45
45
|
example: '/theblockbeats/newsflash',
|
|
46
|
-
parameters: { channel: '类型,见下表,默认为快讯' },
|
|
46
|
+
parameters: { channel: '类型,见下表,默认为快讯', original: '文章类型,仅 `channel` 为 `article` 时有效,见下表,留空为全部' },
|
|
47
47
|
name: '新闻快讯',
|
|
48
48
|
maintainers: ['Fatpandac', 'jameshih'],
|
|
49
49
|
handler,
|
|
@@ -61,15 +61,20 @@ export const route: Route = {
|
|
|
61
61
|
],
|
|
62
62
|
description: `| 快讯 | 文章 |
|
|
63
63
|
| :-------: | :-----: |
|
|
64
|
-
| newsflash | article
|
|
64
|
+
| newsflash | article |
|
|
65
|
+
|
|
66
|
+
| 全部 | 深度 | 精选 | 热点追踪 |
|
|
67
|
+
| :--: | :--: | :--: | :---: |
|
|
68
|
+
| | -2 | 1 | 2 |`,
|
|
65
69
|
};
|
|
66
70
|
|
|
67
71
|
async function handler(ctx) {
|
|
68
|
-
const { channel = 'newsflash' } = ctx.req.param();
|
|
72
|
+
const { channel = 'newsflash', original } = ctx.req.param();
|
|
69
73
|
|
|
70
74
|
const response = await ofetch(channelMap[channel].api, {
|
|
71
75
|
query: {
|
|
72
76
|
limit: ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20,
|
|
77
|
+
original: channel === 'article' ? original : undefined,
|
|
73
78
|
},
|
|
74
79
|
});
|
|
75
80
|
|
|
@@ -86,7 +91,7 @@ async function handler(ctx) {
|
|
|
86
91
|
if (channel !== 'newsflash') {
|
|
87
92
|
list = await Promise.all(
|
|
88
93
|
list.map((item) =>
|
|
89
|
-
cache.tryGet(item.link
|
|
94
|
+
cache.tryGet(`theblockbeats:${item.link}`, async () => {
|
|
90
95
|
const response = await ofetch(item.link);
|
|
91
96
|
const $ = load(response);
|
|
92
97
|
item.description = render({
|
|
@@ -50,7 +50,7 @@ async function handler(ctx) {
|
|
|
50
50
|
notes.flatMap((n) =>
|
|
51
51
|
n.map(({ noteCard }) => ({
|
|
52
52
|
title: noteCard.displayTitle,
|
|
53
|
-
link: `${url}/${noteCard.noteId}`,
|
|
53
|
+
link: `${url}/${noteCard.noteId || noteCard.id}`,
|
|
54
54
|
description: `<img src ="${noteCard.cover.infoList.pop().url}"><br>${noteCard.displayTitle}`,
|
|
55
55
|
author: noteCard.user.nickname,
|
|
56
56
|
upvotes: noteCard.interactInfo.likedCount,
|
|
@@ -1,12 +1,25 @@
|
|
|
1
1
|
import ofetch from '@/utils/ofetch';
|
|
2
2
|
import cache from '@/utils/cache';
|
|
3
3
|
import { config } from '@/config';
|
|
4
|
+
import { getAcwScV2ByArg1 } from '@/routes/5eplay/utils';
|
|
4
5
|
|
|
5
6
|
export const parseToken = () =>
|
|
6
7
|
cache.tryGet(
|
|
7
8
|
'xueqiu:token',
|
|
8
9
|
async () => {
|
|
9
|
-
const
|
|
10
|
+
const r = await ofetch('https://xueqiu.com');
|
|
11
|
+
|
|
12
|
+
let acw_sc__v2 = '';
|
|
13
|
+
const matches = r.match(/var arg1='(.*?)';/);
|
|
14
|
+
if (matches) {
|
|
15
|
+
acw_sc__v2 = getAcwScV2ByArg1(matches[1]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
const res = await ofetch.raw('https://xueqiu.com', {
|
|
19
|
+
headers: {
|
|
20
|
+
Cookie: `acw_sc__v2=${acw_sc__v2}`,
|
|
21
|
+
},
|
|
22
|
+
});
|
|
10
23
|
const cookieArray = res.headers.getSetCookie();
|
|
11
24
|
return cookieArray.find((c) => c.startsWith('xq_a_token='));
|
|
12
25
|
},
|
|
@@ -3,6 +3,7 @@ import got from '@/utils/got';
|
|
|
3
3
|
import queryString from 'query-string';
|
|
4
4
|
import { parseDate } from '@/utils/parse-date';
|
|
5
5
|
import { parseToken } from '@/routes/xueqiu/cookies';
|
|
6
|
+
import ofetch from '@/utils/ofetch';
|
|
6
7
|
|
|
7
8
|
export const route: Route = {
|
|
8
9
|
path: '/favorite/:id',
|
|
@@ -43,15 +44,28 @@ async function handler(ctx) {
|
|
|
43
44
|
});
|
|
44
45
|
const data = res2.data.list;
|
|
45
46
|
|
|
47
|
+
const {
|
|
48
|
+
user: { screen_name },
|
|
49
|
+
} = await ofetch('https://xueqiu.com/statuses/original/show.json', {
|
|
50
|
+
query: {
|
|
51
|
+
user_id: id,
|
|
52
|
+
},
|
|
53
|
+
headers: {
|
|
54
|
+
Cookie: token,
|
|
55
|
+
Referer: `https://xueqiu.com/u/${id}`,
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
46
59
|
return {
|
|
47
|
-
title:
|
|
60
|
+
title: `${screen_name} 的雪球收藏动态`,
|
|
48
61
|
link: `https://xueqiu.com/u/${id}`,
|
|
49
|
-
description:
|
|
62
|
+
description: `${screen_name} 的雪球收藏动态`,
|
|
50
63
|
item: data.map((item) => ({
|
|
51
64
|
title: item.title,
|
|
52
65
|
description: item.description,
|
|
53
66
|
pubDate: parseDate(item.created_at),
|
|
54
67
|
link: `https://xueqiu.com${item.target}`,
|
|
55
68
|
})),
|
|
69
|
+
allowEmpty: true,
|
|
56
70
|
};
|
|
57
71
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rsshub",
|
|
3
|
-
"version": "1.0.0-master.
|
|
3
|
+
"version": "1.0.0-master.d7939a6",
|
|
4
4
|
"description": "Make RSS Great Again!",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"RSS"
|
|
@@ -64,7 +64,7 @@
|
|
|
64
64
|
"etag": "1.8.1",
|
|
65
65
|
"fanfou-sdk": "5.0.0",
|
|
66
66
|
"form-data": "4.0.0",
|
|
67
|
-
"googleapis": "
|
|
67
|
+
"googleapis": "144.0.0",
|
|
68
68
|
"hono": "4.5.11",
|
|
69
69
|
"html-to-text": "9.0.5",
|
|
70
70
|
"http-cookie-agent": "6.0.5",
|
|
@@ -77,7 +77,7 @@
|
|
|
77
77
|
"jsdom": "25.0.0",
|
|
78
78
|
"json-bigint": "1.0.0",
|
|
79
79
|
"jsrsasign": "10.9.0",
|
|
80
|
-
"lru-cache": "11.0.
|
|
80
|
+
"lru-cache": "11.0.1",
|
|
81
81
|
"lz-string": "1.5.0",
|
|
82
82
|
"mailparser": "3.7.1",
|
|
83
83
|
"markdown-it": "14.1.0",
|
|
@@ -105,7 +105,7 @@
|
|
|
105
105
|
"telegram": "2.24.11",
|
|
106
106
|
"tiny-async-pool": "2.1.0",
|
|
107
107
|
"title": "3.5.3",
|
|
108
|
-
"tldts": "6.1.
|
|
108
|
+
"tldts": "6.1.42",
|
|
109
109
|
"tosource": "2.0.0-alpha.3",
|
|
110
110
|
"tough-cookie": "4.1.4",
|
|
111
111
|
"tsx": "4.19.0",
|
|
@@ -139,7 +139,7 @@
|
|
|
139
139
|
"@types/mailparser": "3.4.4",
|
|
140
140
|
"@types/markdown-it": "14.1.2",
|
|
141
141
|
"@types/module-alias": "2.0.4",
|
|
142
|
-
"@types/node": "22.5.
|
|
142
|
+
"@types/node": "22.5.4",
|
|
143
143
|
"@types/sanitize-html": "2.13.0",
|
|
144
144
|
"@types/supertest": "6.0.2",
|
|
145
145
|
"@types/tiny-async-pool": "2.0.3",
|
|
@@ -148,9 +148,9 @@
|
|
|
148
148
|
"@types/uuid": "10.0.0",
|
|
149
149
|
"@typescript-eslint/eslint-plugin": "8.4.0",
|
|
150
150
|
"@typescript-eslint/parser": "8.4.0",
|
|
151
|
-
"@vercel/nft": "0.27.
|
|
151
|
+
"@vercel/nft": "0.27.4",
|
|
152
152
|
"@vitest/coverage-v8": "2.0.5",
|
|
153
|
-
"discord-api-types": "0.37.
|
|
153
|
+
"discord-api-types": "0.37.100",
|
|
154
154
|
"eslint": "9.9.1",
|
|
155
155
|
"eslint-config-prettier": "9.1.0",
|
|
156
156
|
"eslint-nibble": "8.1.0",
|
|
@@ -165,7 +165,7 @@
|
|
|
165
165
|
"js-beautify": "1.15.1",
|
|
166
166
|
"lint-staged": "15.2.10",
|
|
167
167
|
"mockdate": "3.0.5",
|
|
168
|
-
"msw": "2.4.
|
|
168
|
+
"msw": "2.4.2",
|
|
169
169
|
"prettier": "3.3.3",
|
|
170
170
|
"remark-parse": "11.0.0",
|
|
171
171
|
"supertest": "7.0.0",
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { Route } from '@/types';
|
|
2
|
-
import cache from '@/utils/cache';
|
|
3
|
-
import got from '@/utils/got';
|
|
4
|
-
import { load } from 'cheerio';
|
|
5
|
-
|
|
6
|
-
export const route: Route = {
|
|
7
|
-
path: '/article-choice',
|
|
8
|
-
categories: ['new-media'],
|
|
9
|
-
example: '/blockbeats/article-choice',
|
|
10
|
-
name: '文章精选',
|
|
11
|
-
maintainers: ['DIYgod'],
|
|
12
|
-
handler,
|
|
13
|
-
radar: [
|
|
14
|
-
{
|
|
15
|
-
source: ['www.theblockbeats.info/article_choice'],
|
|
16
|
-
target: '/article-choice',
|
|
17
|
-
},
|
|
18
|
-
],
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
async function handler() {
|
|
22
|
-
const response = await got('https://www.theblockbeats.info/article_choice');
|
|
23
|
-
|
|
24
|
-
const $ = load(response.data);
|
|
25
|
-
|
|
26
|
-
const items = await Promise.all(
|
|
27
|
-
$('.article-item')
|
|
28
|
-
.toArray()
|
|
29
|
-
.map(async (item) => {
|
|
30
|
-
const $item = $(item);
|
|
31
|
-
const pubDate = new Date($item.find('.item-time').text()).toUTCString();
|
|
32
|
-
let link = $item.find('.article-item-title').attr('href');
|
|
33
|
-
const category = $item
|
|
34
|
-
.find('.item-label')
|
|
35
|
-
.toArray()
|
|
36
|
-
.map((tag) => $(tag).text().replaceAll(/^#/g, ''));
|
|
37
|
-
const author = $item.find('.article-item-author-name').text();
|
|
38
|
-
const title = $item.find('.article-item-title').text();
|
|
39
|
-
let description = '';
|
|
40
|
-
if (link) {
|
|
41
|
-
link = `https://www.theblockbeats.info${link}`;
|
|
42
|
-
description = (await cache.tryGet(link, async () => {
|
|
43
|
-
const detailResponse = await got(link);
|
|
44
|
-
const content = load(detailResponse.data);
|
|
45
|
-
return content('.news-content').html() || '';
|
|
46
|
-
})) as string;
|
|
47
|
-
}
|
|
48
|
-
return {
|
|
49
|
-
title,
|
|
50
|
-
pubDate,
|
|
51
|
-
link,
|
|
52
|
-
category,
|
|
53
|
-
author,
|
|
54
|
-
description,
|
|
55
|
-
};
|
|
56
|
-
})
|
|
57
|
-
);
|
|
58
|
-
|
|
59
|
-
return {
|
|
60
|
-
title: 'BlockBeats - 文章精选',
|
|
61
|
-
link: 'https://www.theblockbeats.info/article_choice',
|
|
62
|
-
item: items,
|
|
63
|
-
};
|
|
64
|
-
}
|