Skip to content

Commit

Permalink
Merge pull request #764 from DIYgod/master
Browse files Browse the repository at this point in the history
[pull] master from diygod:master
  • Loading branch information
pull[bot] authored Jan 28, 2023
2 parents 1da7edf + c5df480 commit ec2dd45
Show file tree
Hide file tree
Showing 9 changed files with 124 additions and 25 deletions.
12 changes: 10 additions & 2 deletions docs/finance.md
Original file line number Diff line number Diff line change
Expand Up @@ -284,16 +284,24 @@ TokenInsight 官方亦有提供 RSS,可参考 <https://api.tokeninsight.com/re

### 用户文章

<Route author="nczitzk" example="/gelonghui/user/5273" path="/gelonghui/user/:id" :paramsDesc="['用户编号, 可在用户页 URL 中找到']" radar="1" rssbud="1"/>
<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 中找到']" radar="1" rssbud="1"/>
<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="['搜索关键字']" radar="1" rssbud="1"/>

### 最热文章

<Route author="TonyRL" example="/gelonghui/hot-article" path="/gelonghui/hot-article/:type?" :paramsDesc="['`day` 为日排行,`week` 为周排行,默认为 `day`']" radar="1" rssbud="1"/>

### 实时快讯

<Route author="TonyRL" example="/gelonghui/live" path="/gelonghui/live" radar="1" rssbud="1"/>

## 国家金融与发展实验室

### 研究
Expand Down
33 changes: 33 additions & 0 deletions lib/v2/gelonghui/hot-article.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseItem } = require('./utils');

module.exports = async (ctx) => {
const type = ctx.params.type === 'week' ? 1 : 0;
const baseUrl = `https://www.gelonghui.com`;
const { data: response } = await got(baseUrl);
const $ = cheerio.load(response);

const list = $('#hot-article ul')
.eq(type)
.find('li')
.toArray()
.map((item) => {
item = $(item);
const a = item.find('a');
return {
title: a.text(),
link: `${baseUrl}${a.attr('href')}`,
};
});

const items = await Promise.all(list.map((item) => parseItem(item, ctx.cache.tryGet)));

ctx.state.data = {
title: `最热文章 - ${type === 0 ? '日排行' : '周排行'} - 格隆汇`,
description: '格隆汇为中国投资者出海投资及中国公司出海融资,提供海外投资,港股开户行情,科创板股票发行数据、资讯、研究、交易等一站式服务,目前业务范围主要涉及港股与美股两大市场,未来将陆续开通台湾、日本、印度、欧洲等市场.',
image: 'https://cdn.gelonghui.com/static/web/www.ico.la.ico',
link: baseUrl,
item: items,
};
};
31 changes: 31 additions & 0 deletions lib/v2/gelonghui/live.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
const got = require('@/utils/got');
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');

const baseUrl = 'https://www.gelonghui.com';

module.exports = async (ctx) => {
const apiUrl = `${baseUrl}/api/live-channels/all/lives/v4`;
const {
data: { result },
} = await got(apiUrl);

const items = result.map((i) => ({
title: i.title || i.content,
description: art(path.join(__dirname, 'templates/live.art'), {
i,
}),
link: i.route,
category: i.source,
pubDate: parseDate(i.createTimestamp, 'X'),
}));

ctx.state.data = {
title: '格隆汇快讯-7x24小时市场快讯-财经市场热点',
description: '格隆汇快讯栏目提供外汇投资实时行情,外汇投资交易,外汇投资炒股,证券等内容,实时更新,格隆汇未来将陆续开通台湾、日本、印度、欧洲等市场.',
image: 'https://cdn.gelonghui.com/static/web/www.ico.la.ico',
link: `${baseUrl}/live`,
item: items,
};
};
12 changes: 12 additions & 0 deletions lib/v2/gelonghui/radar.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,24 @@ module.exports = {
source: ['/tag/:tag', '/'],
target: (params) => `/gelonghui/home${params.tag ? `/${params.tag}` : ''}`,
},
{
title: '最热文章',
docs: 'https://docs.rsshub.app/finance.html#ge-long-hui',
source: ['/'],
target: '/gelonghui/hot-article',
},
{
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: ['/live', '/'],
target: '/gelonghui/live',
},
{
title: '主题文章',
docs: 'https://docs.rsshub.app/finance.html#ge-long-hui',
Expand Down
2 changes: 2 additions & 0 deletions lib/v2/gelonghui/router.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module.exports = (router) => {
router.get('/home/:tag?', require('./home'));
router.get('/hot-article/:type?', require('./hot-article'));
router.get('/keyword/:keyword', require('./keyword'));
router.get('/live', require('./live'));
router.get('/subject/:id', require('./subject'));
router.get('/user/:id', require('./user'));
};
7 changes: 7 additions & 0 deletions lib/v2/gelonghui/templates/live.art
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{{ i.content }}
{{ if i.pictures }}
<br>
{{ each i.pictures p }}
<img src="{{ p }}">
{{ /each }}
{{ /if }}
6 changes: 6 additions & 0 deletions lib/v2/gelonghui/utils.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const { parseDate, parseRelativeDate } = require('@/utils/parse-date');
const timezone = require('@/utils/timezone');

const parseItem = (item, tryGet) =>
tryGet(item.link, async () => {
Expand All @@ -12,6 +14,10 @@ const parseItem = (item, tryGet) =>
// article
item.title = $('.article-title').text().trim();
item.description = $('.article-summary').html() + $('article.article-with-html').html();
if (!item.pubDate) {
const isRelativeDate = $('time.date').text().includes('前') || $('time.date').text().includes('天');
item.pubDate = isRelativeDate ? parseRelativeDate($('time.date').text()) : timezone(parseDate($('time.date').text(), 'MM-DD HH:mm'), +8);
}
}
return item;
});
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@
"dependencies": {
"@koa/router": "12.0.0",
"@postlight/parser": "2.2.3",
"@sentry/node": "7.33.0",
"@sentry/node": "7.34.0",
"aes-js": "3.1.2",
"art-template": "4.13.2",
"bbcodejs": "0.0.4",
Expand Down
44 changes: 22 additions & 22 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1546,39 +1546,39 @@
domhandler "^5.0.3"
selderee "^0.10.0"

"@sentry/core@7.33.0":
version "7.33.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.33.0.tgz#7cba1670c041fae02794729b74e9fb9d1f519755"
integrity sha512-mrSgUnXjxHVi0cVea1lv7gC/Y66ya2a3atCHaPEij/+l+3APg5d0Ixt1zMx5YllMiZKf6wpxlZ0uwXcqdAAw+w==
"@sentry/core@7.34.0":
version "7.34.0"
resolved "https://registry.yarnpkg.com/@sentry/core/-/core-7.34.0.tgz#bfda8d386cf7343200aa9fb7a7a26e99b839fc0c"
integrity sha512-J1oxsYZX1N0tkEcaHt/uuDqk6zOnaivyampp+EvBsUMCdemjg7rwKvawlRB0ZtBEQu3HAhi8zecm03mlpWfCDw==
dependencies:
"@sentry/types" "7.33.0"
"@sentry/utils" "7.33.0"
"@sentry/types" "7.34.0"
"@sentry/utils" "7.34.0"
tslib "^1.9.3"

"@sentry/node@7.33.0":
version "7.33.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.33.0.tgz#d5c7c7094543dd9819422dfc69952ed40416bfab"
integrity sha512-isQVF9LLSG4EZLHiSJ3chgK6f3ZBdGxm8fX6YGm8HWz07CubJddes3yBPLPRNXrRLd7X3SK8pPcK5oc3LIKqAw==
"@sentry/node@7.34.0":
version "7.34.0"
resolved "https://registry.yarnpkg.com/@sentry/node/-/node-7.34.0.tgz#acf51e40b1ecbd91d7bf2df55c47ae1b30c39b40"
integrity sha512-VM4XeydRdgeaNTRe8kwqYg2oNPddVyY74PlCFEFnPEN1NccycNuwiFno68kNrApeqxxLlTTmzkJy0BWo16x2Yg==
dependencies:
"@sentry/core" "7.33.0"
"@sentry/types" "7.33.0"
"@sentry/utils" "7.33.0"
"@sentry/core" "7.34.0"
"@sentry/types" "7.34.0"
"@sentry/utils" "7.34.0"
cookie "^0.4.1"
https-proxy-agent "^5.0.0"
lru_map "^0.3.3"
tslib "^1.9.3"

"@sentry/types@7.33.0":
version "7.33.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.33.0.tgz#7d4893a783360a868382e5194b50dbf034ba23c0"
integrity sha512-5kkmYjtBWSbPxfYGiXdZFPS6xpFBNlXvDqeX4NpCFXz6/LiEDn6tZ61kuCSFb8MZlyqyCX5WsP3aiI2FJfpGIA==
"@sentry/types@7.34.0":
version "7.34.0"
resolved "https://registry.yarnpkg.com/@sentry/types/-/types-7.34.0.tgz#e0dc6a927dd13e4cacbca7bfee67a088885e8309"
integrity sha512-K+OeHIrl35PSYn6Zwqe4b8WWyAJQoI5NeWxHVkM7oQTGJ1YLG4BvLsR+UiUXnKdR5krE4EDtEA5jLsDlBEyPvw==

"@sentry/utils@7.33.0":
version "7.33.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.33.0.tgz#e6910139328b49b9cc21186521bdb10390dfd915"
integrity sha512-msp02GV1gOfaN5FjKjWxI00rtbYLXEE5cTGldhs/Dt9KI63dDk1nwPDkSLhg6joqRItAq0thlBh6un717HdWbg==
"@sentry/utils@7.34.0":
version "7.34.0"
resolved "https://registry.yarnpkg.com/@sentry/utils/-/utils-7.34.0.tgz#32fb6db8b352477d219ddff8200372959c68b445"
integrity sha512-VIHHXEBw0htzqxnU8A7WkXKvmsG2pZVqHlAn0H9W/yyFQtXMuP1j1i0NsjADB/3JXUKK83kTNWGzScXvp0o+Jg==
dependencies:
"@sentry/types" "7.33.0"
"@sentry/types" "7.34.0"
tslib "^1.9.3"

"@sinclair/typebox@^0.25.16":
Expand Down

1 comment on commit ec2dd45

@vercel
Copy link

@vercel vercel bot commented on ec2dd45 Jan 28, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.