rsshub 1.0.0-master.f71451d → 1.0.0-master.f75997f
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.ts +14 -0
- package/lib/errors/index.test.ts +2 -2
- package/lib/middleware/template.tsx +12 -3
- package/lib/routes/0x80/index.ts +87 -0
- package/lib/routes/0x80/namespace.ts +7 -0
- package/lib/routes/aljazeera/index.ts +17 -14
- package/lib/routes/apple/podcast.ts +64 -0
- package/lib/routes/bilibili/cache.ts +1 -1
- package/lib/routes/bing/daily-wallpaper.ts +9 -8
- package/lib/routes/byau/namespace.ts +6 -0
- package/lib/routes/byau/xinwen/index.ts +72 -0
- package/lib/routes/cpcaauto/index.ts +255 -0
- package/lib/routes/cpcaauto/namespace.ts +8 -0
- package/lib/routes/dehenglaw/index.ts +128 -0
- package/lib/routes/dehenglaw/namespace.ts +8 -0
- package/lib/routes/dehenglaw/templates/description.art +7 -0
- package/lib/routes/gov/stats/index.ts +25 -22
- package/lib/routes/gxmzu/ai.ts +1 -1
- package/lib/routes/gxmzu/lib.ts +9 -26
- package/lib/routes/gxmzu/utils/index.ts +31 -13
- package/lib/routes/gxmzu/yjs.ts +1 -1
- package/lib/routes/jou/utils/index.ts +35 -25
- package/lib/routes/lofter/tag.ts +3 -3
- package/lib/routes/lofter/user.ts +3 -3
- package/lib/routes/njxzc/utils/index.ts +31 -13
- package/lib/routes/qingting/podcast.ts +61 -39
- package/lib/routes/reuters/common.ts +2 -2
- package/lib/routes/sara/index.ts +66 -0
- package/lib/routes/sara/namespace.ts +6 -0
- package/lib/routes/tencent/news/author.ts +13 -11
- package/lib/routes/test/index.ts +11 -1
- package/lib/routes/twitter/api/mobile-api/login.ts +29 -28
- package/lib/routes/twitter/namespace.ts +2 -2
- package/lib/routes/twitter/user.ts +5 -0
- package/lib/routes/u3c3/index.ts +1 -1
- package/lib/routes/u3c3/namespace.ts +1 -1
- package/lib/routes/u9a9/index.ts +2 -2
- package/lib/routes/u9a9/namespace.ts +1 -1
- package/lib/routes/zsxq/group.ts +63 -0
- package/lib/routes/zsxq/namespace.ts +6 -0
- package/lib/routes/zsxq/types.ts +149 -0
- package/lib/routes/zsxq/user.ts +58 -0
- package/lib/routes/zsxq/utils.ts +70 -0
- package/lib/setup.test.ts +183 -12
- package/lib/utils/render.ts +1 -1
- package/lib/utils/request-rewriter/get.ts +8 -1
- package/lib/utils/wechat-mp.test.ts +411 -32
- package/lib/utils/wechat-mp.ts +447 -76
- package/lib/views/{rss3-ums.ts → rss3.ts} +2 -2
- package/package.json +14 -14
|
@@ -0,0 +1,255 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
|
|
3
|
+
import cache from '@/utils/cache';
|
|
4
|
+
import got from '@/utils/got';
|
|
5
|
+
import { load } from 'cheerio';
|
|
6
|
+
import timezone from '@/utils/timezone';
|
|
7
|
+
import { parseDate } from '@/utils/parse-date';
|
|
8
|
+
|
|
9
|
+
export const handler = async (ctx) => {
|
|
10
|
+
const { type = 'news', id } = ctx.req.param();
|
|
11
|
+
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20;
|
|
12
|
+
|
|
13
|
+
const rootUrl = 'http://cpcaauto.com';
|
|
14
|
+
const currentUrl = new URL(`news.php${type ? `?types=${type}${id ? `&anid=${id}` : ''}` : ''}`, rootUrl).href;
|
|
15
|
+
|
|
16
|
+
const { data: response } = await got(currentUrl);
|
|
17
|
+
|
|
18
|
+
const $ = load(response);
|
|
19
|
+
|
|
20
|
+
const language = 'zh';
|
|
21
|
+
|
|
22
|
+
let items = $('div.list_d ul li.q')
|
|
23
|
+
.slice(0, limit)
|
|
24
|
+
.toArray()
|
|
25
|
+
.map((item) => {
|
|
26
|
+
item = $(item);
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
title: item.find('a').text(),
|
|
30
|
+
pubDate: parseDate(item.find('span').text().trim()),
|
|
31
|
+
link: new URL(item.find('a').prop('href'), rootUrl).href,
|
|
32
|
+
};
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
items = await Promise.all(
|
|
36
|
+
items.map((item) =>
|
|
37
|
+
cache.tryGet(item.link, async () => {
|
|
38
|
+
const { data: detailResponse } = await got(item.link);
|
|
39
|
+
|
|
40
|
+
const $$ = load(detailResponse);
|
|
41
|
+
|
|
42
|
+
const title = $$('div.tit').text();
|
|
43
|
+
const description = $$('div.text').html();
|
|
44
|
+
|
|
45
|
+
item.title = title;
|
|
46
|
+
item.description = description;
|
|
47
|
+
item.pubDate = timezone(parseDate($$('div.view span').first().text().split(/:/).pop()), +8);
|
|
48
|
+
item.content = {
|
|
49
|
+
html: description,
|
|
50
|
+
text: $$('div.text').text(),
|
|
51
|
+
};
|
|
52
|
+
item.language = language;
|
|
53
|
+
|
|
54
|
+
return item;
|
|
55
|
+
})
|
|
56
|
+
)
|
|
57
|
+
);
|
|
58
|
+
|
|
59
|
+
const image = new URL($('meta[property="og:image"]').prop('content'), rootUrl).href;
|
|
60
|
+
|
|
61
|
+
return {
|
|
62
|
+
title: `${$('title').text()} - ${$('span.main_color')
|
|
63
|
+
.toArray()
|
|
64
|
+
.map((a) => $(a).text())
|
|
65
|
+
.join(' - ')}`,
|
|
66
|
+
description: $('META[name="description"]').prop('content'),
|
|
67
|
+
link: currentUrl,
|
|
68
|
+
item: items,
|
|
69
|
+
allowEmpty: true,
|
|
70
|
+
image,
|
|
71
|
+
author: $('meta[name="keywords"]').prop('content'),
|
|
72
|
+
language,
|
|
73
|
+
};
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export const route: Route = {
|
|
77
|
+
path: '/news/:type?/:id?',
|
|
78
|
+
name: '文章',
|
|
79
|
+
url: 'cpcaauto.com',
|
|
80
|
+
maintainers: ['nczitzk'],
|
|
81
|
+
handler,
|
|
82
|
+
example: '/cpcaauto/news/news',
|
|
83
|
+
parameters: { type: '分类,默认为 news,可在对应分类页 URL 中找到', id: 'id,默认为 news,可在对应分类页 URL 中找到' },
|
|
84
|
+
description: `:::tip
|
|
85
|
+
若订阅 [行业新闻 > 国内乘用车](http://cpcaauto.com/news.php?types=news&anid=10),网址为 \`http://cpcaauto.com/news.php?types=news&anid=10\`。截取 \`types\` 和 \`anid\` 的部分 \`\` 作为参数填入,此时路由为 [\`/cpcaauto/news/news/10\`](https://rsshub.app/cpcaauto/news/news/10)。
|
|
86
|
+
:::
|
|
87
|
+
|
|
88
|
+
#### [行业新闻](http://cpcaauto.com/news.php?types=news)
|
|
89
|
+
|
|
90
|
+
| [国内乘用车](http://cpcaauto.com/news.php?types=news&anid=10) | [进口及国外乘用车](http://cpcaauto.com/news.php?types=news&anid=64) | [后市场](http://cpcaauto.com/news.php?types=news&anid=44) | [商用车](http://cpcaauto.com/news.php?types=news&anid=62) |
|
|
91
|
+
| ----------------------------------------------------------------- | ----------------------------------------------------------------------- | ------------------------------------------------------------- | ------------------------------------------------------------- |
|
|
92
|
+
| [news/10](https://rsshub.app/cpcaauto/news/news/10) | [news/64](https://rsshub.app/cpcaauto/news/news/64) | [news/44](https://rsshub.app/cpcaauto/news/news/44) | [news/62](https://rsshub.app/cpcaauto/news/news/62) |
|
|
93
|
+
|
|
94
|
+
#### [车市解读](http://cpcaauto.com/news.php?types=csjd)
|
|
95
|
+
|
|
96
|
+
| [周度](http://cpcaauto.com/news.php?types=csjd&anid=128) | [月度](http://cpcaauto.com/news.php?types=csjd&anid=129) | [指数](http://cpcaauto.com/news.php?types=csjd&anid=130) | [预测](http://cpcaauto.com/news.php?types=csjd&anid=131) |
|
|
97
|
+
| ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ |
|
|
98
|
+
| [csjd/128](https://rsshub.app/cpcaauto/news/csjd/128) | [csjd/129](https://rsshub.app/cpcaauto/news/csjd/129) | [csjd/130](https://rsshub.app/cpcaauto/news/csjd/130) | [csjd/131](https://rsshub.app/cpcaauto/news/csjd/131) |
|
|
99
|
+
|
|
100
|
+
#### [发布会报告](http://cpcaauto.com/news.php?types=bgzl)
|
|
101
|
+
|
|
102
|
+
| [上海市场上牌数](http://cpcaauto.com/news.php?types=bgzl&anid=119) | [京城车市](http://cpcaauto.com/news.php?types=bgzl&anid=122) | [进口车市场分析](http://cpcaauto.com/news.php?types=bgzl&anid=120) | [二手车市场分析](http://cpcaauto.com/news.php?types=bgzl&anid=121) | [价格指数](http://cpcaauto.com/news.php?types=bgzl&anid=124) |
|
|
103
|
+
| ---------------------------------------------------------------------- | ---------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------------- | ---------------------------------------------------------------- |
|
|
104
|
+
| [bgzl/119](https://rsshub.app/cpcaauto/news/bgzl/119) | [bgzl/122](https://rsshub.app/cpcaauto/news/bgzl/122) | [bgzl/120](https://rsshub.app/cpcaauto/news/bgzl/120) | [bgzl/121](https://rsshub.app/cpcaauto/news/bgzl/121) | [bgzl/124](https://rsshub.app/cpcaauto/news/bgzl/124) |
|
|
105
|
+
|
|
106
|
+
| [热点评述](http://cpcaauto.com/news.php?types=bgzl&anid=125) | [新能源月报](http://cpcaauto.com/news.php?types=bgzl&anid=126) | [商用车月报](http://cpcaauto.com/news.php?types=bgzl&anid=127) | [政策分析](http://cpcaauto.com/news.php?types=bgzl&anid=123) |
|
|
107
|
+
| ---------------------------------------------------------------- | ------------------------------------------------------------------ | ------------------------------------------------------------------ | ---------------------------------------------------------------- |
|
|
108
|
+
| [bgzl/125](https://rsshub.app/cpcaauto/news/bgzl/125) | [bgzl/126](https://rsshub.app/cpcaauto/news/bgzl/126) | [bgzl/127](https://rsshub.app/cpcaauto/news/bgzl/127) | [bgzl/123](https://rsshub.app/cpcaauto/news/bgzl/123) |
|
|
109
|
+
|
|
110
|
+
#### [经济与政策](http://cpcaauto.com/news.php?types=meeting)
|
|
111
|
+
|
|
112
|
+
| [一周经济](http://cpcaauto.com/news.php?types=meeting&anid=46) | [一周政策](http://cpcaauto.com/news.php?types=meeting&anid=47) |
|
|
113
|
+
| ------------------------------------------------------------------ | ------------------------------------------------------------------ |
|
|
114
|
+
| [meeting/46](https://rsshub.app/cpcaauto/news/meeting/46) | [meeting/47](https://rsshub.app/cpcaauto/news/meeting/47) |
|
|
115
|
+
|
|
116
|
+
#### [乘联会论坛](http://cpcaauto.com/news.php?types=yjsy)
|
|
117
|
+
|
|
118
|
+
| [论坛文章](http://cpcaauto.com/news.php?types=yjsy&anid=49) | [两会](http://cpcaauto.com/news.php?types=yjsy&anid=111) | [车展看点](http://cpcaauto.com/news.php?types=yjsy&anid=113) |
|
|
119
|
+
| --------------------------------------------------------------- | ------------------------------------------------------------ | ---------------------------------------------------------------- |
|
|
120
|
+
| [yjsy/49](https://rsshub.app/cpcaauto/news/yjsy/49) | [yjsy/111](https://rsshub.app/cpcaauto/news/yjsy/111) | [yjsy/113](https://rsshub.app/cpcaauto/news/yjsy/113) |
|
|
121
|
+
`,
|
|
122
|
+
categories: ['new-media'],
|
|
123
|
+
|
|
124
|
+
features: {
|
|
125
|
+
requireConfig: false,
|
|
126
|
+
requirePuppeteer: false,
|
|
127
|
+
antiCrawler: false,
|
|
128
|
+
supportRadar: true,
|
|
129
|
+
supportBT: false,
|
|
130
|
+
supportPodcast: false,
|
|
131
|
+
supportScihub: false,
|
|
132
|
+
},
|
|
133
|
+
radar: [
|
|
134
|
+
{
|
|
135
|
+
source: ['cpcaauto.com/news.php'],
|
|
136
|
+
target: (_, url) => {
|
|
137
|
+
url = new URL(url);
|
|
138
|
+
const types = url.searchParams.get('types');
|
|
139
|
+
const id = url.searchParams.get('id');
|
|
140
|
+
|
|
141
|
+
return types ? `/${types}${id ? `/${id}` : ''}` : '';
|
|
142
|
+
},
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
title: '行业新闻 - 国内乘用车',
|
|
146
|
+
source: ['cpcaauto.com/news.php?types=news&anid=10'],
|
|
147
|
+
target: '/news/news/10',
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
title: '行业新闻 - 进口及国外乘用车',
|
|
151
|
+
source: ['cpcaauto.com/news.php?types=news&anid=64'],
|
|
152
|
+
target: '/news/news/64',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
title: '行业新闻 - 后市场',
|
|
156
|
+
source: ['cpcaauto.com/news.php?types=news&anid=44'],
|
|
157
|
+
target: '/news/news/44',
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
title: '行业新闻 - 商用车',
|
|
161
|
+
source: ['cpcaauto.com/news.php?types=news&anid=62'],
|
|
162
|
+
target: '/news/news/62',
|
|
163
|
+
},
|
|
164
|
+
{
|
|
165
|
+
title: '车市解读 - 周度',
|
|
166
|
+
source: ['cpcaauto.com/news.php?types=csjd&anid=128'],
|
|
167
|
+
target: '/news/csjd/128',
|
|
168
|
+
},
|
|
169
|
+
{
|
|
170
|
+
title: '车市解读 - 月度',
|
|
171
|
+
source: ['cpcaauto.com/news.php?types=csjd&anid=129'],
|
|
172
|
+
target: '/news/csjd/129',
|
|
173
|
+
},
|
|
174
|
+
{
|
|
175
|
+
title: '车市解读 - 指数',
|
|
176
|
+
source: ['cpcaauto.com/news.php?types=csjd&anid=130'],
|
|
177
|
+
target: '/news/csjd/130',
|
|
178
|
+
},
|
|
179
|
+
{
|
|
180
|
+
title: '车市解读 - 预测',
|
|
181
|
+
source: ['cpcaauto.com/news.php?types=csjd&anid=131'],
|
|
182
|
+
target: '/news/csjd/131',
|
|
183
|
+
},
|
|
184
|
+
{
|
|
185
|
+
title: '发布会报告 - 上海市场上牌数',
|
|
186
|
+
source: ['cpcaauto.com/news.php?types=bgzl&anid=119'],
|
|
187
|
+
target: '/news/bgzl/119',
|
|
188
|
+
},
|
|
189
|
+
{
|
|
190
|
+
title: '发布会报告 - 京城车市',
|
|
191
|
+
source: ['cpcaauto.com/news.php?types=bgzl&anid=122'],
|
|
192
|
+
target: '/news/bgzl/122',
|
|
193
|
+
},
|
|
194
|
+
{
|
|
195
|
+
title: '发布会报告 - 进口车市场分析',
|
|
196
|
+
source: ['cpcaauto.com/news.php?types=bgzl&anid=120'],
|
|
197
|
+
target: '/news/bgzl/120',
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
title: '发布会报告 - 二手车市场分析',
|
|
201
|
+
source: ['cpcaauto.com/news.php?types=bgzl&anid=121'],
|
|
202
|
+
target: '/news/bgzl/121',
|
|
203
|
+
},
|
|
204
|
+
{
|
|
205
|
+
title: '发布会报告 - 价格指数',
|
|
206
|
+
source: ['cpcaauto.com/news.php?types=bgzl&anid=124'],
|
|
207
|
+
target: '/news/bgzl/124',
|
|
208
|
+
},
|
|
209
|
+
{
|
|
210
|
+
title: '发布会报告 - 热点评述',
|
|
211
|
+
source: ['cpcaauto.com/news.php?types=bgzl&anid=125'],
|
|
212
|
+
target: '/news/bgzl/125',
|
|
213
|
+
},
|
|
214
|
+
{
|
|
215
|
+
title: '发布会报告 - 新能源月报',
|
|
216
|
+
source: ['cpcaauto.com/news.php?types=bgzl&anid=126'],
|
|
217
|
+
target: '/news/bgzl/126',
|
|
218
|
+
},
|
|
219
|
+
{
|
|
220
|
+
title: '发布会报告 - 商用车月报',
|
|
221
|
+
source: ['cpcaauto.com/news.php?types=bgzl&anid=127'],
|
|
222
|
+
target: '/news/bgzl/127',
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
title: '发布会报告 - 政策分析',
|
|
226
|
+
source: ['cpcaauto.com/news.php?types=bgzl&anid=123'],
|
|
227
|
+
target: '/news/bgzl/123',
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
title: '经济与政策 - 一周经济',
|
|
231
|
+
source: ['cpcaauto.com/news.php?types=meeting&anid=46'],
|
|
232
|
+
target: '/news/meeting/46',
|
|
233
|
+
},
|
|
234
|
+
{
|
|
235
|
+
title: '经济与政策 - 一周政策',
|
|
236
|
+
source: ['cpcaauto.com/news.php?types=meeting&anid=47'],
|
|
237
|
+
target: '/news/meeting/47',
|
|
238
|
+
},
|
|
239
|
+
{
|
|
240
|
+
title: '乘联会论坛 - 论坛文章',
|
|
241
|
+
source: ['cpcaauto.com/news.php?types=yjsy&anid=49'],
|
|
242
|
+
target: '/news/yjsy/49',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
title: '乘联会论坛 - 两会',
|
|
246
|
+
source: ['cpcaauto.com/news.php?types=yjsy&anid=111'],
|
|
247
|
+
target: '/news/yjsy/111',
|
|
248
|
+
},
|
|
249
|
+
{
|
|
250
|
+
title: '乘联会论坛 - 车展看点',
|
|
251
|
+
source: ['cpcaauto.com/news.php?types=yjsy&anid=113'],
|
|
252
|
+
target: '/news/yjsy/113',
|
|
253
|
+
},
|
|
254
|
+
],
|
|
255
|
+
};
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
import { getCurrentPath } from '@/utils/helpers';
|
|
3
|
+
const __dirname = getCurrentPath(import.meta.url);
|
|
4
|
+
|
|
5
|
+
import cache from '@/utils/cache';
|
|
6
|
+
import got from '@/utils/got';
|
|
7
|
+
import { load } from 'cheerio';
|
|
8
|
+
import { parseDate } from '@/utils/parse-date';
|
|
9
|
+
import { art } from '@/utils/render';
|
|
10
|
+
import path from 'node:path';
|
|
11
|
+
|
|
12
|
+
export const handler = async (ctx) => {
|
|
13
|
+
const { language = 'CN', category = 'paper' } = ctx.req.param();
|
|
14
|
+
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 6;
|
|
15
|
+
|
|
16
|
+
const rootUrl = 'https://www.dehenglaw.com';
|
|
17
|
+
const currentUrl = new URL(`${language}/${category}/0008/000901.aspx`, rootUrl).href;
|
|
18
|
+
|
|
19
|
+
const { data: response } = await got(currentUrl);
|
|
20
|
+
|
|
21
|
+
const $ = load(response);
|
|
22
|
+
|
|
23
|
+
let items = $('div.news_box ul li')
|
|
24
|
+
.slice(0, limit)
|
|
25
|
+
.toArray()
|
|
26
|
+
.map((item) => {
|
|
27
|
+
item = $(item);
|
|
28
|
+
|
|
29
|
+
const title = item.find('h2').text();
|
|
30
|
+
const description = art(path.join(__dirname, 'templates/description.art'), {
|
|
31
|
+
intro: item.find('div.deheng_newscontent p').text(),
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
return {
|
|
35
|
+
title,
|
|
36
|
+
description,
|
|
37
|
+
pubDate: parseDate(item.find('span').text(), 'YYYY/M/D'),
|
|
38
|
+
link: item.find('a').first().prop('href'),
|
|
39
|
+
};
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
items = await Promise.all(
|
|
43
|
+
items.map((item) =>
|
|
44
|
+
cache.tryGet(item.link, async () => {
|
|
45
|
+
const { data: detailResponse } = await got(item.link);
|
|
46
|
+
|
|
47
|
+
const $$ = load(detailResponse);
|
|
48
|
+
|
|
49
|
+
const description =
|
|
50
|
+
item.description +
|
|
51
|
+
art(path.join(__dirname, 'templates/description.art'), {
|
|
52
|
+
description: $$('div.news_content').html(),
|
|
53
|
+
});
|
|
54
|
+
const image = $$('div.news_content img').prop('src');
|
|
55
|
+
|
|
56
|
+
item.description = description;
|
|
57
|
+
item.author = $$('div.name h4 a').text();
|
|
58
|
+
item.content = {
|
|
59
|
+
html: description,
|
|
60
|
+
text: $$('div.news_content').text(),
|
|
61
|
+
};
|
|
62
|
+
item.image = image;
|
|
63
|
+
item.banner = image;
|
|
64
|
+
|
|
65
|
+
return item;
|
|
66
|
+
})
|
|
67
|
+
)
|
|
68
|
+
);
|
|
69
|
+
|
|
70
|
+
const image = $('div.logo_content a img').prop('src');
|
|
71
|
+
|
|
72
|
+
return {
|
|
73
|
+
title: $('title')
|
|
74
|
+
.text()
|
|
75
|
+
.replace(/\|.*?$/, `| ${$('li.onthis').text()}`),
|
|
76
|
+
description: $('meta[name="Description"]').prop('content'),
|
|
77
|
+
link: currentUrl,
|
|
78
|
+
item: items,
|
|
79
|
+
allowEmpty: true,
|
|
80
|
+
image,
|
|
81
|
+
author: $('meta[name="Description"]').prop('content'),
|
|
82
|
+
};
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export const route: Route = {
|
|
86
|
+
path: '/:language?/:category?',
|
|
87
|
+
name: '德恒探索',
|
|
88
|
+
url: 'dehenglaw.com',
|
|
89
|
+
maintainers: ['nczitzk'],
|
|
90
|
+
handler,
|
|
91
|
+
example: '/dehenglaw/CN/paper',
|
|
92
|
+
parameters: { language: '语言,默认为中文,即 CN,可在对应分类页 URL 中找到,可选 CN 和 EN', category: '分类,默认为专业文章,即 paper,可在对应分类页 URL 中找到' },
|
|
93
|
+
description: `:::tip
|
|
94
|
+
若订阅 [专业文章](https://dehenglaw.com/),网址为 \`https://www.dehenglaw.com/CN/paper/0008/000902.aspx\`。截取 \`https://dehenglaw.com/\` 到末尾 \`/0008/000902.aspx\` 的部分 \`CN/paper\` 作为参数填入,此时路由为 [\`/dehenglaw/CN/paper\`](https://rsshub.app/dehenglaw/CN/paper)。
|
|
95
|
+
|
|
96
|
+
| 专业文章 | 出版物 | 德恒论坛 |
|
|
97
|
+
| -------- | ------- | -------- |
|
|
98
|
+
| paper | publish | luntan |
|
|
99
|
+
:::`,
|
|
100
|
+
categories: ['new-media'],
|
|
101
|
+
|
|
102
|
+
features: {
|
|
103
|
+
requireConfig: false,
|
|
104
|
+
requirePuppeteer: false,
|
|
105
|
+
antiCrawler: false,
|
|
106
|
+
supportRadar: true,
|
|
107
|
+
supportBT: false,
|
|
108
|
+
supportPodcast: false,
|
|
109
|
+
supportScihub: false,
|
|
110
|
+
},
|
|
111
|
+
radar: [
|
|
112
|
+
{
|
|
113
|
+
title: '专业文章',
|
|
114
|
+
source: ['dehenglaw.com/:language/paper/0008/000902.aspx'],
|
|
115
|
+
target: '/:language/paper',
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
title: '出版物',
|
|
119
|
+
source: ['dehenglaw.com/:language/publish/0008/000903.aspx'],
|
|
120
|
+
target: '/:language/publish',
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
title: '德恒论坛',
|
|
124
|
+
source: ['dehenglaw.com/:language/luntan/0008/000901.aspx'],
|
|
125
|
+
target: '/:language/luntan',
|
|
126
|
+
},
|
|
127
|
+
],
|
|
128
|
+
};
|
|
@@ -4,7 +4,7 @@ const __dirname = getCurrentPath(import.meta.url);
|
|
|
4
4
|
|
|
5
5
|
import { getSubPath } from '@/utils/common-utils';
|
|
6
6
|
import cache from '@/utils/cache';
|
|
7
|
-
import
|
|
7
|
+
import ofetch from '@/utils/ofetch';
|
|
8
8
|
import { load } from 'cheerio';
|
|
9
9
|
import timezone from '@/utils/timezone';
|
|
10
10
|
import { parseDate } from '@/utils/parse-date';
|
|
@@ -29,9 +29,13 @@ export const route: Route = {
|
|
|
29
29
|
description: `::: tip
|
|
30
30
|
路径处填写对应页面 URL 中 \`http://www.stats.gov.cn/\` 后的字段。下面是一个例子。
|
|
31
31
|
|
|
32
|
-
若订阅 [数据 > 数据解读](http://www.stats.gov.cn/sj/sjjd/)
|
|
32
|
+
若订阅 [数据 > 数据解读](http://www.stats.gov.cn/sj/sjjd/)
|
|
33
|
+
则将对应页面 URL \`http://www.stats.gov.cn/sj/sjjd/\` 中 \`http://www.stats.gov.cn/\` 后的字段 \`sj/sjjd\` 作为路径填入。
|
|
34
|
+
此时路由为 [\`/gov/stats/sj/sjjd\`](https://rsshub.app/gov/stats/sj/sjjd)
|
|
33
35
|
|
|
34
|
-
若订阅 [新闻 > 时政要闻 > 中央精神](http://www.stats.gov.cn/xw/szyw/zyjs/)
|
|
36
|
+
若订阅 [新闻 > 时政要闻 > 中央精神](http://www.stats.gov.cn/xw/szyw/zyjs/)
|
|
37
|
+
则将对应页面 URL \`http://www.stats.gov.cn/xw/szyw/zyjs/\` 中 \`http://www.stats.gov.cn/\`
|
|
38
|
+
后的字段 \`xw/szyw/zyjs\` 作为路径填入。此时路由为 [\`/gov/stats/xw/szyw/zyjs\`](https://rsshub.app/gov/stats/xw/szyw/zyjs)
|
|
35
39
|
:::`,
|
|
36
40
|
};
|
|
37
41
|
|
|
@@ -39,25 +43,23 @@ async function handler(ctx) {
|
|
|
39
43
|
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 15;
|
|
40
44
|
const rootUrl = 'http://www.stats.gov.cn';
|
|
41
45
|
|
|
46
|
+
const { headers } = await ofetch.raw(rootUrl);
|
|
47
|
+
const sid = headers
|
|
48
|
+
?.getSetCookie()
|
|
49
|
+
.find((s) => s.startsWith('wzws_sessionid='))
|
|
50
|
+
?.split(';')[0] as string;
|
|
51
|
+
|
|
42
52
|
const pathname = getSubPath(ctx) === '/stats' ? '/sj/zxfb/' : getSubPath(ctx).replace(/^\/stats(.*)/, '$1');
|
|
43
53
|
const currentUrl = `${rootUrl}${pathname.endsWith('/') ? pathname : pathname + '/'}`;
|
|
44
54
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
const headers = {
|
|
51
|
-
cookie: response.headers['set-cookie'].join(' ').match(/(wzws_sessionid=.*?);/)[1],
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
response = await got({
|
|
55
|
-
method: 'get',
|
|
56
|
-
url: currentUrl,
|
|
57
|
-
headers,
|
|
55
|
+
const response = await ofetch(currentUrl, {
|
|
56
|
+
headers: {
|
|
57
|
+
Cookie: sid,
|
|
58
|
+
Referer: currentUrl,
|
|
59
|
+
},
|
|
58
60
|
});
|
|
59
61
|
|
|
60
|
-
const $ = load(response
|
|
62
|
+
const $ = load(response);
|
|
61
63
|
|
|
62
64
|
let items = $($('a.pchide').length === 0 ? 'a[title]' : '.list-content a.pchide')
|
|
63
65
|
.slice(0, limit)
|
|
@@ -74,13 +76,14 @@ async function handler(ctx) {
|
|
|
74
76
|
items = await Promise.all(
|
|
75
77
|
items.map((item) =>
|
|
76
78
|
cache.tryGet(item.link, async () => {
|
|
77
|
-
const detailResponse = await
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
79
|
+
const detailResponse = await ofetch(item.link, {
|
|
80
|
+
headers: {
|
|
81
|
+
Cookie: sid,
|
|
82
|
+
Referer: rootUrl,
|
|
83
|
+
},
|
|
81
84
|
});
|
|
82
85
|
|
|
83
|
-
const content = load(detailResponse
|
|
86
|
+
const content = load(detailResponse);
|
|
84
87
|
|
|
85
88
|
// articles from www.news.cn or www.gov.cn
|
|
86
89
|
|
package/lib/routes/gxmzu/ai.ts
CHANGED
|
@@ -31,7 +31,7 @@ export const route: Route = {
|
|
|
31
31
|
async function handler(ctx) {
|
|
32
32
|
const out = await getNoticeList(ctx, url, host, 'a', '.timestyle55267', {
|
|
33
33
|
title: '.titlestyle55269',
|
|
34
|
-
content: '#
|
|
34
|
+
content: '#vsb_newscontent',
|
|
35
35
|
date: '.timestyle55269',
|
|
36
36
|
});
|
|
37
37
|
|
package/lib/routes/gxmzu/lib.ts
CHANGED
|
@@ -1,17 +1,11 @@
|
|
|
1
1
|
import { Route } from '@/types';
|
|
2
2
|
import cache from '@/utils/cache';
|
|
3
|
-
//
|
|
4
|
-
import got from '@/utils/got';
|
|
5
|
-
// 导入cheerio库,该库用来解析网页数据
|
|
3
|
+
import ofetch from '@/utils/ofetch'; // 使用ofetch库代替got
|
|
6
4
|
import { load } from 'cheerio';
|
|
7
|
-
// 导入parseDate函数,该函数用于日期处理
|
|
8
5
|
import { parseDate } from '@/utils/parse-date';
|
|
9
|
-
// 导入timezone库,该库用于时区处理
|
|
10
6
|
import timezone from '@/utils/timezone';
|
|
11
7
|
|
|
12
|
-
// 广西民大的url链接
|
|
13
8
|
const url = 'https://library.gxmzu.edu.cn/news/news_list.jsp?urltype=tree.TreeTempUrl&wbtreeid=1010';
|
|
14
|
-
// 广西民大图书馆网址
|
|
15
9
|
const host = 'https://library.gxmzu.edu.cn';
|
|
16
10
|
|
|
17
11
|
export const route: Route = {
|
|
@@ -39,13 +33,12 @@ export const route: Route = {
|
|
|
39
33
|
};
|
|
40
34
|
|
|
41
35
|
async function handler() {
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
const response = await ofetch(url).catch(() => null);
|
|
37
|
+
if (!response) {
|
|
38
|
+
return;
|
|
39
|
+
}
|
|
40
|
+
const $ = load(response);
|
|
44
41
|
|
|
45
|
-
// 解析网页数据
|
|
46
|
-
const $ = load(response.data);
|
|
47
|
-
|
|
48
|
-
// 通知公告的items的标题、url链接、发布日期
|
|
49
42
|
const list = $('#newslist ul li')
|
|
50
43
|
.toArray()
|
|
51
44
|
.map((item) => {
|
|
@@ -59,23 +52,17 @@ async function handler() {
|
|
|
59
52
|
|
|
60
53
|
const out = await Promise.all(
|
|
61
54
|
list.map((item) =>
|
|
62
|
-
// 使用缓存
|
|
63
55
|
cache.tryGet(item.link, async () => {
|
|
64
|
-
// 排除非本站点的外链
|
|
65
56
|
if (item.link && !item.link.startsWith('https://library.gxmzu.edu.cn/')) {
|
|
66
57
|
item.description = '该通知无法直接预览,请点击原文链接↑查看';
|
|
67
58
|
return item;
|
|
68
59
|
}
|
|
69
60
|
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
// 检查重定向
|
|
74
|
-
if (response.redirectUrls && response.redirectUrls.length > 0) {
|
|
75
|
-
item.link = response.redirectUrls[0];
|
|
61
|
+
const response = await ofetch(item.link).catch(() => null);
|
|
62
|
+
if (!response || (response.status >= 300 && response.status < 400)) {
|
|
76
63
|
item.description = '该通知无法直接预览,请点击原文链接↑查看';
|
|
77
64
|
} else {
|
|
78
|
-
const $ = load(response
|
|
65
|
+
const $ = load(response);
|
|
79
66
|
item.title = $('h2').text();
|
|
80
67
|
item.description = $('.v_news_content').html();
|
|
81
68
|
}
|
|
@@ -84,13 +71,9 @@ async function handler() {
|
|
|
84
71
|
)
|
|
85
72
|
);
|
|
86
73
|
|
|
87
|
-
// 生成RSS源
|
|
88
74
|
return {
|
|
89
|
-
// 项目标题
|
|
90
75
|
title: '广西民族大学图书馆 -- 最新消息',
|
|
91
|
-
// 项目链接
|
|
92
76
|
link: url,
|
|
93
|
-
// items的内容
|
|
94
77
|
item: out,
|
|
95
78
|
};
|
|
96
79
|
}
|
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import cache from '@/utils/cache';
|
|
2
|
-
import
|
|
2
|
+
import ofetch from '@/utils/ofetch'; // 使用ofetch库代替got
|
|
3
3
|
import { load } from 'cheerio';
|
|
4
4
|
import { parseDate } from '@/utils/parse-date';
|
|
5
5
|
import timezone from '@/utils/timezone';
|
|
6
6
|
|
|
7
7
|
async function getNoticeList(ctx, url, host, titleSelector, dateSelector, contentSelector) {
|
|
8
|
-
const response = await
|
|
9
|
-
|
|
8
|
+
const response = await ofetch(url, { rejectUnauthorized: false }).catch(() => null);
|
|
9
|
+
if (!response) {
|
|
10
|
+
return [];
|
|
11
|
+
}
|
|
12
|
+
const $ = load(response);
|
|
10
13
|
|
|
11
14
|
const list = $(`tr[height=20]`)
|
|
12
15
|
.toArray()
|
|
@@ -23,21 +26,36 @@ async function getNoticeList(ctx, url, host, titleSelector, dateSelector, conten
|
|
|
23
26
|
list.map((item) =>
|
|
24
27
|
cache.tryGet(item.link, async () => {
|
|
25
28
|
if (item.link.includes('.jsp')) {
|
|
29
|
+
// 特殊处理.jsp文件,直接显示消息而不尝试爬取
|
|
30
|
+
return {
|
|
31
|
+
...item,
|
|
32
|
+
description: '该通知无法直接预览,请点击原文链接↑查看',
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
const response = await ofetch(item.link, { rejectUnauthorized: false }).catch(() => null);
|
|
36
|
+
if (!response || (response.status >= 300 && response.status < 400)) {
|
|
26
37
|
item.description = '该通知无法直接预览,请点击原文链接↑查看';
|
|
27
38
|
} else {
|
|
28
|
-
const
|
|
29
|
-
|
|
30
|
-
|
|
39
|
+
const $ = load(response);
|
|
40
|
+
|
|
41
|
+
item.title = $(contentSelector.title).text();
|
|
42
|
+
const hasEmbeddedPDFScript = $('script:contains("showVsbpdfIframe")').length > 0;
|
|
43
|
+
|
|
44
|
+
if (hasEmbeddedPDFScript) {
|
|
31
45
|
item.description = '该通知无法直接预览,请点击原文链接↑查看';
|
|
32
46
|
} else {
|
|
33
|
-
const $ = load(
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
47
|
+
const $content = load($(contentSelector.content).html());
|
|
48
|
+
$content('a').each(function () {
|
|
49
|
+
const a = $(this);
|
|
50
|
+
const href = a.attr('href');
|
|
51
|
+
if (href && !href.startsWith('http')) {
|
|
52
|
+
a.attr('href', new URL(href, host).href);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
item.description = $content.html();
|
|
40
56
|
}
|
|
57
|
+
const preDate = $(contentSelector.date).text().replaceAll(/年|月/g, '-').replaceAll('日', '');
|
|
58
|
+
item.pubDate = timezone(parseDate(preDate), +8);
|
|
41
59
|
}
|
|
42
60
|
return item;
|
|
43
61
|
})
|
package/lib/routes/gxmzu/yjs.ts
CHANGED
|
@@ -31,7 +31,7 @@ export const route: Route = {
|
|
|
31
31
|
async function handler(ctx) {
|
|
32
32
|
const out = await getNoticeList(ctx, url, host, 'a', '.timestyle55267', {
|
|
33
33
|
title: '.titlestyle55269',
|
|
34
|
-
content: '#
|
|
34
|
+
content: '#vsb_newscontent',
|
|
35
35
|
date: '.timestyle55269',
|
|
36
36
|
});
|
|
37
37
|
|