rsshub 1.0.0-master.cf8766a → 1.0.0-master.cf9cb26
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/api/index.ts +2 -2
- package/lib/routes/199it/index.ts +334 -0
- package/lib/routes/199it/templates/description.art +20 -0
- package/lib/routes/adquan/case-library.ts +146 -0
- package/lib/routes/adquan/index.ts +146 -0
- package/lib/routes/adquan/namespace.ts +9 -0
- package/lib/routes/adquan/templates/description.art +7 -0
- package/lib/routes/apnews/mobile-api.ts +93 -0
- package/lib/routes/apnews/utils.ts +2 -2
- package/lib/routes/apple/podcast.ts +2 -1
- package/lib/routes/cdu/cdrw.ts +80 -0
- package/lib/routes/coolpc/namespace.ts +7 -0
- package/lib/routes/coolpc/news.ts +53 -0
- package/lib/routes/domp4/detail.ts +8 -6
- package/lib/routes/domp4/latest-movie-bt.ts +10 -10
- package/lib/routes/domp4/latest.ts +8 -8
- package/lib/routes/domp4/namespace.ts +2 -8
- package/lib/routes/domp4/utils.ts +5 -5
- package/lib/routes/gcores/program-previews.ts +50 -0
- package/lib/routes/geocaching/blogs.ts +4 -3
- package/lib/routes/gitcode/namespace.ts +7 -0
- package/lib/routes/gitcode/repos/commits.ts +67 -0
- package/lib/routes/gov/mof/gss.ts +82 -0
- package/lib/routes/gov/nea/ghs.ts +70 -37
- package/lib/routes/hanime1/namespace.ts +7 -0
- package/lib/routes/hanime1/previews.ts +89 -0
- package/lib/routes/jandan/index.ts +36 -12
- package/lib/routes/jandan/section.ts +102 -44
- package/lib/routes/jandan/utils.ts +248 -0
- package/lib/routes/jin10/category.ts +223 -0
- package/lib/routes/jpmorganchase/namespace.ts +9 -0
- package/lib/routes/jpmorganchase/research.ts +107 -0
- package/lib/routes/kurogames/namespace.ts +1 -1
- package/lib/routes/kurogames/wutheringwaves/constants.ts +34 -0
- package/lib/routes/kurogames/wutheringwaves/news.ts +60 -33
- package/lib/routes/kurogames/wutheringwaves/utils.ts +79 -0
- package/lib/routes/linkedin/posts.ts +64 -0
- package/lib/routes/linkedin/utils.ts +75 -1
- package/lib/routes/nhentai/util.ts +3 -1
- package/lib/routes/nytimes/rss.ts +5 -1
- package/lib/routes/readhub/daily.ts +2 -2
- package/lib/routes/reuters/common.ts +17 -2
- package/lib/routes/sehuatang/index.ts +1 -1
- package/lib/routes/steam/search.ts +1 -2
- package/lib/routes/swjtu/scai.ts +19 -4
- package/lib/routes/telegram/channel.ts +1 -1
- package/lib/routes/wechat/sogou.ts +171 -50
- package/lib/routes/xjtu/zs.ts +170 -0
- package/lib/routes/youtube/channel.ts +40 -16
- package/lib/routes/youtube/user.ts +38 -9
- package/lib/routes/youtube/utils.ts +17 -0
- package/package.json +27 -27
- package/lib/routes/apnews/api.ts +0 -77
- package/lib/routes-deprecated/jpmorganchase/research.js +0 -52
package/lib/api/index.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { route as radarRulesOneRoute, handler as radarRulesOneHandler } from '@/
|
|
|
6
6
|
import { route as categoryOneRoute, handler as categoryOneHandler } from '@/api/category/one';
|
|
7
7
|
import { route as followConfigRoute, handler as followConfigHandler } from '@/api/follow/config';
|
|
8
8
|
import { OpenAPIHono } from '@hono/zod-openapi';
|
|
9
|
-
import {
|
|
9
|
+
import { Scalar } from '@scalar/hono-api-reference';
|
|
10
10
|
|
|
11
11
|
const app = new OpenAPIHono();
|
|
12
12
|
|
|
@@ -29,6 +29,6 @@ for (const path in docs.paths) {
|
|
|
29
29
|
delete docs.paths[path];
|
|
30
30
|
}
|
|
31
31
|
app.get('/openapi.json', (ctx) => ctx.json(docs));
|
|
32
|
-
app.get('/reference',
|
|
32
|
+
app.get('/reference', Scalar({ content: docs }));
|
|
33
33
|
|
|
34
34
|
export default app;
|
|
@@ -0,0 +1,334 @@
|
|
|
1
|
+
import { type Data, type DataItem, type Route, ViewType } from '@/types';
|
|
2
|
+
|
|
3
|
+
import { art } from '@/utils/render';
|
|
4
|
+
import cache from '@/utils/cache';
|
|
5
|
+
import { getCurrentPath } from '@/utils/helpers';
|
|
6
|
+
import ofetch from '@/utils/ofetch';
|
|
7
|
+
import { parseDate } from '@/utils/parse-date';
|
|
8
|
+
|
|
9
|
+
import { type CheerioAPI, type Cheerio, type Element, load } from 'cheerio';
|
|
10
|
+
import { type Context } from 'hono';
|
|
11
|
+
import path from 'node:path';
|
|
12
|
+
|
|
13
|
+
const __dirname = getCurrentPath(import.meta.url);
|
|
14
|
+
|
|
15
|
+
export const handler = async (ctx: Context): Promise<Data> => {
|
|
16
|
+
const { category = 'newly' } = ctx.req.param();
|
|
17
|
+
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);
|
|
18
|
+
|
|
19
|
+
const baseUrl: string = 'https://www.199it.com';
|
|
20
|
+
const targetUrl: string = new URL(category, baseUrl).href;
|
|
21
|
+
|
|
22
|
+
const response = await ofetch(targetUrl);
|
|
23
|
+
const $: CheerioAPI = load(response);
|
|
24
|
+
const language = $('html').attr('lang') ?? 'zh-CN';
|
|
25
|
+
|
|
26
|
+
let items: DataItem[] = [];
|
|
27
|
+
|
|
28
|
+
items = $('article.newsplus')
|
|
29
|
+
.slice(0, limit)
|
|
30
|
+
.toArray()
|
|
31
|
+
.map((el): Element => {
|
|
32
|
+
const $el: Cheerio<Element> = $(el);
|
|
33
|
+
|
|
34
|
+
const title: string = $el.find('h2.entry-title').text();
|
|
35
|
+
const pubDateStr: string | undefined = $el.find('time.entry-date').attr('datetime');
|
|
36
|
+
const linkUrl: string | undefined = $el.find('h2.entry-title a').attr('href');
|
|
37
|
+
const categoryEls: Element[] = $el.find('ul.post-categories li:not(submenu-parent)').toArray();
|
|
38
|
+
const categories: string[] = [...new Set(categoryEls.map((el) => $(el).text()).filter(Boolean))];
|
|
39
|
+
const image: string | undefined = $el.find('img.attachment-post-thumbnail').attr('src');
|
|
40
|
+
const upDatedStr: string | undefined = pubDateStr;
|
|
41
|
+
|
|
42
|
+
const processedItem: DataItem = {
|
|
43
|
+
title,
|
|
44
|
+
pubDate: pubDateStr ? parseDate(pubDateStr) : undefined,
|
|
45
|
+
link: linkUrl ? new URL(linkUrl, baseUrl).href : undefined,
|
|
46
|
+
category: categories,
|
|
47
|
+
image,
|
|
48
|
+
banner: image,
|
|
49
|
+
updated: upDatedStr ? parseDate(upDatedStr) : undefined,
|
|
50
|
+
language,
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
return processedItem;
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
items = (
|
|
57
|
+
await Promise.all(
|
|
58
|
+
items.map((item) => {
|
|
59
|
+
if (!item.link) {
|
|
60
|
+
return item;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return cache.tryGet(item.link, async (): Promise<DataItem> => {
|
|
64
|
+
const detailResponse = await ofetch(item.link);
|
|
65
|
+
const $$: CheerioAPI = load(detailResponse);
|
|
66
|
+
|
|
67
|
+
$$('div.entry-content img.alignnone').each((_, el) => {
|
|
68
|
+
const $el: Cheerio<Element> = $$(el);
|
|
69
|
+
|
|
70
|
+
$el.replaceWith(
|
|
71
|
+
art(path.join(__dirname, 'templates/description.art'), {
|
|
72
|
+
images: $el.attr('src')
|
|
73
|
+
? [
|
|
74
|
+
{
|
|
75
|
+
src: $el.attr('src'),
|
|
76
|
+
width: $el.attr('width'),
|
|
77
|
+
height: $el.attr('height'),
|
|
78
|
+
},
|
|
79
|
+
]
|
|
80
|
+
: undefined,
|
|
81
|
+
})
|
|
82
|
+
);
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
const title: string = $$('h1.entry-title').text();
|
|
86
|
+
const pubDateStr: string | undefined = $$('time.entry-date').attr('datetime');
|
|
87
|
+
const categoryEls: Element[] = $$('ul.post-categories li').toArray();
|
|
88
|
+
const categories: string[] = [...new Set(categoryEls.map((el) => $$(el).text()).filter(Boolean))];
|
|
89
|
+
const upDatedStr: string | undefined = pubDateStr;
|
|
90
|
+
|
|
91
|
+
let processedItem: DataItem = {
|
|
92
|
+
title,
|
|
93
|
+
pubDate: pubDateStr ? parseDate(pubDateStr) : item.pubDate,
|
|
94
|
+
category: categories,
|
|
95
|
+
updated: upDatedStr ? parseDate(upDatedStr) : item.updated,
|
|
96
|
+
language,
|
|
97
|
+
};
|
|
98
|
+
|
|
99
|
+
const extraLinkEls: Element[] = $$('ul.related_post li a').toArray();
|
|
100
|
+
const extraLinks = extraLinkEls
|
|
101
|
+
.map((extraLinkEl) => {
|
|
102
|
+
const $$extraLinkEl: Cheerio<Element> = $$(extraLinkEl);
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
url: $$extraLinkEl.attr('href'),
|
|
106
|
+
type: 'related',
|
|
107
|
+
content_html: $$extraLinkEl.text(),
|
|
108
|
+
};
|
|
109
|
+
})
|
|
110
|
+
.filter((_): _ is { url: string; type: string; content_html: string } => true);
|
|
111
|
+
|
|
112
|
+
if (extraLinks) {
|
|
113
|
+
processedItem = {
|
|
114
|
+
...processedItem,
|
|
115
|
+
_extra: {
|
|
116
|
+
links: extraLinks,
|
|
117
|
+
},
|
|
118
|
+
};
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
$$('ul.related_post').parent().remove();
|
|
122
|
+
|
|
123
|
+
const description: string | undefined = $$('div.entry-content').html();
|
|
124
|
+
|
|
125
|
+
processedItem = {
|
|
126
|
+
...processedItem,
|
|
127
|
+
description,
|
|
128
|
+
content: {
|
|
129
|
+
html: description,
|
|
130
|
+
text: description,
|
|
131
|
+
},
|
|
132
|
+
};
|
|
133
|
+
|
|
134
|
+
return {
|
|
135
|
+
...item,
|
|
136
|
+
...processedItem,
|
|
137
|
+
};
|
|
138
|
+
});
|
|
139
|
+
})
|
|
140
|
+
)
|
|
141
|
+
).filter((_): _ is DataItem => true);
|
|
142
|
+
|
|
143
|
+
const title: string = $('title').text();
|
|
144
|
+
|
|
145
|
+
return {
|
|
146
|
+
title,
|
|
147
|
+
description: $('meta[name="description"]').attr('content'),
|
|
148
|
+
link: targetUrl,
|
|
149
|
+
item: items,
|
|
150
|
+
allowEmpty: true,
|
|
151
|
+
image: $('h3.site-title img').attr('src'),
|
|
152
|
+
author: title.split(/-/).pop()?.trim(),
|
|
153
|
+
language,
|
|
154
|
+
id: targetUrl,
|
|
155
|
+
};
|
|
156
|
+
};
|
|
157
|
+
|
|
158
|
+
export const route: Route = {
|
|
159
|
+
path: '/:category{.+}?',
|
|
160
|
+
name: '资讯',
|
|
161
|
+
url: '199it.com',
|
|
162
|
+
maintainers: ['nczitzk'],
|
|
163
|
+
handler,
|
|
164
|
+
example: '/199it/newly',
|
|
165
|
+
parameters: {
|
|
166
|
+
category: {
|
|
167
|
+
description: '分类,默认为 `newly`,即最新,可在对应分类页 URL 中找到',
|
|
168
|
+
options: [
|
|
169
|
+
{
|
|
170
|
+
label: '最新',
|
|
171
|
+
value: 'newly',
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
label: '报告',
|
|
175
|
+
value: 'archives/category/report',
|
|
176
|
+
},
|
|
177
|
+
{
|
|
178
|
+
label: '新兴产业',
|
|
179
|
+
value: 'archives/category/emerging',
|
|
180
|
+
},
|
|
181
|
+
{
|
|
182
|
+
label: '金融科技',
|
|
183
|
+
value: 'archives/category/fintech',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
label: '共享经济',
|
|
187
|
+
value: 'archives/category/sharingeconomy',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
label: '移动互联网',
|
|
191
|
+
value: 'archives/category/mobile-internet',
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
label: '电子商务',
|
|
195
|
+
value: 'archives/category/electronic-commerce',
|
|
196
|
+
},
|
|
197
|
+
{
|
|
198
|
+
label: '社交网络',
|
|
199
|
+
value: 'archives/category/social-network',
|
|
200
|
+
},
|
|
201
|
+
{
|
|
202
|
+
label: '网络广告',
|
|
203
|
+
value: 'archives/category/advertising',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
label: '投资&经济,互联网金融',
|
|
207
|
+
value: 'archives/category/economic-data',
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
label: '服务',
|
|
211
|
+
value: 'archives/category/service',
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
label: '网络服务行业',
|
|
215
|
+
value: 'archives/category/dataindustry',
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
label: '用户研究',
|
|
219
|
+
value: 'archives/category/internet-users',
|
|
220
|
+
},
|
|
221
|
+
],
|
|
222
|
+
},
|
|
223
|
+
},
|
|
224
|
+
description: `:::tip
|
|
225
|
+
若订阅 [研究报告](https://www.199it.com/archives/category/report),网址为 \`https://www.199it.com/archives/category/report\`,请截取 \`https://www.199it.com/archives/category/report\` 到末尾的部分 \`archives/category/report\` 作为 \`category\` 参数填入,此时目标路由为 [\`/199it/archives/category/report\`](https://rsshub.app/199it/archives/category/report)。
|
|
226
|
+
:::
|
|
227
|
+
|
|
228
|
+
<details>
|
|
229
|
+
<summary>更多分类</summary>
|
|
230
|
+
|
|
231
|
+
| 分类 | ID |
|
|
232
|
+
| --------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------- |
|
|
233
|
+
| [报告](http://www.199it.com/archives/category/report) | [archives/category/report](https://rsshub.app/199it/archives/category/report) |
|
|
234
|
+
| [新兴产业](http://www.199it.com/archives/category/emerging) | [archives/category/emerging](https://rsshub.app/199it/archives/category/emerging) |
|
|
235
|
+
| [金融科技](http://www.199it.com/archives/category/fintech) | [archives/category/fintech](https://rsshub.app/199it/archives/category/fintech) |
|
|
236
|
+
| [共享经济](http://www.199it.com/archives/category/sharingeconomy) | [archives/category/sharingeconomy](https://rsshub.app/199it/archives/category/sharingeconomy) |
|
|
237
|
+
| [移动互联网](http://www.199it.com/archives/category/mobile-internet) | [archives/category/mobile-internet](https://rsshub.app/199it/archives/category/mobile-internet) |
|
|
238
|
+
| [电子商务](http://www.199it.com/archives/category/electronic-commerce) | [archives/category/electronic-commerce](https://rsshub.app/199it/archives/category/electronic-commerce) |
|
|
239
|
+
| [社交网络](http://www.199it.com/archives/category/social-network) | [archives/category/social-network](https://rsshub.app/199it/archives/category/social-network) |
|
|
240
|
+
| [网络广告](http://www.199it.com/archives/category/advertising) | [archives/category/advertising](https://rsshub.app/199it/archives/category/advertising) |
|
|
241
|
+
| [投资&经济,互联网金融](http://www.199it.com/archives/category/economic-data) | [archives/category/economic-data](https://rsshub.app/199it/archives/category/economic-data) |
|
|
242
|
+
| [服务](http://www.199it.com/archives/category/service) | [archives/category/service](https://rsshub.app/199it/archives/category/service) |
|
|
243
|
+
| [网络服务行业](http://www.199it.com/archives/category/dataindustry) | [archives/category/dataindustry](https://rsshub.app/199it/archives/category/dataindustry) |
|
|
244
|
+
| [用户研究](http://www.199it.com/archives/category/internet-users) | [archives/category/internet-users](https://rsshub.app/199it/archives/category/internet-users) |
|
|
245
|
+
|
|
246
|
+
</details>
|
|
247
|
+
`,
|
|
248
|
+
categories: ['new-media'],
|
|
249
|
+
features: {
|
|
250
|
+
requireConfig: false,
|
|
251
|
+
requirePuppeteer: false,
|
|
252
|
+
antiCrawler: false,
|
|
253
|
+
supportRadar: true,
|
|
254
|
+
supportBT: false,
|
|
255
|
+
supportPodcast: false,
|
|
256
|
+
supportScihub: false,
|
|
257
|
+
},
|
|
258
|
+
radar: [
|
|
259
|
+
{
|
|
260
|
+
source: ['www.199it.com/:category'],
|
|
261
|
+
target: (params) => {
|
|
262
|
+
const category: string = params.category;
|
|
263
|
+
|
|
264
|
+
return `/199it${category ? `/${category}` : ''}`;
|
|
265
|
+
},
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
title: '最新',
|
|
269
|
+
source: ['www.199it.com/newly'],
|
|
270
|
+
target: '/newly',
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
title: '报告',
|
|
274
|
+
source: ['www.199it.com/archives/category/report'],
|
|
275
|
+
target: '/archives/category/report',
|
|
276
|
+
},
|
|
277
|
+
{
|
|
278
|
+
title: '新兴产业',
|
|
279
|
+
source: ['www.199it.com/archives/category/emerging'],
|
|
280
|
+
target: '/archives/category/emerging',
|
|
281
|
+
},
|
|
282
|
+
{
|
|
283
|
+
title: '金融科技',
|
|
284
|
+
source: ['www.199it.com/archives/category/fintech'],
|
|
285
|
+
target: '/archives/category/fintech',
|
|
286
|
+
},
|
|
287
|
+
{
|
|
288
|
+
title: '共享经济',
|
|
289
|
+
source: ['www.199it.com/archives/category/sharingeconomy'],
|
|
290
|
+
target: '/archives/category/sharingeconomy',
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
title: '移动互联网',
|
|
294
|
+
source: ['www.199it.com/archives/category/mobile-internet'],
|
|
295
|
+
target: '/archives/category/mobile-internet',
|
|
296
|
+
},
|
|
297
|
+
{
|
|
298
|
+
title: '电子商务',
|
|
299
|
+
source: ['www.199it.com/archives/category/electronic-commerce'],
|
|
300
|
+
target: '/archives/category/electronic-commerce',
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
title: '社交网络',
|
|
304
|
+
source: ['www.199it.com/archives/category/social-network'],
|
|
305
|
+
target: '/archives/category/social-network',
|
|
306
|
+
},
|
|
307
|
+
{
|
|
308
|
+
title: '网络广告',
|
|
309
|
+
source: ['www.199it.com/archives/category/advertising'],
|
|
310
|
+
target: '/archives/category/advertising',
|
|
311
|
+
},
|
|
312
|
+
{
|
|
313
|
+
title: '投资&经济,互联网金融',
|
|
314
|
+
source: ['www.199it.com/archives/category/economic-data'],
|
|
315
|
+
target: '/archives/category/economic-data',
|
|
316
|
+
},
|
|
317
|
+
{
|
|
318
|
+
title: '服务',
|
|
319
|
+
source: ['www.199it.com/archives/category/service'],
|
|
320
|
+
target: '/archives/category/service',
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
title: '网络服务行业',
|
|
324
|
+
source: ['www.199it.com/archives/category/dataindustry'],
|
|
325
|
+
target: '/archives/category/dataindustry',
|
|
326
|
+
},
|
|
327
|
+
{
|
|
328
|
+
title: '用户研究',
|
|
329
|
+
source: ['www.199it.com/archives/category/internet-users'],
|
|
330
|
+
target: '/archives/category/internet-users',
|
|
331
|
+
},
|
|
332
|
+
],
|
|
333
|
+
view: ViewType.Articles,
|
|
334
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
{{ if images }}
|
|
2
|
+
{{ each images image }}
|
|
3
|
+
{{ if image?.src }}
|
|
4
|
+
<figure>
|
|
5
|
+
<img
|
|
6
|
+
{{ if image.width }}
|
|
7
|
+
width="{{ image.width }}"
|
|
8
|
+
{{ /if }}
|
|
9
|
+
{{ if image.height }}
|
|
10
|
+
height="{{ image.height }}"
|
|
11
|
+
{{ /if }}
|
|
12
|
+
src="{{ image.src }}">
|
|
13
|
+
</figure>
|
|
14
|
+
{{ /if }}
|
|
15
|
+
{{ /each }}
|
|
16
|
+
{{ /if }}
|
|
17
|
+
|
|
18
|
+
{{ if description }}
|
|
19
|
+
{{@ description }}
|
|
20
|
+
{{ /if }}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { type Data, type DataItem, type Route, ViewType } from '@/types';
|
|
2
|
+
|
|
3
|
+
import { art } from '@/utils/render';
|
|
4
|
+
import cache from '@/utils/cache';
|
|
5
|
+
import { getCurrentPath } from '@/utils/helpers';
|
|
6
|
+
import ofetch from '@/utils/ofetch';
|
|
7
|
+
import { parseDate } from '@/utils/parse-date';
|
|
8
|
+
import timezone from '@/utils/timezone';
|
|
9
|
+
|
|
10
|
+
import { type CheerioAPI, type Cheerio, type Element, load } from 'cheerio';
|
|
11
|
+
import { type Context } from 'hono';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
|
|
14
|
+
const __dirname = getCurrentPath(import.meta.url);
|
|
15
|
+
|
|
16
|
+
export const handler = async (ctx: Context): Promise<Data> => {
|
|
17
|
+
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '24', 10);
|
|
18
|
+
|
|
19
|
+
const baseUrl: string = 'https://www.adquan.com';
|
|
20
|
+
const targetUrl: string = new URL('case_library/index', baseUrl).href;
|
|
21
|
+
|
|
22
|
+
const response = await ofetch(targetUrl);
|
|
23
|
+
const $: CheerioAPI = load(response);
|
|
24
|
+
const language = $('html').attr('lang') ?? 'zh-CN';
|
|
25
|
+
|
|
26
|
+
let items: DataItem[] = [];
|
|
27
|
+
|
|
28
|
+
items = $('div.article_1')
|
|
29
|
+
.slice(0, limit)
|
|
30
|
+
.toArray()
|
|
31
|
+
.map((el): Element => {
|
|
32
|
+
const $el: Cheerio<Element> = $(el);
|
|
33
|
+
|
|
34
|
+
const title: string = $el.find('p.article_2_p').text();
|
|
35
|
+
const description: string | undefined = art(path.join(__dirname, 'templates/description.art'), {
|
|
36
|
+
intro: $el.find('div.article_1_fu p').first().text(),
|
|
37
|
+
});
|
|
38
|
+
const pubDateStr: string | undefined = $el.find('div.article_1_fu p').last().text();
|
|
39
|
+
const linkUrl: string | undefined = $el.find('a.article_2_href').attr('href');
|
|
40
|
+
const authors: DataItem['author'] = $el.find('div.article_4').text();
|
|
41
|
+
const image: string | undefined = $el.find('img.article_1_img').attr('src');
|
|
42
|
+
const upDatedStr: string | undefined = pubDateStr;
|
|
43
|
+
|
|
44
|
+
const processedItem: DataItem = {
|
|
45
|
+
title,
|
|
46
|
+
description,
|
|
47
|
+
pubDate: pubDateStr ? parseDate(pubDateStr) : undefined,
|
|
48
|
+
link: linkUrl,
|
|
49
|
+
author: authors,
|
|
50
|
+
content: {
|
|
51
|
+
html: description,
|
|
52
|
+
text: description,
|
|
53
|
+
},
|
|
54
|
+
image,
|
|
55
|
+
banner: image,
|
|
56
|
+
updated: upDatedStr ? parseDate(upDatedStr) : undefined,
|
|
57
|
+
language,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return processedItem;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
items = (
|
|
64
|
+
await Promise.all(
|
|
65
|
+
items.map((item) => {
|
|
66
|
+
if (!item.link) {
|
|
67
|
+
return item;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return cache.tryGet(item.link, async (): Promise<DataItem> => {
|
|
71
|
+
const detailResponse = await ofetch(item.link);
|
|
72
|
+
const $$: CheerioAPI = load(detailResponse);
|
|
73
|
+
|
|
74
|
+
const title: string = $$('p.infoTitle_left').text();
|
|
75
|
+
const description: string | undefined = art(path.join(__dirname, 'templates/description.art'), {
|
|
76
|
+
description: $$('div.articleContent').html(),
|
|
77
|
+
});
|
|
78
|
+
const pubDateStr: string | undefined = $$('p.time').text().split(/:/).pop();
|
|
79
|
+
const categoryEls: Element[] = $$('span.article_5').toArray();
|
|
80
|
+
const categories: string[] = [...new Set(categoryEls.map((el) => $$(el).text()).filter(Boolean))];
|
|
81
|
+
const authors: DataItem['author'] = $$('div.infoTitle_right span').text();
|
|
82
|
+
const upDatedStr: string | undefined = pubDateStr;
|
|
83
|
+
|
|
84
|
+
const processedItem: DataItem = {
|
|
85
|
+
title,
|
|
86
|
+
description,
|
|
87
|
+
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
|
|
88
|
+
category: categories,
|
|
89
|
+
author: authors,
|
|
90
|
+
content: {
|
|
91
|
+
html: description,
|
|
92
|
+
text: description,
|
|
93
|
+
},
|
|
94
|
+
updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
|
|
95
|
+
language,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
...item,
|
|
100
|
+
...processedItem,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
).filter((_): _ is DataItem => true);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
title: $('title').text(),
|
|
109
|
+
description: $('meta[name="description"]').attr('content'),
|
|
110
|
+
link: targetUrl,
|
|
111
|
+
item: items,
|
|
112
|
+
allowEmpty: true,
|
|
113
|
+
image: $('img.navi_logo').attr('src'),
|
|
114
|
+
author: $('meta[name="author"]').attr('content'),
|
|
115
|
+
language,
|
|
116
|
+
id: targetUrl,
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const route: Route = {
|
|
121
|
+
path: '/case_library',
|
|
122
|
+
name: '案例库',
|
|
123
|
+
url: 'www.adquan.com',
|
|
124
|
+
maintainers: ['nczitzk'],
|
|
125
|
+
handler,
|
|
126
|
+
example: '/adquan/case_library',
|
|
127
|
+
parameters: undefined,
|
|
128
|
+
description: undefined,
|
|
129
|
+
categories: ['new-media'],
|
|
130
|
+
features: {
|
|
131
|
+
requireConfig: false,
|
|
132
|
+
requirePuppeteer: false,
|
|
133
|
+
antiCrawler: false,
|
|
134
|
+
supportRadar: true,
|
|
135
|
+
supportBT: false,
|
|
136
|
+
supportPodcast: false,
|
|
137
|
+
supportScihub: false,
|
|
138
|
+
},
|
|
139
|
+
radar: [
|
|
140
|
+
{
|
|
141
|
+
source: ['www.adquan.com/case_library/index'],
|
|
142
|
+
target: '/case_library',
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
view: ViewType.Articles,
|
|
146
|
+
};
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
import { type Data, type DataItem, type Route, ViewType } from '@/types';
|
|
2
|
+
|
|
3
|
+
import { art } from '@/utils/render';
|
|
4
|
+
import cache from '@/utils/cache';
|
|
5
|
+
import { getCurrentPath } from '@/utils/helpers';
|
|
6
|
+
import ofetch from '@/utils/ofetch';
|
|
7
|
+
import { parseDate } from '@/utils/parse-date';
|
|
8
|
+
import timezone from '@/utils/timezone';
|
|
9
|
+
|
|
10
|
+
import { type CheerioAPI, type Cheerio, type Element, load } from 'cheerio';
|
|
11
|
+
import { type Context } from 'hono';
|
|
12
|
+
import path from 'node:path';
|
|
13
|
+
|
|
14
|
+
const __dirname = getCurrentPath(import.meta.url);
|
|
15
|
+
|
|
16
|
+
export const handler = async (ctx: Context): Promise<Data> => {
|
|
17
|
+
const limit: number = Number.parseInt(ctx.req.query('limit') ?? '30', 10);
|
|
18
|
+
|
|
19
|
+
const baseUrl: string = 'https://www.adquan.com';
|
|
20
|
+
const targetUrl: string = baseUrl;
|
|
21
|
+
|
|
22
|
+
const response = await ofetch(targetUrl);
|
|
23
|
+
const $: CheerioAPI = load(response);
|
|
24
|
+
const language = $('html').attr('lang') ?? 'zh-CN';
|
|
25
|
+
|
|
26
|
+
let items: DataItem[] = [];
|
|
27
|
+
|
|
28
|
+
items = $('div.article_1')
|
|
29
|
+
.slice(0, limit)
|
|
30
|
+
.toArray()
|
|
31
|
+
.map((el): Element => {
|
|
32
|
+
const $el: Cheerio<Element> = $(el);
|
|
33
|
+
|
|
34
|
+
const title: string = $el.find('p.article_2_p').text();
|
|
35
|
+
const description: string | undefined = art(path.join(__dirname, 'templates/description.art'), {
|
|
36
|
+
intro: $el.find('div.article_1_fu p').first().text(),
|
|
37
|
+
});
|
|
38
|
+
const pubDateStr: string | undefined = $el.find('div.article_1_fu p').last().text();
|
|
39
|
+
const linkUrl: string | undefined = $el.find('a.article_2_href').attr('href');
|
|
40
|
+
const authors: DataItem['author'] = $el.find('div.article_4').text();
|
|
41
|
+
const image: string | undefined = $el.find('img.article_1_img').attr('src');
|
|
42
|
+
const upDatedStr: string | undefined = pubDateStr;
|
|
43
|
+
|
|
44
|
+
const processedItem: DataItem = {
|
|
45
|
+
title,
|
|
46
|
+
description,
|
|
47
|
+
pubDate: pubDateStr ? parseDate(pubDateStr) : undefined,
|
|
48
|
+
link: linkUrl,
|
|
49
|
+
author: authors,
|
|
50
|
+
content: {
|
|
51
|
+
html: description,
|
|
52
|
+
text: description,
|
|
53
|
+
},
|
|
54
|
+
image,
|
|
55
|
+
banner: image,
|
|
56
|
+
updated: upDatedStr ? parseDate(upDatedStr) : undefined,
|
|
57
|
+
language,
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
return processedItem;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
items = (
|
|
64
|
+
await Promise.all(
|
|
65
|
+
items.map((item) => {
|
|
66
|
+
if (!item.link) {
|
|
67
|
+
return item;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
return cache.tryGet(item.link, async (): Promise<DataItem> => {
|
|
71
|
+
const detailResponse = await ofetch(item.link);
|
|
72
|
+
const $$: CheerioAPI = load(detailResponse);
|
|
73
|
+
|
|
74
|
+
const title: string = $$('p.infoTitle_left').text();
|
|
75
|
+
const description: string | undefined = art(path.join(__dirname, 'templates/description.art'), {
|
|
76
|
+
description: $$('div.articleContent').html(),
|
|
77
|
+
});
|
|
78
|
+
const pubDateStr: string | undefined = $$('p.time').text().split(/:/).pop();
|
|
79
|
+
const categoryEls: Element[] = $$('span.article_5').toArray();
|
|
80
|
+
const categories: string[] = [...new Set(categoryEls.map((el) => $$(el).text()).filter(Boolean))];
|
|
81
|
+
const authors: DataItem['author'] = $$('div.infoTitle_right span').text();
|
|
82
|
+
const upDatedStr: string | undefined = pubDateStr;
|
|
83
|
+
|
|
84
|
+
const processedItem: DataItem = {
|
|
85
|
+
title,
|
|
86
|
+
description,
|
|
87
|
+
pubDate: pubDateStr ? timezone(parseDate(pubDateStr), +8) : item.pubDate,
|
|
88
|
+
category: categories,
|
|
89
|
+
author: authors,
|
|
90
|
+
content: {
|
|
91
|
+
html: description,
|
|
92
|
+
text: description,
|
|
93
|
+
},
|
|
94
|
+
updated: upDatedStr ? timezone(parseDate(upDatedStr), +8) : item.updated,
|
|
95
|
+
language,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
return {
|
|
99
|
+
...item,
|
|
100
|
+
...processedItem,
|
|
101
|
+
};
|
|
102
|
+
});
|
|
103
|
+
})
|
|
104
|
+
)
|
|
105
|
+
).filter((_): _ is DataItem => true);
|
|
106
|
+
|
|
107
|
+
return {
|
|
108
|
+
title: $('title').text(),
|
|
109
|
+
description: $('meta[name="description"]').attr('content'),
|
|
110
|
+
link: targetUrl,
|
|
111
|
+
item: items,
|
|
112
|
+
allowEmpty: true,
|
|
113
|
+
image: $('img.navi_logo').attr('src'),
|
|
114
|
+
author: $('meta[name="author"]').attr('content'),
|
|
115
|
+
language,
|
|
116
|
+
id: targetUrl,
|
|
117
|
+
};
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
export const route: Route = {
|
|
121
|
+
path: '/',
|
|
122
|
+
name: '最新文章',
|
|
123
|
+
url: 'www.adquan.com',
|
|
124
|
+
maintainers: ['nczitzk'],
|
|
125
|
+
handler,
|
|
126
|
+
example: '/adquan',
|
|
127
|
+
parameters: undefined,
|
|
128
|
+
description: undefined,
|
|
129
|
+
categories: ['new-media'],
|
|
130
|
+
features: {
|
|
131
|
+
requireConfig: false,
|
|
132
|
+
requirePuppeteer: false,
|
|
133
|
+
antiCrawler: false,
|
|
134
|
+
supportRadar: true,
|
|
135
|
+
supportBT: false,
|
|
136
|
+
supportPodcast: false,
|
|
137
|
+
supportScihub: false,
|
|
138
|
+
},
|
|
139
|
+
radar: [
|
|
140
|
+
{
|
|
141
|
+
source: ['www.adquan.com'],
|
|
142
|
+
target: '/',
|
|
143
|
+
},
|
|
144
|
+
],
|
|
145
|
+
view: ViewType.Articles,
|
|
146
|
+
};
|