rsshub 1.0.0-master.c183692 → 1.0.0-master.c1913c8
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/README.md +6 -9
- package/lib/config.ts +18 -0
- package/lib/errors/index.tsx +1 -1
- package/lib/middleware/logger.ts +2 -2
- package/lib/routes/abc/index.ts +2 -2
- package/lib/routes/apnews/api.ts +6 -1
- package/lib/routes/apnews/rss.ts +1 -1
- package/lib/routes/apnews/sitemap.ts +2 -1
- package/lib/routes/apnews/topics.ts +2 -2
- package/lib/routes/asus/bios.ts +39 -6
- package/lib/routes/bilibili/bilibili-recommend.ts +42 -0
- package/lib/routes/bilibili/cache.ts +22 -0
- package/lib/routes/bilibili/dynamic.ts +101 -97
- package/lib/routes/bilibili/followings-video.ts +9 -3
- package/lib/routes/bilibili/utils.ts +5 -0
- package/lib/routes/bilibili/video.ts +2 -1
- package/lib/routes/bitget/announcement.ts +200 -0
- package/lib/routes/bitget/namespace.ts +6 -0
- package/lib/routes/bitget/type.ts +26 -0
- package/lib/routes/bjp/apod.ts +4 -2
- package/lib/routes/bupt/jwc.ts +130 -0
- package/lib/routes/ccfa/index.ts +216 -0
- package/lib/routes/ccfa/namespace.ts +8 -0
- package/lib/routes/ccfa/templates/description.art +7 -0
- package/lib/routes/devtrium/namespace.ts +6 -0
- package/lib/routes/devtrium/posts.ts +55 -0
- package/lib/routes/discourse/official.ts +55 -0
- package/lib/routes/dockerhub/utils.ts +4 -3
- package/lib/routes/douban/movie/coming.ts +68 -0
- package/lib/routes/douban/templates/movie_coming.art +27 -0
- package/lib/routes/follow/profile.ts +35 -5
- package/lib/routes/github/comments.ts +32 -30
- package/lib/routes/gov/cn/namespace.ts +8 -0
- package/lib/routes/gov/{news → cn/news}/index.ts +11 -7
- package/lib/routes/gov/ndrc/fggz.ts +637 -2
- package/lib/routes/gov/ndrc/namespace.ts +8 -0
- package/lib/routes/gov/ndrc/xwdt.ts +28 -8
- package/lib/routes/gov/ndrc/zfxxgk/articles.ts +73 -0
- package/lib/routes/hpoi/all.ts +3 -2
- package/lib/routes/hpoi/character.ts +3 -2
- package/lib/routes/hpoi/work.ts +3 -2
- package/lib/routes/jjwxc/book.ts +18 -14
- package/lib/routes/lofter/collection.ts +87 -0
- package/lib/routes/malaysiakini/index.ts +179 -0
- package/lib/routes/malaysiakini/namespace.ts +11 -0
- package/lib/routes/mastodon/acct.ts +4 -3
- package/lib/routes/mastodon/timeline-local.ts +3 -2
- package/lib/routes/mastodon/timeline-remote.ts +3 -2
- package/lib/routes/meishichina/index.ts +1997 -0
- package/lib/routes/meishichina/namespace.ts +8 -0
- package/lib/routes/oct0pu5/namespace.ts +10 -0
- package/lib/routes/oct0pu5/rss.ts +48 -0
- package/lib/routes/pconline/focus.ts +143 -0
- package/lib/routes/pconline/namespace.ts +10 -0
- package/lib/routes/people/index.ts +6 -2
- package/lib/routes/pixivision/index.ts +84 -0
- package/lib/routes/pixivision/namespace.ts +6 -0
- package/lib/routes/pixivision/utils.ts +86 -0
- package/lib/routes/pku/bbs/hot.ts +1 -1
- package/lib/routes/pornhub/category.ts +3 -2
- package/lib/routes/pornhub/model.ts +4 -3
- package/lib/routes/pornhub/pornstar.ts +4 -3
- package/lib/routes/pornhub/search.ts +3 -2
- package/lib/routes/qiche365/namespace.ts +5 -0
- package/lib/routes/qiche365/recall.ts +53 -0
- package/lib/routes/sdu/{cs.ts → cs/index.ts} +46 -12
- package/lib/routes/sdu/namespace.ts +2 -2
- package/lib/routes/soundon/namespace.ts +6 -0
- package/lib/routes/soundon/podcast.ts +80 -0
- package/lib/routes/soundon/types.ts +67 -0
- package/lib/routes/swjtu/scai/bks.ts +80 -0
- package/lib/routes/telegram/blog.ts +3 -2
- package/lib/routes/telegram/stickerpack.ts +3 -2
- package/lib/routes/tencent/news/author.ts +2 -1
- package/lib/routes/the/index.ts +3 -2
- package/lib/routes/theinitium/app.ts +137 -0
- package/lib/routes/theinitium/templates/description.art +17 -0
- package/lib/routes/threads/index.ts +26 -20
- package/lib/routes/tju/cic/index.ts +2 -2
- package/lib/routes/tju/news/index.ts +2 -2
- package/lib/routes/tju/oaa/index.ts +2 -2
- package/lib/routes/twitch/live.ts +3 -2
- package/lib/routes/twitch/video.ts +3 -2
- package/lib/routes/twitter/api/mobile-api/login.ts +1 -1
- package/lib/routes/twitter/api/web-api/constants.ts +15 -14
- package/lib/routes/twitter/api/web-api/login.ts +7 -5
- package/lib/routes/twitter/api/web-api/utils.ts +1 -2
- package/lib/routes/twitter/list.ts +5 -2
- package/lib/routes/twitter/tweet.ts +1 -0
- package/lib/routes/weibo/namespace.ts +1 -0
- package/lib/routes/weibo/oasis/user.ts +1 -1
- package/lib/routes/weibo/super-index.ts +23 -11
- package/lib/routes/weibo/user.ts +12 -1
- package/lib/routes/whu/cs.ts +11 -3
- package/lib/routes/whu/gs/index.ts +2 -1
- package/lib/routes/whu/news.ts +27 -2
- package/lib/routes/withgoogle/explorables.ts +54 -0
- package/lib/routes/withgoogle/namespace.ts +6 -0
- package/lib/routes/zaobao/util.ts +1 -1
- package/lib/routes/zhihu/zhuanlan.ts +8 -7
- package/lib/utils/otel/metric.ts +3 -2
- package/lib/views/rss.tsx +7 -0
- package/package.json +14 -14
|
@@ -35,6 +35,7 @@ async function handler(ctx) {
|
|
|
35
35
|
const cookie = await cache.getCookie();
|
|
36
36
|
const wbiVerifyString = await cache.getWbiVerifyString();
|
|
37
37
|
const dmImgList = utils.getDmImgList();
|
|
38
|
+
const renderData = await cache.getRenderData(uid);
|
|
38
39
|
const [name, face] = await cache.getUsernameAndFaceFromUID(uid);
|
|
39
40
|
|
|
40
41
|
// await got(`https://space.bilibili.com/${uid}/video?tid=0&page=1&keyword=&order=pubdate`, {
|
|
@@ -43,7 +44,7 @@ async function handler(ctx) {
|
|
|
43
44
|
// Cookie: cookie,
|
|
44
45
|
// },
|
|
45
46
|
// });
|
|
46
|
-
const params = utils.addWbiVerifyInfo(utils.addDmVerifyInfo(`mid=${uid}&ps=30&tid=0&pn=1&keyword=&order=pubdate&platform=web&web_location=1550101&order_avoided=true`, dmImgList), wbiVerifyString);
|
|
47
|
+
const params = utils.addWbiVerifyInfo(utils.addRenderData(utils.addDmVerifyInfo(`mid=${uid}&ps=30&tid=0&pn=1&keyword=&order=pubdate&platform=web&web_location=1550101&order_avoided=true`, dmImgList), renderData), wbiVerifyString);
|
|
47
48
|
const response = await got(`https://api.bilibili.com/x/space/wbi/arc/search?${params}`, {
|
|
48
49
|
headers: {
|
|
49
50
|
Referer: `https://space.bilibili.com/${uid}/video?tid=0&page=1&keyword=&order=pubdate`,
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { DataItem, Route } from '@/types';
|
|
2
|
+
import ofetch from '@/utils/ofetch';
|
|
3
|
+
import { load } from 'cheerio';
|
|
4
|
+
import cache from '@/utils/cache';
|
|
5
|
+
import { BitgetResponse } from './type';
|
|
6
|
+
import { parseDate } from '@/utils/parse-date';
|
|
7
|
+
import { config } from '@/config';
|
|
8
|
+
|
|
9
|
+
const handler: Route['handler'] = async (ctx) => {
|
|
10
|
+
const baseUrl = 'https://www.bitget.com';
|
|
11
|
+
const announcementApiUrl = `${baseUrl}/v1/msg/push/stationLetterNew`;
|
|
12
|
+
const { type, lang = 'zh-CN' } = ctx.req.param<'/bitget/announcement/:type/:lang?'>();
|
|
13
|
+
const languageCode = lang.replace('-', '_');
|
|
14
|
+
const headers = {
|
|
15
|
+
Referer: baseUrl,
|
|
16
|
+
accept: 'application/json, text/plain, */*',
|
|
17
|
+
'content-type': 'application/json;charset=UTF-8',
|
|
18
|
+
language: languageCode,
|
|
19
|
+
locale: languageCode,
|
|
20
|
+
};
|
|
21
|
+
const pageSize = ctx.req.query('limit') ?? '10';
|
|
22
|
+
|
|
23
|
+
// stationLetterType: 0 表示全部通知,02 表示新币上线,01 表示最新活动,06 表示最新公告
|
|
24
|
+
const reqBody: {
|
|
25
|
+
pageSize: string;
|
|
26
|
+
openUnread: number;
|
|
27
|
+
stationLetterType: string;
|
|
28
|
+
isPre: boolean;
|
|
29
|
+
lastEndId: null;
|
|
30
|
+
languageType: number;
|
|
31
|
+
excludeStationLetterType?: string;
|
|
32
|
+
} = {
|
|
33
|
+
pageSize,
|
|
34
|
+
openUnread: 0,
|
|
35
|
+
stationLetterType: '0',
|
|
36
|
+
isPre: false,
|
|
37
|
+
lastEndId: null,
|
|
38
|
+
languageType: 1,
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// 根据 type 判断 reqBody 的 stationLetterType 的值
|
|
42
|
+
switch (type) {
|
|
43
|
+
case 'new-listing':
|
|
44
|
+
reqBody.stationLetterType = '02';
|
|
45
|
+
break;
|
|
46
|
+
|
|
47
|
+
case 'latest-activities':
|
|
48
|
+
reqBody.stationLetterType = '01';
|
|
49
|
+
break;
|
|
50
|
+
|
|
51
|
+
case 'new-announcement':
|
|
52
|
+
reqBody.stationLetterType = '06';
|
|
53
|
+
break;
|
|
54
|
+
|
|
55
|
+
case 'all':
|
|
56
|
+
reqBody.stationLetterType = '0';
|
|
57
|
+
reqBody.excludeStationLetterType = '00';
|
|
58
|
+
break;
|
|
59
|
+
|
|
60
|
+
default:
|
|
61
|
+
throw new Error('Invalid type');
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
const response = (await cache.tryGet(
|
|
65
|
+
`bitget:announcement:${type}:${pageSize}:${lang}`,
|
|
66
|
+
async () => {
|
|
67
|
+
const result = await ofetch<BitgetResponse>(announcementApiUrl, {
|
|
68
|
+
method: 'POST',
|
|
69
|
+
body: reqBody,
|
|
70
|
+
headers,
|
|
71
|
+
});
|
|
72
|
+
if (result?.code !== '200') {
|
|
73
|
+
throw new Error('Failed to fetch announcements, error code: ' + result?.code);
|
|
74
|
+
}
|
|
75
|
+
return result;
|
|
76
|
+
},
|
|
77
|
+
config.cache.routeExpire,
|
|
78
|
+
false
|
|
79
|
+
)) as BitgetResponse;
|
|
80
|
+
|
|
81
|
+
if (!response) {
|
|
82
|
+
throw new Error('Failed to fetch announcements');
|
|
83
|
+
}
|
|
84
|
+
const items = response.data.items;
|
|
85
|
+
const data = await Promise.all(
|
|
86
|
+
items.map(
|
|
87
|
+
(item) =>
|
|
88
|
+
cache.tryGet(`bitget:announcement:${item.id}:${pageSize}:${lang}`, async () => {
|
|
89
|
+
// 从 unix 时间戳转换为日期
|
|
90
|
+
const date = parseDate(Number(item.sendTime));
|
|
91
|
+
const dataItem: DataItem = {
|
|
92
|
+
title: item.title ?? '',
|
|
93
|
+
link: item.openUrl ?? '',
|
|
94
|
+
pubDate: item.sendTime ? date : undefined,
|
|
95
|
+
description: item.content ?? '',
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
if (item.imgUrl) {
|
|
99
|
+
dataItem.image = item.imgUrl;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
if (item.stationLetterType === '01' || item.stationLetterType === '06') {
|
|
103
|
+
try {
|
|
104
|
+
const itemResponse = await ofetch<string>(item.openUrl ?? '', {
|
|
105
|
+
headers,
|
|
106
|
+
});
|
|
107
|
+
const $ = load(itemResponse);
|
|
108
|
+
const nextData = JSON.parse($('script#__NEXT_DATA__').text());
|
|
109
|
+
dataItem.description = nextData.props.pageProps.details?.content || nextData.props.pageProps.pageInitInfo?.ruleContent || item.content || '';
|
|
110
|
+
} catch (error: any) {
|
|
111
|
+
if (error.name && (error.name === 'HTTPError' || error.name === 'RequestError' || error.name === 'FetchError')) {
|
|
112
|
+
dataItem.description = item.content ?? '';
|
|
113
|
+
} else {
|
|
114
|
+
throw error;
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
return dataItem;
|
|
119
|
+
}) as Promise<DataItem>
|
|
120
|
+
)
|
|
121
|
+
);
|
|
122
|
+
|
|
123
|
+
return {
|
|
124
|
+
title: `Bitget | ${findTypeLabel(type)}`,
|
|
125
|
+
link: `https://www.bitget.com/${lang}/inmail`,
|
|
126
|
+
item: data,
|
|
127
|
+
};
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
const findTypeLabel = (type: string) => {
|
|
131
|
+
const typeMap = {
|
|
132
|
+
all: 'All',
|
|
133
|
+
'new-listing': 'New Listing',
|
|
134
|
+
'latest-activities': 'Latest Activities',
|
|
135
|
+
'new-announcement': 'New Announcement',
|
|
136
|
+
};
|
|
137
|
+
return typeMap[type];
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
export const route: Route = {
|
|
141
|
+
path: '/announcement/:type/:lang?',
|
|
142
|
+
categories: ['finance'],
|
|
143
|
+
example: '/bitget/announcement/all/zh-CN',
|
|
144
|
+
parameters: {
|
|
145
|
+
type: {
|
|
146
|
+
description: 'Bitget 通知类型',
|
|
147
|
+
default: 'all',
|
|
148
|
+
options: [
|
|
149
|
+
{ value: 'all', label: '全部通知' },
|
|
150
|
+
{ value: 'new-listing', label: '新币上线' },
|
|
151
|
+
{ value: 'latest-activities', label: '最新活动' },
|
|
152
|
+
{ value: 'new-announcement', label: '最新公告' },
|
|
153
|
+
],
|
|
154
|
+
},
|
|
155
|
+
lang: {
|
|
156
|
+
description: '语言',
|
|
157
|
+
default: 'zh-CN',
|
|
158
|
+
options: [
|
|
159
|
+
{ value: 'zh-CN', label: '中文' },
|
|
160
|
+
{ value: 'en-US', label: 'English' },
|
|
161
|
+
{ value: 'es-ES', label: 'Español' },
|
|
162
|
+
{ value: 'fr-FR', label: 'Français' },
|
|
163
|
+
{ value: 'de-DE', label: 'Deutsch' },
|
|
164
|
+
{ value: 'ja-JP', label: '日本語' },
|
|
165
|
+
{ value: 'ru-RU', label: 'Русский' },
|
|
166
|
+
{ value: 'ar-SA', label: 'العربية' },
|
|
167
|
+
],
|
|
168
|
+
},
|
|
169
|
+
},
|
|
170
|
+
radar: [
|
|
171
|
+
{
|
|
172
|
+
source: ['www.bitget.com/:lang/inmail'],
|
|
173
|
+
target: '/announcement/all/:lang',
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
name: 'Announcement',
|
|
177
|
+
description: `
|
|
178
|
+
type:
|
|
179
|
+
| Type | Description |
|
|
180
|
+
| --- | --- |
|
|
181
|
+
| all | 全部通知 |
|
|
182
|
+
| new-listing | 新币上线 |
|
|
183
|
+
| latest-activities | 最新活动 |
|
|
184
|
+
| new-announcement | 最新公告 |
|
|
185
|
+
|
|
186
|
+
lang:
|
|
187
|
+
| Lang | Description |
|
|
188
|
+
| --- | --- |
|
|
189
|
+
| zh-CN | 中文 |
|
|
190
|
+
| en-US | English |
|
|
191
|
+
| es-ES | Español |
|
|
192
|
+
| fr-FR | Français |
|
|
193
|
+
| de-DE | Deutsch |
|
|
194
|
+
| ja-JP | 日本語 |
|
|
195
|
+
| ru-RU | Русский |
|
|
196
|
+
| ar-SA | العربية |
|
|
197
|
+
`,
|
|
198
|
+
maintainers: ['YukiCoco'],
|
|
199
|
+
handler,
|
|
200
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
export interface BitgetResponse {
|
|
2
|
+
code: string;
|
|
3
|
+
data: {
|
|
4
|
+
endId: string;
|
|
5
|
+
hasNextPage: boolean;
|
|
6
|
+
hasPrePage: boolean;
|
|
7
|
+
items: Array<{
|
|
8
|
+
businessType?: number;
|
|
9
|
+
content?: string;
|
|
10
|
+
id: string;
|
|
11
|
+
imgUrl?: string;
|
|
12
|
+
openUrl?: string;
|
|
13
|
+
openUrlName?: string;
|
|
14
|
+
readStats?: number;
|
|
15
|
+
sendTime?: string;
|
|
16
|
+
stationLetterType?: string;
|
|
17
|
+
title?: string;
|
|
18
|
+
}>;
|
|
19
|
+
notifyFlag: boolean;
|
|
20
|
+
page: number;
|
|
21
|
+
pageSize: number;
|
|
22
|
+
startId: string;
|
|
23
|
+
total: number;
|
|
24
|
+
};
|
|
25
|
+
params: any[];
|
|
26
|
+
}
|
package/lib/routes/bjp/apod.ts
CHANGED
|
@@ -29,7 +29,7 @@ export const route: Route = {
|
|
|
29
29
|
url: 'bjp.org.cn/APOD/today.shtml',
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
async function handler() {
|
|
32
|
+
async function handler(ctx) {
|
|
33
33
|
const baseUrl = 'https://www.bjp.org.cn';
|
|
34
34
|
const listUrl = `${baseUrl}/APOD/list.shtml`;
|
|
35
35
|
|
|
@@ -46,7 +46,9 @@ async function handler() {
|
|
|
46
46
|
link: `${baseUrl}${e.find('a').attr('href')}`,
|
|
47
47
|
pubDate: timezone(parseDate(e.find('span').text().replace(':', ''), 'YYYY-MM-DD'), 8),
|
|
48
48
|
};
|
|
49
|
-
})
|
|
49
|
+
})
|
|
50
|
+
.sort((a, b) => b.pubDate - a.pubDate)
|
|
51
|
+
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 10);
|
|
50
52
|
|
|
51
53
|
const items = await Promise.all(
|
|
52
54
|
list.map((e) =>
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
import cache from '@/utils/cache';
|
|
3
|
+
import got from '@/utils/got';
|
|
4
|
+
import { load } from 'cheerio';
|
|
5
|
+
import timezone from '@/utils/timezone';
|
|
6
|
+
import { parseDate } from '@/utils/parse-date';
|
|
7
|
+
import type { Context } from 'hono';
|
|
8
|
+
|
|
9
|
+
export const route: Route = {
|
|
10
|
+
path: '/jwc/:type',
|
|
11
|
+
categories: ['university'],
|
|
12
|
+
example: '/bupt/jwc/tzgg',
|
|
13
|
+
parameters: {
|
|
14
|
+
type: {
|
|
15
|
+
type: 'string',
|
|
16
|
+
optional: false,
|
|
17
|
+
description: '信息类型,可选值:tzgg(通知公告),xwzx(新闻资讯)',
|
|
18
|
+
},
|
|
19
|
+
},
|
|
20
|
+
features: {
|
|
21
|
+
requireConfig: false,
|
|
22
|
+
requirePuppeteer: false,
|
|
23
|
+
antiCrawler: false,
|
|
24
|
+
supportBT: false,
|
|
25
|
+
supportPodcast: false,
|
|
26
|
+
supportScihub: false,
|
|
27
|
+
},
|
|
28
|
+
radar: [
|
|
29
|
+
{
|
|
30
|
+
source: ['jwc.bupt.edu.cn/tzgg1.htm'],
|
|
31
|
+
target: '/jwc/tzgg',
|
|
32
|
+
},
|
|
33
|
+
{
|
|
34
|
+
source: ['jwc.bupt.edu.cn/xwzx2.htm'],
|
|
35
|
+
target: '/jwc/xwzx',
|
|
36
|
+
},
|
|
37
|
+
],
|
|
38
|
+
name: '教务处',
|
|
39
|
+
maintainers: ['Yoruet'],
|
|
40
|
+
handler,
|
|
41
|
+
url: 'https://jwc.bupt.edu.cn/',
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
async function handler(ctx: Context) {
|
|
45
|
+
let type = ctx.req.param('type'); // 默认类型为通知公告
|
|
46
|
+
if (!type) {
|
|
47
|
+
type = 'tzgg';
|
|
48
|
+
}
|
|
49
|
+
const rootUrl = 'https://jwc.bupt.edu.cn';
|
|
50
|
+
let currentUrl;
|
|
51
|
+
let pageTitle;
|
|
52
|
+
|
|
53
|
+
if (type === 'tzgg') {
|
|
54
|
+
currentUrl = `${rootUrl}/tzgg1.htm`;
|
|
55
|
+
pageTitle = '通知公告';
|
|
56
|
+
} else if (type === 'xwzx') {
|
|
57
|
+
currentUrl = `${rootUrl}/xwzx2.htm`;
|
|
58
|
+
pageTitle = '新闻资讯';
|
|
59
|
+
} else {
|
|
60
|
+
throw new Error('Invalid type parameter');
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
const response = await got({
|
|
64
|
+
method: 'get',
|
|
65
|
+
url: currentUrl,
|
|
66
|
+
});
|
|
67
|
+
|
|
68
|
+
const $ = load(response.data);
|
|
69
|
+
|
|
70
|
+
const list = $('.txt-elise')
|
|
71
|
+
.map((_, item) => {
|
|
72
|
+
const $item = $(item);
|
|
73
|
+
const $link = $item.find('a');
|
|
74
|
+
// Skip elements without links or with empty href
|
|
75
|
+
if ($link.length === 0 || !$link.attr('href')) {
|
|
76
|
+
return null;
|
|
77
|
+
}
|
|
78
|
+
return {
|
|
79
|
+
title: $link.text().trim(),
|
|
80
|
+
link: rootUrl + '/' + $link.attr('href'),
|
|
81
|
+
};
|
|
82
|
+
})
|
|
83
|
+
.get()
|
|
84
|
+
.filter(Boolean);
|
|
85
|
+
|
|
86
|
+
const items = await Promise.all(
|
|
87
|
+
list.map((item) =>
|
|
88
|
+
cache.tryGet(item.link, async () => {
|
|
89
|
+
const detailResponse = await got({
|
|
90
|
+
method: 'get',
|
|
91
|
+
url: item.link,
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
const content = load(detailResponse.data);
|
|
95
|
+
|
|
96
|
+
// 选择包含新闻内容的元素
|
|
97
|
+
const newsContent = content('.v_news_content');
|
|
98
|
+
|
|
99
|
+
// 移除不必要的标签,比如 <p> 和 <span> 中无用的内容
|
|
100
|
+
newsContent.find('p, span, strong').each(function () {
|
|
101
|
+
const element = content(this);
|
|
102
|
+
const text = element.text().trim();
|
|
103
|
+
|
|
104
|
+
// 删除没有有用文本的元素,防止空元素被保留
|
|
105
|
+
if (text === '') {
|
|
106
|
+
element.remove();
|
|
107
|
+
} else {
|
|
108
|
+
// 去除多余的嵌套标签,但保留其内容
|
|
109
|
+
element.replaceWith(text);
|
|
110
|
+
}
|
|
111
|
+
});
|
|
112
|
+
|
|
113
|
+
// 清理后的内容转换为文本
|
|
114
|
+
const cleanedDescription = newsContent.text().trim();
|
|
115
|
+
|
|
116
|
+
// 提取并格式化发布时间
|
|
117
|
+
item.description = cleanedDescription;
|
|
118
|
+
item.pubDate = timezone(parseDate(content('.info').text().replace('发布时间:', '').trim()), +8);
|
|
119
|
+
|
|
120
|
+
return item;
|
|
121
|
+
})
|
|
122
|
+
)
|
|
123
|
+
);
|
|
124
|
+
|
|
125
|
+
return {
|
|
126
|
+
title: `北京邮电大学教务处 - ${pageTitle}`,
|
|
127
|
+
link: currentUrl,
|
|
128
|
+
item: items,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
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 { type = '1' } = ctx.req.param();
|
|
14
|
+
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 30;
|
|
15
|
+
|
|
16
|
+
const rootUrl = 'http://www.ccfa.org.cn';
|
|
17
|
+
const currentUrl = new URL(`portal/cn/xiehui_list.jsp?type=${type}`, rootUrl).href;
|
|
18
|
+
|
|
19
|
+
const { data: response } = await got(currentUrl);
|
|
20
|
+
|
|
21
|
+
const $ = load(response);
|
|
22
|
+
|
|
23
|
+
let items = $('div.page_right ul li')
|
|
24
|
+
.slice(0, limit)
|
|
25
|
+
.toArray()
|
|
26
|
+
.map((item) => {
|
|
27
|
+
item = $(item);
|
|
28
|
+
|
|
29
|
+
const a = item.find('a');
|
|
30
|
+
|
|
31
|
+
return {
|
|
32
|
+
title: a.text(),
|
|
33
|
+
pubDate: parseDate(item.find('span.list_time').text(), 'YYYY/MM/DD'),
|
|
34
|
+
link: new URL(a.prop('href'), currentUrl).href,
|
|
35
|
+
};
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
items = await Promise.all(
|
|
39
|
+
items.map((item) =>
|
|
40
|
+
cache.tryGet(item.link, async () => {
|
|
41
|
+
if (!item.link.includes('ccfa.org.cn')) {
|
|
42
|
+
return item;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const { data: detailResponse } = await got(item.link);
|
|
46
|
+
|
|
47
|
+
const $$ = load(detailResponse);
|
|
48
|
+
|
|
49
|
+
const title = $$('h2#title').text();
|
|
50
|
+
const description = art(path.join(__dirname, 'templates/description.art'), {
|
|
51
|
+
intro: $$('div.artical_info_jianjie').html(),
|
|
52
|
+
description: $$('div.news_artical_txt').html(),
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const pubDate =
|
|
56
|
+
$$('div.artical_info_left')
|
|
57
|
+
.text()
|
|
58
|
+
.match(/(\d{4}(?:\/\d{2}){2})/)?.[1] ?? undefined;
|
|
59
|
+
|
|
60
|
+
item.title = title;
|
|
61
|
+
item.description = description;
|
|
62
|
+
item.pubDate = pubDate ? parseDate(pubDate, 'YYYY/MM/DD') : item.pubDate;
|
|
63
|
+
item.author = $$('div.artical_info_left')
|
|
64
|
+
.text()
|
|
65
|
+
.split(/来源:/)
|
|
66
|
+
.pop();
|
|
67
|
+
item.content = {
|
|
68
|
+
html: description,
|
|
69
|
+
text: $$('div.news_artical_txt').text(),
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
const attachmentEl =
|
|
73
|
+
$$('p.download').length === 0
|
|
74
|
+
? undefined
|
|
75
|
+
: $$('div.news_artical_txt a')
|
|
76
|
+
.toArray()
|
|
77
|
+
.find((a) => $$(a).prop('href')?.includes('downFiles.do'));
|
|
78
|
+
|
|
79
|
+
item.enclosure_url = attachmentEl ? new URL($$(attachmentEl).prop('href'), rootUrl) : undefined;
|
|
80
|
+
item.enclosure_title = attachmentEl ? $$(attachmentEl).text() : undefined;
|
|
81
|
+
|
|
82
|
+
return item;
|
|
83
|
+
})
|
|
84
|
+
)
|
|
85
|
+
);
|
|
86
|
+
|
|
87
|
+
const description = $('li.page_tit').contents().last().text().split(/>/).pop();
|
|
88
|
+
const image = new URL($('div.logo img').prop('src'), currentUrl).href;
|
|
89
|
+
const author = $('title').text();
|
|
90
|
+
|
|
91
|
+
return {
|
|
92
|
+
title: `${author} - ${description}`,
|
|
93
|
+
description,
|
|
94
|
+
link: currentUrl,
|
|
95
|
+
item: items,
|
|
96
|
+
allowEmpty: true,
|
|
97
|
+
image,
|
|
98
|
+
author: $('meta[property="og:site_name"]').prop('content'),
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export const route: Route = {
|
|
103
|
+
path: '/:type?',
|
|
104
|
+
name: '分类',
|
|
105
|
+
url: 'www.ccfa.org.cn',
|
|
106
|
+
maintainers: ['nczitzk'],
|
|
107
|
+
handler,
|
|
108
|
+
example: '/ccfa/1',
|
|
109
|
+
parameters: { category: '分类,默认为 `1`,即协会动态,可在对应分类页 URL 中找到' },
|
|
110
|
+
description: `:::tip
|
|
111
|
+
若订阅 [协会动态](https://www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=1),网址为 \`https://www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=1\`。截取 \`https://www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=\` 到末尾的部分 \`1\` 作为参数填入,此时路由为 [\`/ccfa/1\`](https://rsshub.app/ccfa/1)。
|
|
112
|
+
:::
|
|
113
|
+
|
|
114
|
+
| 分类 | ID |
|
|
115
|
+
| ------------------------------------------------------------------------- | -------------------------------------- |
|
|
116
|
+
| [协会动态](http://www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=1) | [1](https://rsshub.app/ccfa/1) |
|
|
117
|
+
| [行业动态](http://www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=2) | [2](https://rsshub.app/ccfa/2) |
|
|
118
|
+
| [政策/报告/标准](http://www.ccfa.org.cn/portal/cn/hybz_list.jsp?type=33) | [33](https://rsshub.app/ccfa/33) |
|
|
119
|
+
| [行业统计](http://www.ccfa.org.cn/portal/cn/lsbq.jsp?type=10003) | [10003](https://rsshub.app/ccfa/10003) |
|
|
120
|
+
| [创新案例](http://www.ccfa.org.cn/portal/cn/hybzs_list.jsp?type=10004) | [10004](https://rsshub.app/ccfa/10004) |
|
|
121
|
+
| [党建工作](http://www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=7) | [7](https://rsshub.app/ccfa/7) |
|
|
122
|
+
| [新消费论坛](http://www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=10005) | [10005](https://rsshub.app/ccfa/10005) |
|
|
123
|
+
|
|
124
|
+
#### [政策/报告/标准](http://www.ccfa.org.cn/portal/cn/hybz_list.jsp?type=33)
|
|
125
|
+
|
|
126
|
+
| 分类 | ID |
|
|
127
|
+
| ------------------------------------------------------------------------------- | -------------------------------- |
|
|
128
|
+
| [行业报告](http://www.ccfa.org.cn/portal/cn/hybz_list.jsp?type=33) | [33](https://rsshub.app/ccfa/33) |
|
|
129
|
+
| [行业标准](http://www.ccfa.org.cn/portal/cn/hybz_list.jsp?type=34) | [34](https://rsshub.app/ccfa/34) |
|
|
130
|
+
| [行业政策](http://www.ccfa.org.cn/portal/cn/fangyizhuanqu_list.jsp?type=39) | [39](https://rsshub.app/ccfa/39) |
|
|
131
|
+
| [政策权威解读](http://www.ccfa.org.cn/portal/cn/fangyizhuanqu_list.jsp?type=40) | [40](https://rsshub.app/ccfa/40) |
|
|
132
|
+
`,
|
|
133
|
+
categories: ['new-media'],
|
|
134
|
+
|
|
135
|
+
features: {
|
|
136
|
+
requireConfig: false,
|
|
137
|
+
requirePuppeteer: false,
|
|
138
|
+
antiCrawler: false,
|
|
139
|
+
supportRadar: true,
|
|
140
|
+
supportBT: false,
|
|
141
|
+
supportPodcast: false,
|
|
142
|
+
supportScihub: false,
|
|
143
|
+
},
|
|
144
|
+
radar: [
|
|
145
|
+
{
|
|
146
|
+
source: [
|
|
147
|
+
'www.ccfa.org.cn/portal/cn/xiehui_list.jsp',
|
|
148
|
+
'www.ccfa.org.cn/portal/cn/hybz_list.jsp',
|
|
149
|
+
'www.ccfa.org.cn/portal/cn/lsbq.jsp',
|
|
150
|
+
'www.ccfa.org.cn/portal/cn/hybzs_list.jsp',
|
|
151
|
+
'www.ccfa.org.cn/portal/cn/fangyizhuanqu_list.jsp',
|
|
152
|
+
],
|
|
153
|
+
target: (_, url) => {
|
|
154
|
+
url = new URL(url);
|
|
155
|
+
const type = url.searchParams.get('type');
|
|
156
|
+
|
|
157
|
+
return type ? `/${type}` : '';
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
title: '协会动态',
|
|
162
|
+
source: ['www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=1'],
|
|
163
|
+
target: '/1',
|
|
164
|
+
},
|
|
165
|
+
{
|
|
166
|
+
title: '行业动态',
|
|
167
|
+
source: ['www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=2'],
|
|
168
|
+
target: '/2',
|
|
169
|
+
},
|
|
170
|
+
{
|
|
171
|
+
title: '政策/报告/标准',
|
|
172
|
+
source: ['www.ccfa.org.cn/portal/cn/hybz_list.jsp?type=33'],
|
|
173
|
+
target: '/33',
|
|
174
|
+
},
|
|
175
|
+
{
|
|
176
|
+
title: '行业统计',
|
|
177
|
+
source: ['www.ccfa.org.cn/portal/cn/lsbq.jsp?type=10003'],
|
|
178
|
+
target: '/10003',
|
|
179
|
+
},
|
|
180
|
+
{
|
|
181
|
+
title: '创新案例',
|
|
182
|
+
source: ['www.ccfa.org.cn/portal/cn/hybzs_list.jsp?type=10004'],
|
|
183
|
+
target: '/10004',
|
|
184
|
+
},
|
|
185
|
+
{
|
|
186
|
+
title: '党建工作',
|
|
187
|
+
source: ['www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=7'],
|
|
188
|
+
target: '/7',
|
|
189
|
+
},
|
|
190
|
+
{
|
|
191
|
+
title: '新消费论坛',
|
|
192
|
+
source: ['www.ccfa.org.cn/portal/cn/xiehui_list.jsp?type=10005'],
|
|
193
|
+
target: '/10005',
|
|
194
|
+
},
|
|
195
|
+
{
|
|
196
|
+
title: '政策/报告/标准 - 行业报告',
|
|
197
|
+
source: ['www.ccfa.org.cn/portal/cn/hybz_list.jsp?type=33'],
|
|
198
|
+
target: '/33',
|
|
199
|
+
},
|
|
200
|
+
{
|
|
201
|
+
title: '政策/报告/标准 - 行业标准',
|
|
202
|
+
source: ['www.ccfa.org.cn/portal/cn/hybz_list.jsp?type=34'],
|
|
203
|
+
target: '/34',
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
title: '政策/报告/标准 - 行业政策',
|
|
207
|
+
source: ['www.ccfa.org.cn/portal/cn/fangyizhuanqu_list.jsp?type=39'],
|
|
208
|
+
target: '/39',
|
|
209
|
+
},
|
|
210
|
+
{
|
|
211
|
+
title: '政策/报告/标准 - 政策权威解读',
|
|
212
|
+
source: ['www.ccfa.org.cn/portal/cn/fangyizhuanqu_list.jsp?type=40'],
|
|
213
|
+
target: '/40',
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
};
|