diff --git a/docs/finance.md b/docs/finance.md index cab69b74daff44..78ebfac4be62ac 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -284,16 +284,24 @@ TokenInsight 官方亦有提供 RSS,可参考 + ### 主题文章 - + ### 搜索关键字 +### 最热文章 + + + +### 实时快讯 + + + ## 国家金融与发展实验室 ### 研究 diff --git a/lib/v2/gelonghui/hot-article.js b/lib/v2/gelonghui/hot-article.js new file mode 100644 index 00000000000000..9a96b14e6646a2 --- /dev/null +++ b/lib/v2/gelonghui/hot-article.js @@ -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, + }; +}; diff --git a/lib/v2/gelonghui/live.js b/lib/v2/gelonghui/live.js new file mode 100644 index 00000000000000..d5b1397cd7cce7 --- /dev/null +++ b/lib/v2/gelonghui/live.js @@ -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, + }; +}; diff --git a/lib/v2/gelonghui/radar.js b/lib/v2/gelonghui/radar.js index 6519a1f06b660e..c419c266d5f3dc 100644 --- a/lib/v2/gelonghui/radar.js +++ b/lib/v2/gelonghui/radar.js @@ -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', diff --git a/lib/v2/gelonghui/router.js b/lib/v2/gelonghui/router.js index 6517ad959628e7..5a11e1f563beaa 100644 --- a/lib/v2/gelonghui/router.js +++ b/lib/v2/gelonghui/router.js @@ -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')); }; diff --git a/lib/v2/gelonghui/templates/live.art b/lib/v2/gelonghui/templates/live.art new file mode 100644 index 00000000000000..bd712f6267a2f5 --- /dev/null +++ b/lib/v2/gelonghui/templates/live.art @@ -0,0 +1,7 @@ +{{ i.content }} +{{ if i.pictures }} +
+ {{ each i.pictures p }} + + {{ /each }} +{{ /if }} diff --git a/lib/v2/gelonghui/utils.js b/lib/v2/gelonghui/utils.js index 5e621b5daa29b7..6b875fb57cb156 100644 --- a/lib/v2/gelonghui/utils.js +++ b/lib/v2/gelonghui/utils.js @@ -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 () => { @@ -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; }); diff --git a/package.json b/package.json index 460bb93a339d28..374c91431d0928 100644 --- a/package.json +++ b/package.json @@ -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", diff --git a/yarn.lock b/yarn.lock index 8c4eddb96721df..1e45e6b57abe9f 100644 --- a/yarn.lock +++ b/yarn.lock @@ -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":