diff --git a/docs/finance.md b/docs/finance.md index 671c16f83f..7d54abb9fb 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -368,6 +368,12 @@ TokenInsight 官方亦有提供 RSS,可参考 +## 汇通网 + +### 7x24 小时快讯 + + + ## 金十数据 ### 市场快讯 diff --git a/docs/new-media.md b/docs/new-media.md index ec9681ec4c..f26dd78bd0 100644 --- a/docs/new-media.md +++ b/docs/new-media.md @@ -2726,12 +2726,6 @@ others = 热点新闻 + 滚动新闻 -## 汇通网 - -### 7x24 小时快讯 - - - ## 机核网 ### 分类 diff --git a/lib/router.js b/lib/router.js index ae65793935..8f82509d42 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1576,7 +1576,7 @@ router.get('/asahi/area/:id', lazyloadRouteHandler('./routes/asahi/area')); router.get('/asahi/:genre?/:category?', lazyloadRouteHandler('./routes/asahi/index')); // 7x24小时快讯 -router.get('/fx678/kx', lazyloadRouteHandler('./routes/fx678/kx')); +// router.get('/fx678/kx', lazyloadRouteHandler('./routes/fx678/kx')); // SoundCloud router.get('/soundcloud/tracks/:user', lazyloadRouteHandler('./routes/soundcloud/tracks')); diff --git a/lib/routes/fx678/kx.js b/lib/routes/fx678/kx.js deleted file mode 100644 index 95ac6f8a4f..0000000000 --- a/lib/routes/fx678/kx.js +++ /dev/null @@ -1,44 +0,0 @@ -const cheerio = require('cheerio'); -const got = require('@/utils/got'); -const url = require('url'); -const host = 'https://kx.fx678.com/'; - -module.exports = async (ctx) => { - const link = 'https://kx.fx678.com/'; - const res = await got.get(link); - const $ = cheerio.load(res.data); - // 页面新闻消息列表 - const list = $('.body_zb ul .body_zb_li .zb_word') - .find('.list_font_pic > a:first-child') - .map((i, e) => $(e).attr('href')) - .slice(0, 30) - .get(); - - const out = await Promise.all( - list.map(async (itemUrl) => { - const absoluteUrl = url.resolve(host, itemUrl); - const cache = await ctx.cache.get(absoluteUrl); - // 判断缓存 - if (cache) { - return Promise.resolve(JSON.parse(cache)); - } - const res = await got.get(absoluteUrl); - const $ = cheerio.load(res.data); - - const item = { - title: $('.article-cont h1').text(), - link: absoluteUrl, - description: $('.article-main .content').html(), - pubDate: new Date().toUTCString(), - }; - ctx.cache.set(absoluteUrl, JSON.stringify(item)); - - return item; - }) - ); - ctx.state.data = { - title: '7x24小时快讯', - link, - item: out, - }; -}; diff --git a/lib/v2/fx678/kx.js b/lib/v2/fx678/kx.js new file mode 100644 index 0000000000..db91e62542 --- /dev/null +++ b/lib/v2/fx678/kx.js @@ -0,0 +1,44 @@ +const cheerio = require('cheerio'); +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); + +module.exports = async (ctx) => { + const link = 'https://www.fx678.com/kx/'; + const res = await got.get(link); + const $ = cheerio.load(res.data); + // 页面新闻消息列表 + const list = $('.body_zb ul .body_zb_li .zb_word') + .find('.list_font_pic > a:first-child') + .map((i, e) => $(e).attr('href')) + .slice(0, 30) + .get(); + + const out = await Promise.all( + list.map((itemUrl) => + ctx.cache.tryGet(itemUrl, async () => { + const res = await got.get(itemUrl); + const $ = cheerio.load(res.data); + + const contentPart = $('.article-main .content').html().trim(); + const forewordPart = $('.article-main .foreword').html().trim(); + const datetimeString = $('.article-cont .details i').text().trim(); + const articlePubDate = timezone(parseDate(datetimeString, 'YYYY-MM-DD HH:mm:ss'), +8); + + const item = { + title: $('.article-main .foreword').text().trim().split('——').pop(), + link: itemUrl, + description: contentPart.length > 1 ? contentPart : forewordPart, + pubDate: articlePubDate, + }; + + return item; + }) + ) + ); + ctx.state.data = { + title: '7x24小时快讯', + link, + item: out, + }; +}; diff --git a/lib/v2/fx678/maintainer.js b/lib/v2/fx678/maintainer.js new file mode 100644 index 0000000000..6b6846c1da --- /dev/null +++ b/lib/v2/fx678/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/kx': ['occupy5', 'dousha'], +}; diff --git a/lib/v2/fx678/radar.js b/lib/v2/fx678/radar.js new file mode 100644 index 0000000000..36fd025bbf --- /dev/null +++ b/lib/v2/fx678/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'fx678.com': { + _name: '汇通网', + '.': [ + { + title: '7x24 小时快讯', + docs: 'https://docs.rsshub.app/finance.html#hui-tong-wang', + source: ['/kx'], + target: '/fx678/kx', + }, + ], + }, +}; diff --git a/lib/v2/fx678/router.js b/lib/v2/fx678/router.js new file mode 100644 index 0000000000..f5768b05e3 --- /dev/null +++ b/lib/v2/fx678/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/kx', require('./kx')); +};