mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): gelonghui (#10861)
This commit is contained in:
+13
-3
@@ -244,17 +244,27 @@ TokenInsight 官方亦有提供 RSS,可参考 <https://api.tokeninsight.com/re
|
||||
|
||||
## 格隆汇
|
||||
|
||||
### 首页
|
||||
|
||||
<Route author="TonyRL" example="/gelonghui/home" path="/gelonghui/home/:tag?" :paramsDesc="['分类标签,见下表,默认为 `web_home_page`']" radar="1" rssbud="1">
|
||||
|
||||
| 推荐 | 股票 | 基金 | 新股 | 研报 |
|
||||
| ------------- | ----- | ---- | --------- | -------- |
|
||||
| web_home_page | stock | fund | new_stock | research |
|
||||
|
||||
</Route>
|
||||
|
||||
### 用户文章
|
||||
|
||||
<Route author="nczitzk" example="/gelonghui/user/5273" path="/gelonghui/user/:id" :paramsDesc="['用户编号, 可在用户页 URL 中找到']"/>
|
||||
<Route author="nczitzk" example="/gelonghui/user/5273" path="/gelonghui/user/:id" :paramsDesc="['用户编号, 可在用户页 URL 中找到']" radar="1" rssbud="1"/>
|
||||
|
||||
### 主题文章
|
||||
|
||||
<Route author="nczitzk" example="/gelonghui/subject/4" path="/gelonghui/subject/:id" :paramsDesc="['主题编号, 可在主题页 URL 中找到']"/>
|
||||
<Route author="nczitzk" example="/gelonghui/subject/4" path="/gelonghui/subject/:id" :paramsDesc="['主题编号, 可在主题页 URL 中找到']" radar="1" rssbud="1"/>
|
||||
|
||||
### 搜索关键字
|
||||
|
||||
<Route author="nczitzk" example="/gelonghui/keyword/早报" path="/gelonghui/keyword/:keyword" :paramsDesc="['搜索关键字']"/>
|
||||
<Route author="nczitzk" example="/gelonghui/keyword/早报" path="/gelonghui/keyword/:keyword" :paramsDesc="['搜索关键字']" radar="1" rssbud="1"/>
|
||||
|
||||
## 国家金融与发展实验室
|
||||
|
||||
|
||||
+4
-4
@@ -2968,10 +2968,10 @@ router.get('/dsb/area/:area', lazyloadRouteHandler('./routes/dsb/area'));
|
||||
// 靠谱新闻
|
||||
router.get('/kaopunews/:language?', lazyloadRouteHandler('./routes/kaopunews'));
|
||||
|
||||
// 格隆汇
|
||||
router.get('/gelonghui/user/:id', lazyloadRouteHandler('./routes/gelonghui/user'));
|
||||
router.get('/gelonghui/subject/:id', lazyloadRouteHandler('./routes/gelonghui/subject'));
|
||||
router.get('/gelonghui/keyword/:keyword', lazyloadRouteHandler('./routes/gelonghui/keyword'));
|
||||
// 格隆汇 migrated to v2
|
||||
// router.get('/gelonghui/user/:id', lazyloadRouteHandler('./routes/gelonghui/user'));
|
||||
// router.get('/gelonghui/subject/:id', lazyloadRouteHandler('./routes/gelonghui/subject'));
|
||||
// router.get('/gelonghui/keyword/:keyword', lazyloadRouteHandler('./routes/gelonghui/keyword'));
|
||||
|
||||
// 光谷社区
|
||||
router.get('/guanggoo/:category?', lazyloadRouteHandler('./routes/guanggoo/index'));
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = `https://www.gelonghui.com/api/search/post?keyword=${ctx.params.keyword}&count=20&page=1&type=all`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = response.data.result.postList.map((item) => ({
|
||||
title: item.title,
|
||||
link: `https://www.gelonghui.com/p/${item.id}`,
|
||||
pubDate: new Date(item.createDate).toUTCString(),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(res.data);
|
||||
|
||||
item.description = content('article.article-with-html').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `格隆汇 - 关键词 “${ctx.params.keyword}” 的文章`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
description: $('p.search-number').text(),
|
||||
};
|
||||
};
|
||||
@@ -1,42 +0,0 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = `https://www.gelonghui.com/subject/${ctx.params.id}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('#subject-article ul li')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const h = item.find('h2').length === 0 ? item.find('p') : item.find('h2');
|
||||
return {
|
||||
title: h.text(),
|
||||
link: h.parent().attr('href'),
|
||||
pubDate: new Date(item.find('span').eq(2).text()).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(res.data);
|
||||
|
||||
item.description = content('article.article-with-html').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `格隆汇 - 主题 ${$('span.user-nick').text()} 的文章`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
description: $('div.user-name').parent().children('p').text(),
|
||||
};
|
||||
};
|
||||
@@ -1,46 +0,0 @@
|
||||
const url = require('url');
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const currentUrl = `https://www.gelonghui.com/user/${ctx.params.id}?type=article`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const list = $('section.item')
|
||||
.slice(0, 15)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const h = item.find('h2');
|
||||
const pubDate = item.find('p').text();
|
||||
return {
|
||||
title: h.text(),
|
||||
link: url.resolve(`https://www.gelonghui.com`, h.parent().attr('href')),
|
||||
pubDate: new Date(
|
||||
pubDate.substr(pubDate.length - 1, 1) !== '分' ? new Date().getFullYear() + '-' + pubDate : pubDate.replace('年', '-').replace('月', '-').replace('日', ' ').replace('时', ':').replace('分', '')
|
||||
).toUTCString(),
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(res.data);
|
||||
|
||||
item.description = content('article.article-with-html').html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: `格隆汇 - 用户 ${$('p.nick').text()} 的文章`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
description: $('div.val').text(),
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { parseItem } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { tag = 'web_home_page' } = ctx.params;
|
||||
const apiUrl = `https://www.gelonghui.com/api/channels/${tag}/articles/v8`;
|
||||
const { data } = await got(apiUrl);
|
||||
|
||||
const list = data.result.map((article) => {
|
||||
article = article.data;
|
||||
return {
|
||||
title: article.title,
|
||||
description: article.summary,
|
||||
link: article.link,
|
||||
author: article.nick,
|
||||
category: article.source,
|
||||
pubDate: parseDate(article.timestamp, 'X'),
|
||||
};
|
||||
});
|
||||
|
||||
const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: '格隆汇-财经资讯动态-股市行情',
|
||||
description: '格隆汇为中国投资者出海投资及中国公司出海融资,提供海外投资,港股开户行情,科创板股票发行数据、资讯、研究、交易等一站式服务,目前业务范围主要涉及港股与美股两大市场,未来将陆续开通台湾、日本、印度、欧洲等市场.',
|
||||
image: 'https://cdn.gelonghui.com/static/web/www.ico.la.ico',
|
||||
link: 'https://www.gelonghui.com',
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,34 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { parseItem } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { keyword } = ctx.params;
|
||||
const currentUrl = `https://www.gelonghui.com/api/post/search/v4`;
|
||||
const { data } = await got(currentUrl, {
|
||||
searchParams: {
|
||||
keyword,
|
||||
isVipArticle: false,
|
||||
count: ctx.query.limit ? Number(ctx.query.limit) : 20,
|
||||
page: 1,
|
||||
searchArea: 'all',
|
||||
},
|
||||
});
|
||||
|
||||
const list = data.result.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.summary,
|
||||
link: item.link,
|
||||
author: item.source,
|
||||
pubDate: parseDate(item.timestamp, 'X'),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `格隆汇 - 关键词 “${keyword}” 的文章`,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
description: `找到关于 “ ${keyword} ”的文章,共${data.totalCount}个结果`,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
'/home/:tag?': ['TonyRL'],
|
||||
'/keyword/:keyword': ['nczitzk'],
|
||||
'/subject/:id': ['nczitzk'],
|
||||
'/user/:id': ['nczitzk'],
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
module.exports = {
|
||||
'gelonghui.com': {
|
||||
_name: '格隆汇',
|
||||
'.': [
|
||||
{
|
||||
title: '首页',
|
||||
docs: 'https://docs.rsshub.app/finance.html#ge-long-hui',
|
||||
source: ['/tag/:tag', '/'],
|
||||
target: (params) => `/gelonghui/home${params.tag ? `/${params.tag}` : ''}`,
|
||||
},
|
||||
{
|
||||
title: '搜索关键字',
|
||||
docs: 'https://docs.rsshub.app/finance.html#ge-long-hui',
|
||||
source: ['/search'],
|
||||
target: (_, url) => `/gelonghui/keyword/${new URL(url).searchParams.get('keyword')}`,
|
||||
},
|
||||
{
|
||||
title: '主题文章',
|
||||
docs: 'https://docs.rsshub.app/finance.html#ge-long-hui',
|
||||
source: ['/subject/:id'],
|
||||
target: '/gelonghui/subject/:id',
|
||||
},
|
||||
{
|
||||
title: '用户文章',
|
||||
docs: 'https://docs.rsshub.app/finance.html#ge-long-hui',
|
||||
source: ['/user/:id'],
|
||||
target: '/gelonghui/user/:id',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/home/:tag?', require('./home'));
|
||||
router.get('/keyword/:keyword', require('./keyword'));
|
||||
router.get('/subject/:id', require('./subject'));
|
||||
router.get('/user/:id', require('./user'));
|
||||
};
|
||||
@@ -0,0 +1,36 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { parseItem } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id } = ctx.params;
|
||||
const apiUrl = `https://www.gelonghui.com/api/subjects/${id}/contents`;
|
||||
const pageUrl = `https://www.gelonghui.com/subject/${id}`;
|
||||
const { data: response } = await got(pageUrl);
|
||||
const { data } = await got(apiUrl, {
|
||||
searchParams: {
|
||||
isChoice: false,
|
||||
},
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const list = data.result.map((item) => ({
|
||||
title: item.title,
|
||||
description: item.summary,
|
||||
link: item.link,
|
||||
author: item.source,
|
||||
pubDate: parseDate(item.timestamp, 'X'),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `格隆汇 - 主题 ${$('span.user-nick').text()} 的文章`,
|
||||
description: $('div.user-name').parent().children('p').text(),
|
||||
image: $('.subject-list-title').find('img').attr('data-src'),
|
||||
link: `https://www.gelonghui.com/subject/${id}`,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
const got = require('@/utils/got');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const { parseItem } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id: userId } = ctx.params;
|
||||
const currentUrl = 'https://www.gelonghui.com/api/community/dynamic/my-dynamics/v2';
|
||||
const { data } = await got(currentUrl, {
|
||||
searchParams: {
|
||||
article: true,
|
||||
userId,
|
||||
count: ctx.query.limit ? Number(ctx.query.limit) : 15,
|
||||
},
|
||||
});
|
||||
|
||||
const list = data.result.map((item) => ({
|
||||
title: item.title,
|
||||
link: item.route,
|
||||
description: item.content,
|
||||
author: item.user.nick,
|
||||
pubDate: parseDate(item.createTimestamp, 'X'),
|
||||
}));
|
||||
|
||||
const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `格隆汇 - 用户 ${data.result[0].user.nick} 的文章`,
|
||||
description: data.result.find((i) => i.user).user.brief,
|
||||
image: data.result.find((i) => i.user).user.avatar.split('@')[0],
|
||||
link: data.result.find((i) => i.user).user.route.replace('https://m.gelonghui.com', 'https://www.gelonghui.com'),
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,21 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const parseItem = (item, tryGet) =>
|
||||
tryGet(item.link, async () => {
|
||||
const { data: res } = await got(item.link);
|
||||
const $ = cheerio.load(res);
|
||||
if (item.link.startsWith('https://www.gelonghui.com/live/')) {
|
||||
item.title = $('.type-name').next().text().trim();
|
||||
item.description = $('.dtb-content').html();
|
||||
} else {
|
||||
// article
|
||||
item.title = $('.article-title').text().trim();
|
||||
item.description = $('.article-summary').html() + $('article.article-with-html').html();
|
||||
}
|
||||
return item;
|
||||
});
|
||||
|
||||
module.exports = {
|
||||
parseItem,
|
||||
};
|
||||
Reference in New Issue
Block a user