rsshub 1.0.0-master.b32c5ca → 1.0.0-master.b35d47d
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/index.ts +3 -0
- package/lib/routes/36kr/hot-list.ts +5 -0
- package/lib/routes/amz123/kx.ts +65 -0
- package/lib/routes/amz123/namespace.ts +9 -0
- package/lib/routes/bilibili/hot-search.ts +1 -1
- package/lib/routes/bloomberg/authors.ts +6 -6
- package/lib/routes/bsky/posts.ts +1 -0
- package/lib/routes/dingshao/namespace.ts +7 -0
- package/lib/routes/dingshao/share.ts +53 -0
- package/lib/routes/dingshao/types.ts +64 -0
- package/lib/routes/fastbull/express-news.ts +4 -4
- package/lib/routes/fastbull/namespace.ts +3 -3
- package/lib/routes/fastbull/news.ts +6 -6
- package/lib/routes/foodtalks/index.ts +75 -0
- package/lib/routes/foodtalks/namespace.ts +9 -0
- package/lib/routes/hbr/topic.ts +25 -20
- package/lib/routes/hellogithub/article.ts +62 -0
- package/lib/routes/hellogithub/index.ts +2 -2
- package/lib/routes/hellogithub/report.ts +1 -1
- package/lib/routes/hellogithub/volume.ts +1 -1
- package/lib/routes/ifun/n/category.ts +102 -0
- package/lib/routes/ifun/n/search.ts +73 -0
- package/lib/routes/ifun/n/tag.ts +76 -0
- package/lib/routes/ifun/n/util.ts +34 -0
- package/lib/routes/ifun/namespace.ts +9 -0
- package/lib/routes/joneslanglasalle/index.ts +310 -0
- package/lib/routes/joneslanglasalle/namespace.ts +13 -0
- package/lib/routes/joneslanglasalle/templates/description.art +21 -0
- package/lib/routes/latepost/index.ts +1 -1
- package/lib/routes/luogu/daily.ts +1 -1
- package/lib/routes/luogu/user-article.ts +75 -0
- package/lib/routes/luogu/user-blog.ts +4 -1
- package/lib/routes/luogu/user-feed.ts +9 -10
- package/lib/routes/luogu/utils.ts +17 -0
- package/lib/routes/newrank/wechat.ts +6 -1
- package/lib/routes/parliament.uk/namespace.ts +2 -0
- package/lib/routes/parliament.uk/petitions.ts +191 -0
- package/lib/routes/parliament.uk/templates/description.art +7 -0
- package/lib/routes/picnob/templates/desc.art +9 -2
- package/lib/routes/picnob/user.ts +52 -35
- package/lib/routes/qingting/channel.ts +9 -9
- package/lib/routes/qingting/podcast.ts +13 -23
- package/lib/routes/spotify/show.ts +5 -4
- package/lib/routes/taiwanmobile/namespace.ts +7 -0
- package/lib/routes/taiwanmobile/rate-plans.ts +64 -0
- package/lib/routes/theatlantic/news.ts +4 -7
- package/lib/routes/theatlantic/utils.ts +10 -8
- package/lib/routes/xiaohongshu/user.ts +10 -3
- package/lib/routes/xiaohongshu/util.ts +65 -5
- package/lib/routes/yna/index.ts +92 -0
- package/lib/routes/yna/namespace.ts +10 -0
- package/lib/utils/wechat-mp.ts +15 -13
- package/lib/views/index.tsx +1 -1
- package/package.json +22 -22
package/lib/index.ts
CHANGED
|
@@ -4,6 +4,7 @@ import got from '@/utils/got';
|
|
|
4
4
|
import { parseDate } from '@/utils/parse-date';
|
|
5
5
|
|
|
6
6
|
import { rootUrl, ProcessItem } from './utils';
|
|
7
|
+
import InvalidParameterError from '@/errors/types/invalid-parameter';
|
|
7
8
|
|
|
8
9
|
const categories = {
|
|
9
10
|
24: {
|
|
@@ -54,6 +55,10 @@ export const route: Route = {
|
|
|
54
55
|
async function handler(ctx) {
|
|
55
56
|
const category = ctx.req.param('category') ?? '24';
|
|
56
57
|
|
|
58
|
+
if (!categories[category]) {
|
|
59
|
+
throw new InvalidParameterError('This category does not exist. Please refer to the documentation for the correct usage.');
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
const currentUrl = category === '24' ? rootUrl : `${rootUrl}/hot-list/catalog`;
|
|
58
63
|
|
|
59
64
|
const response = await got({
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Route, ViewType } from '@/types';
|
|
2
|
+
import got from '@/utils/got';
|
|
3
|
+
import { parseDate } from '@/utils/parse-date';
|
|
4
|
+
|
|
5
|
+
export const route: Route = {
|
|
6
|
+
path: '/kx',
|
|
7
|
+
categories: ['new-media'],
|
|
8
|
+
example: '/amz123/kx',
|
|
9
|
+
parameters: {},
|
|
10
|
+
features: {
|
|
11
|
+
requireConfig: false,
|
|
12
|
+
requirePuppeteer: false,
|
|
13
|
+
antiCrawler: false,
|
|
14
|
+
supportBT: false,
|
|
15
|
+
supportPodcast: false,
|
|
16
|
+
supportScihub: false,
|
|
17
|
+
},
|
|
18
|
+
radar: [
|
|
19
|
+
{
|
|
20
|
+
source: ['amz123.com/kx'],
|
|
21
|
+
target: '/kx',
|
|
22
|
+
},
|
|
23
|
+
],
|
|
24
|
+
name: 'AMZ123 快讯',
|
|
25
|
+
maintainers: ['defp'],
|
|
26
|
+
handler,
|
|
27
|
+
url: 'amz123.com/kx',
|
|
28
|
+
view: ViewType.Articles,
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
async function handler() {
|
|
32
|
+
const limit = 12;
|
|
33
|
+
const apiRootUrl = 'https://api.amz123.com';
|
|
34
|
+
const rootUrl = 'https://www.amz123.com';
|
|
35
|
+
|
|
36
|
+
const { data: response } = await got.post(`${apiRootUrl}/ugc/v1/user_content/forum_list`, {
|
|
37
|
+
json: {
|
|
38
|
+
page: 1,
|
|
39
|
+
page_size: limit,
|
|
40
|
+
tag_id: 0,
|
|
41
|
+
fid: 4,
|
|
42
|
+
ban: 0,
|
|
43
|
+
is_new: 1,
|
|
44
|
+
},
|
|
45
|
+
headers: {
|
|
46
|
+
'content-type': 'application/json',
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
|
|
50
|
+
const items = response.data.rows.map((item) => ({
|
|
51
|
+
title: item.title,
|
|
52
|
+
description: item.description,
|
|
53
|
+
pubDate: parseDate(item.published_at * 1000),
|
|
54
|
+
link: `${rootUrl}/kx/${item.id}`,
|
|
55
|
+
author: item.author?.username,
|
|
56
|
+
category: item.tags.map((tag) => tag.name),
|
|
57
|
+
guid: item.resource_id,
|
|
58
|
+
}));
|
|
59
|
+
|
|
60
|
+
return {
|
|
61
|
+
title: 'AMZ123 快讯',
|
|
62
|
+
link: `${rootUrl}/kx`,
|
|
63
|
+
item: items,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { Route, ViewType } from '@/types';
|
|
2
2
|
import { load } from 'cheerio';
|
|
3
|
-
import
|
|
3
|
+
import ofetch from '@/utils/ofetch';
|
|
4
4
|
import rssParser from '@/utils/rss-parser';
|
|
5
5
|
import { asyncPoolAll, parseArticle } from './utils';
|
|
6
6
|
|
|
7
7
|
const parseAuthorNewsList = async (slug) => {
|
|
8
8
|
const baseURL = `https://www.bloomberg.com/authors/${slug}`;
|
|
9
9
|
const apiUrl = `https://www.bloomberg.com/lineup/api/lazy_load_author_stories?slug=${slug}&authorType=default&page=1`;
|
|
10
|
-
const resp = await
|
|
10
|
+
const resp = await ofetch(apiUrl);
|
|
11
11
|
// Likely rate limited
|
|
12
|
-
if (!resp.
|
|
12
|
+
if (!resp.html) {
|
|
13
13
|
return [];
|
|
14
14
|
}
|
|
15
|
-
const $ = load(resp.
|
|
15
|
+
const $ = load(resp.html);
|
|
16
16
|
const articles = $('article.story-list-story');
|
|
17
17
|
return articles
|
|
18
18
|
.map((index, item) => {
|
|
@@ -49,7 +49,7 @@ export const route: Route = {
|
|
|
49
49
|
},
|
|
50
50
|
],
|
|
51
51
|
name: 'Authors',
|
|
52
|
-
maintainers: ['josh'],
|
|
52
|
+
maintainers: ['josh', 'pseudoyu'],
|
|
53
53
|
handler,
|
|
54
54
|
};
|
|
55
55
|
|
|
@@ -67,7 +67,7 @@ async function handler(ctx) {
|
|
|
67
67
|
}
|
|
68
68
|
|
|
69
69
|
const item = await asyncPoolAll(1, list, (item) => parseArticle(item));
|
|
70
|
-
const authorName = item.find((i) => i.author)?.author ??
|
|
70
|
+
const authorName = item.find((i) => i.author)?.author ?? slug;
|
|
71
71
|
|
|
72
72
|
return {
|
|
73
73
|
title: `Bloomberg - ${authorName}`,
|
package/lib/routes/bsky/posts.ts
CHANGED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
import ofetch from '@/utils/ofetch';
|
|
3
|
+
import { parseDate } from '@/utils/parse-date';
|
|
4
|
+
import type { Context } from 'hono';
|
|
5
|
+
import { Value } from './types';
|
|
6
|
+
|
|
7
|
+
export const route: Route = {
|
|
8
|
+
path: '/share/:shortId',
|
|
9
|
+
categories: ['other'],
|
|
10
|
+
example: '/dingshao/share/FzFypN',
|
|
11
|
+
parameters: {
|
|
12
|
+
shortId: '频道 ID',
|
|
13
|
+
},
|
|
14
|
+
radar: [
|
|
15
|
+
{
|
|
16
|
+
source: ['www.dingshao.cn/share/:shortId'],
|
|
17
|
+
},
|
|
18
|
+
],
|
|
19
|
+
name: '频道',
|
|
20
|
+
maintainers: ['TonyRL'],
|
|
21
|
+
handler,
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const baseUrl = 'https://www.dingshao.cn';
|
|
25
|
+
|
|
26
|
+
async function handler(ctx: Context) {
|
|
27
|
+
const { shortId } = ctx.req.param();
|
|
28
|
+
|
|
29
|
+
const response = await ofetch<Value>(`${baseUrl}/api/v2/channel/get-channel-and-recent-messages-by-short-id`, {
|
|
30
|
+
method: 'POST',
|
|
31
|
+
body: {
|
|
32
|
+
shortId,
|
|
33
|
+
},
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
const items = response.value.bundle.channelMessages.map((message) => ({
|
|
37
|
+
title: message.excerpt.split('\n')[0],
|
|
38
|
+
description: message.content,
|
|
39
|
+
pubDate: parseDate(message.publishedAt),
|
|
40
|
+
category: message.tags,
|
|
41
|
+
link: `${baseUrl}/channel/${response.value.channel}/${message.id}`,
|
|
42
|
+
}));
|
|
43
|
+
|
|
44
|
+
const channelProfile = response.value.bundle.channels.find((channel) => channel.id === response.value.channel)?.profile;
|
|
45
|
+
|
|
46
|
+
return {
|
|
47
|
+
title: channelProfile?.name,
|
|
48
|
+
description: channelProfile?.description,
|
|
49
|
+
link: `${baseUrl}/share/${shortId}`,
|
|
50
|
+
image: channelProfile?.image,
|
|
51
|
+
item: items,
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
export interface Value {
|
|
2
|
+
value: {
|
|
3
|
+
channel: string;
|
|
4
|
+
recentMessages: string[];
|
|
5
|
+
bundle: Bundle;
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
interface Bundle {
|
|
10
|
+
channels: Channel[];
|
|
11
|
+
users: User[];
|
|
12
|
+
channelMessages: ChannelMessage[];
|
|
13
|
+
channelMessageInteractions: any[];
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
interface Channel {
|
|
17
|
+
id: string;
|
|
18
|
+
owner: string;
|
|
19
|
+
profile: Profile;
|
|
20
|
+
tags: string[];
|
|
21
|
+
script: Script;
|
|
22
|
+
private: boolean;
|
|
23
|
+
stats: Stats;
|
|
24
|
+
sharable: boolean;
|
|
25
|
+
lastPublishedAt: string;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
interface Profile {
|
|
29
|
+
name: string;
|
|
30
|
+
description: string;
|
|
31
|
+
image: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
interface Script {
|
|
35
|
+
homepage: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
interface Stats {
|
|
39
|
+
subscribers: number;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
interface User {
|
|
43
|
+
id: string;
|
|
44
|
+
profile: UserProfile;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
interface UserProfile {
|
|
48
|
+
name: string;
|
|
49
|
+
image: string;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
interface ChannelMessage {
|
|
53
|
+
id: string;
|
|
54
|
+
channel: string;
|
|
55
|
+
author: string;
|
|
56
|
+
tags: string[];
|
|
57
|
+
excerpt: string;
|
|
58
|
+
content: string;
|
|
59
|
+
likes: number;
|
|
60
|
+
private: boolean;
|
|
61
|
+
sharable: boolean;
|
|
62
|
+
script: boolean;
|
|
63
|
+
publishedAt: string;
|
|
64
|
+
}
|
|
@@ -19,17 +19,17 @@ export const route: Route = {
|
|
|
19
19
|
},
|
|
20
20
|
radar: [
|
|
21
21
|
{
|
|
22
|
-
source: ['fastbull.
|
|
22
|
+
source: ['fastbull.com/express-news', 'fastbull.com/'],
|
|
23
23
|
},
|
|
24
24
|
],
|
|
25
|
-
name: '
|
|
25
|
+
name: 'News Flash',
|
|
26
26
|
maintainers: ['nczitzk'],
|
|
27
27
|
handler,
|
|
28
|
-
url: 'fastbull.
|
|
28
|
+
url: 'fastbull.com/express-news',
|
|
29
29
|
};
|
|
30
30
|
|
|
31
31
|
async function handler() {
|
|
32
|
-
const rootUrl = 'https://www.fastbull.
|
|
32
|
+
const rootUrl = 'https://www.fastbull.com';
|
|
33
33
|
const currentUrl = `${rootUrl}/express-news`;
|
|
34
34
|
|
|
35
35
|
const response = await got({
|
|
@@ -10,7 +10,7 @@ import { art } from '@/utils/render';
|
|
|
10
10
|
import path from 'node:path';
|
|
11
11
|
|
|
12
12
|
export const route: Route = {
|
|
13
|
-
path:
|
|
13
|
+
path: '/news',
|
|
14
14
|
categories: ['finance', 'popular'],
|
|
15
15
|
view: ViewType.Articles,
|
|
16
16
|
example: '/fastbull/news',
|
|
@@ -25,18 +25,18 @@ export const route: Route = {
|
|
|
25
25
|
},
|
|
26
26
|
radar: [
|
|
27
27
|
{
|
|
28
|
-
source: ['fastbull.cn/news', 'fastbull.cn
|
|
28
|
+
source: ['fastbull.com/cn/news', 'fastbull.com/cn'],
|
|
29
29
|
},
|
|
30
30
|
],
|
|
31
|
-
name: '
|
|
31
|
+
name: 'News',
|
|
32
32
|
maintainers: ['nczitzk'],
|
|
33
33
|
handler,
|
|
34
|
-
url: 'fastbull.
|
|
34
|
+
url: 'fastbull.com/news',
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
async function handler() {
|
|
38
|
-
const rootUrl = 'https://www.fastbull.
|
|
39
|
-
const currentUrl = `${rootUrl}/news`;
|
|
38
|
+
const rootUrl = 'https://www.fastbull.com';
|
|
39
|
+
const currentUrl = `${rootUrl}/cn/news`;
|
|
40
40
|
|
|
41
41
|
const response = await got({
|
|
42
42
|
method: 'get',
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
import ofetch from '@/utils/ofetch';
|
|
3
|
+
import cache from '@/utils/cache';
|
|
4
|
+
import { namespace } from './namespace';
|
|
5
|
+
import logger from '@/utils/logger';
|
|
6
|
+
|
|
7
|
+
export const route: Route = {
|
|
8
|
+
path: '/',
|
|
9
|
+
categories: namespace.categories,
|
|
10
|
+
example: '/foodtalks',
|
|
11
|
+
radar: [
|
|
12
|
+
{
|
|
13
|
+
source: ['www.foodtalks.cn'],
|
|
14
|
+
},
|
|
15
|
+
],
|
|
16
|
+
name: 'FoodTalks global food information network',
|
|
17
|
+
maintainers: ['Geraldxm'],
|
|
18
|
+
handler,
|
|
19
|
+
url: 'www.foodtalks.cn',
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
function processItems(list: any[], fullTextApi: string) {
|
|
23
|
+
return Promise.all(
|
|
24
|
+
list.map((item) =>
|
|
25
|
+
cache.tryGet(item.link, async () => {
|
|
26
|
+
try {
|
|
27
|
+
const response = await ofetch(fullTextApi.replace('{id}', item.id), {
|
|
28
|
+
headers: {
|
|
29
|
+
referrer: 'https://www.foodtalks.cn/',
|
|
30
|
+
method: 'GET',
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
item.description = response.data.content;
|
|
34
|
+
return item;
|
|
35
|
+
} catch (error) {
|
|
36
|
+
logger.error(`Error fetching full text for ${item.link}:`, error);
|
|
37
|
+
return item;
|
|
38
|
+
}
|
|
39
|
+
})
|
|
40
|
+
)
|
|
41
|
+
);
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async function handler(ctx) {
|
|
45
|
+
const limit = ctx.req.query('limit') || 15;
|
|
46
|
+
const url = `https://api-we.foodtalks.cn/news/news/page?current=1&size=${limit}&isLatest=1&language=ZH`;
|
|
47
|
+
const response = await ofetch(url, {
|
|
48
|
+
headers: {
|
|
49
|
+
referrer: 'https://www.foodtalks.cn/',
|
|
50
|
+
method: 'GET',
|
|
51
|
+
},
|
|
52
|
+
});
|
|
53
|
+
const records = response.data.records;
|
|
54
|
+
|
|
55
|
+
const list = records.map((item) => ({
|
|
56
|
+
title: item.title,
|
|
57
|
+
pubDate: new Date(item.publishTime),
|
|
58
|
+
link: `https://www.foodtalks.cn/news/${item.id}`,
|
|
59
|
+
category: item.parentTagCode === 'category' ? item.tagCode : item.parentTagCode,
|
|
60
|
+
author: item.author === null ? item.sourceName : item.author,
|
|
61
|
+
id: item.id,
|
|
62
|
+
image: item.coverImg,
|
|
63
|
+
}));
|
|
64
|
+
|
|
65
|
+
const fullTextApi = 'https://api-we.foodtalks.cn/news/news/{id}?language=ZH';
|
|
66
|
+
const items = await processItems(list, fullTextApi);
|
|
67
|
+
|
|
68
|
+
return {
|
|
69
|
+
title: namespace.name,
|
|
70
|
+
description: namespace.description,
|
|
71
|
+
link: 'https://' + namespace.url,
|
|
72
|
+
item: items,
|
|
73
|
+
image: 'https://www.foodtalks.cn/static/img/news-site-logo.7aaa5463.svg',
|
|
74
|
+
};
|
|
75
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { Namespace } from '@/types';
|
|
2
|
+
|
|
3
|
+
export const namespace: Namespace = {
|
|
4
|
+
name: 'FoodTalks全球食品资讯网',
|
|
5
|
+
url: 'www.foodtalks.cn',
|
|
6
|
+
categories: ['new-media'],
|
|
7
|
+
lang: 'zh-CN',
|
|
8
|
+
description: 'FoodTalks全球食品资讯网是一个提供食品饮料行业新闻、资讯、分析和商业资源的领先在线平台。它涵盖行业趋势、市场动态、产品创新、投融资信息以及企业新闻,连接行业内的专业人士、企业和消费者。',
|
|
9
|
+
};
|
package/lib/routes/hbr/topic.ts
CHANGED
|
@@ -1,14 +1,25 @@
|
|
|
1
1
|
import { Route } from '@/types';
|
|
2
2
|
import cache from '@/utils/cache';
|
|
3
|
-
import
|
|
3
|
+
import ofetch from '@/utils/ofetch';
|
|
4
4
|
import { load } from 'cheerio';
|
|
5
5
|
import { parseDate } from '@/utils/parse-date';
|
|
6
6
|
|
|
7
7
|
export const route: Route = {
|
|
8
8
|
path: '/topic/:topic?/:type?',
|
|
9
|
-
categories: ['new-media'],
|
|
10
|
-
example: '/hbr/topic/
|
|
11
|
-
parameters: {
|
|
9
|
+
categories: ['new-media', 'popular'],
|
|
10
|
+
example: '/hbr/topic/Leadership/Popular',
|
|
11
|
+
parameters: {
|
|
12
|
+
topic: 'Topic, can be found in URL, Leadership by default',
|
|
13
|
+
type: {
|
|
14
|
+
description: 'Type, see below, Popular by default',
|
|
15
|
+
options: [
|
|
16
|
+
{ value: 'Popular', label: 'Popular' },
|
|
17
|
+
{ value: 'From the Store', label: 'From the Store' },
|
|
18
|
+
{ value: 'For You', label: 'For You' },
|
|
19
|
+
],
|
|
20
|
+
default: 'Popular',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
12
23
|
features: {
|
|
13
24
|
requireConfig: false,
|
|
14
25
|
requirePuppeteer: false,
|
|
@@ -23,11 +34,11 @@ export const route: Route = {
|
|
|
23
34
|
},
|
|
24
35
|
],
|
|
25
36
|
name: 'Topic',
|
|
26
|
-
maintainers: ['nczitzk'],
|
|
37
|
+
maintainers: ['nczitzk', 'pseudoyu'],
|
|
27
38
|
handler,
|
|
28
|
-
description: `|
|
|
29
|
-
|
|
|
30
|
-
|
|
|
39
|
+
description: `| POPULAR | FROM THE STORE | FOR YOU |
|
|
40
|
+
| ------- | -------------- | ------- |
|
|
41
|
+
| Popular | From the Store | For You |
|
|
31
42
|
|
|
32
43
|
:::tip
|
|
33
44
|
Click here to view [All Topics](https://hbr.org/topics)
|
|
@@ -35,18 +46,15 @@ export const route: Route = {
|
|
|
35
46
|
};
|
|
36
47
|
|
|
37
48
|
async function handler(ctx) {
|
|
38
|
-
const topic = ctx.req.param('topic') ?? '
|
|
39
|
-
const type = ctx.req.param('type') ?? '
|
|
49
|
+
const topic = ctx.req.param('topic') ?? 'Leadership';
|
|
50
|
+
const type = ctx.req.param('type') ?? 'Popular';
|
|
40
51
|
|
|
41
52
|
const rootUrl = 'https://hbr.org';
|
|
42
53
|
const currentUrl = `${rootUrl}/topic/${topic}`;
|
|
43
54
|
|
|
44
|
-
const response = await
|
|
45
|
-
method: 'get',
|
|
46
|
-
url: currentUrl,
|
|
47
|
-
});
|
|
55
|
+
const response = await ofetch(currentUrl);
|
|
48
56
|
|
|
49
|
-
const $ = load(response
|
|
57
|
+
const $ = load(response);
|
|
50
58
|
|
|
51
59
|
const list = $(`stream-content[data-stream-name="${type}"]`)
|
|
52
60
|
.find('.stream-item')
|
|
@@ -65,12 +73,9 @@ async function handler(ctx) {
|
|
|
65
73
|
const items = await Promise.all(
|
|
66
74
|
list.map((item) =>
|
|
67
75
|
cache.tryGet(item.link, async () => {
|
|
68
|
-
const detailResponse = await
|
|
69
|
-
method: 'get',
|
|
70
|
-
url: item.link,
|
|
71
|
-
});
|
|
76
|
+
const detailResponse = await ofetch(item.link);
|
|
72
77
|
|
|
73
|
-
const content = load(detailResponse
|
|
78
|
+
const content = load(detailResponse);
|
|
74
79
|
|
|
75
80
|
item.description = content('.article-body, article[itemprop="description"]').html();
|
|
76
81
|
item.pubDate = parseDate(content('meta[property="article:published_time"]').attr('content'));
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { Route } from '@/types';
|
|
2
|
+
|
|
3
|
+
import got from '@/utils/got';
|
|
4
|
+
import { parseDate } from '@/utils/parse-date';
|
|
5
|
+
|
|
6
|
+
const sorts = {
|
|
7
|
+
hot: '热门',
|
|
8
|
+
last: '最近',
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
export const route: Route = {
|
|
12
|
+
path: '/article/:sort?',
|
|
13
|
+
categories: ['programming'],
|
|
14
|
+
example: '/hellogithub/article',
|
|
15
|
+
parameters: { sort: '排序方式,见下表,默认为 `last`,即最近' },
|
|
16
|
+
features: {
|
|
17
|
+
requireConfig: false,
|
|
18
|
+
requirePuppeteer: false,
|
|
19
|
+
antiCrawler: false,
|
|
20
|
+
supportBT: false,
|
|
21
|
+
supportPodcast: false,
|
|
22
|
+
supportScihub: false,
|
|
23
|
+
},
|
|
24
|
+
name: '文章',
|
|
25
|
+
maintainers: ['moke8', 'nczitzk', 'CaoMeiYouRen'],
|
|
26
|
+
handler,
|
|
27
|
+
description: `| 热门 | 最近 |
|
|
28
|
+
| ---- | ---- |
|
|
29
|
+
| hot | last |`,
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
async function handler(ctx) {
|
|
33
|
+
const sort = ctx.req.param('sort') ?? 'last';
|
|
34
|
+
const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20;
|
|
35
|
+
|
|
36
|
+
const rootUrl = 'https://hellogithub.com';
|
|
37
|
+
const apiRootUrl = 'https://api.hellogithub.com/v1/article/';
|
|
38
|
+
const currentUrl = `${rootUrl}/article/?sort_by=${sort}`;
|
|
39
|
+
const apiUrl = `${apiRootUrl}?sort_by=${sort}&page=1`;
|
|
40
|
+
|
|
41
|
+
const response = await got({
|
|
42
|
+
method: 'get',
|
|
43
|
+
url: apiUrl,
|
|
44
|
+
});
|
|
45
|
+
|
|
46
|
+
const items = response.data.data.slice(0, limit).map((item) => ({
|
|
47
|
+
title: item.title,
|
|
48
|
+
description: `<figure>
|
|
49
|
+
<img src="${item.head_image}">
|
|
50
|
+
</figure><br>${item.desc}`,
|
|
51
|
+
link: `${rootUrl}/article/${item.aid}`,
|
|
52
|
+
author: item.author,
|
|
53
|
+
guid: item.aid,
|
|
54
|
+
pubDate: parseDate(item.publish_at),
|
|
55
|
+
}));
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
title: `HelloGithub - ${sorts[sort]}文章`,
|
|
59
|
+
link: currentUrl,
|
|
60
|
+
item: items,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
@@ -10,7 +10,7 @@ const sorts = {
|
|
|
10
10
|
};
|
|
11
11
|
|
|
12
12
|
export const route: Route = {
|
|
13
|
-
path:
|
|
13
|
+
path: '/home/:sort?/:id?',
|
|
14
14
|
categories: ['programming'],
|
|
15
15
|
example: '/hellogithub/home',
|
|
16
16
|
parameters: { sort: '排序方式,见下表,默认为 `featured`,即精选', id: '标签 id,可在对应标签页 URL 中找到,默认为全部标签' },
|
|
@@ -23,7 +23,7 @@ export const route: Route = {
|
|
|
23
23
|
supportScihub: false,
|
|
24
24
|
},
|
|
25
25
|
name: '开源项目',
|
|
26
|
-
maintainers: ['moke8', 'nczitzk'],
|
|
26
|
+
maintainers: ['moke8', 'nczitzk', 'CaoMeiYouRen'],
|
|
27
27
|
handler,
|
|
28
28
|
description: `| 精选 | 全部 |
|
|
29
29
|
| ---- | ---- |
|