diff --git a/docs/finance.md b/docs/finance.md index 578e1f5d1..df2c7ba69 100644 --- a/docs/finance.md +++ b/docs/finance.md @@ -316,7 +316,9 @@ TokenInsight 官方亦有提供 RSS,可参考 +### 市场快讯 + + ## 老虎社区 diff --git a/lib/router.js b/lib/router.js index 0ed526351..7c7ffb3ec 100644 --- a/lib/router.js +++ b/lib/router.js @@ -1798,7 +1798,7 @@ router.get('/im2maker/:channel?', lazyloadRouteHandler('./routes/im2maker/index' router.get('/cninfo/announcement/:column/:code/:orgId/:category?/:search?', lazyloadRouteHandler('./routes/cninfo/announcement')); // 金十数据 -router.get('/jinshi/index', lazyloadRouteHandler('./routes/jinshi/index')); +// router.get('/jinshi/index', lazyloadRouteHandler('./routes/jinshi/index')); // 中华人民共和国农业农村部 router.get('/gov/moa/sjzxfb', lazyloadRouteHandler('./routes/gov/moa/sjzxfb')); diff --git a/lib/routes/jinshi/index.js b/lib/routes/jinshi/index.js deleted file mode 100644 index 7cda66476..000000000 --- a/lib/routes/jinshi/index.js +++ /dev/null @@ -1,35 +0,0 @@ -const got = require('@/utils/got'); -const cheerio = require('cheerio'); - -module.exports = async (ctx) => { - const response = await got.get('https://www.jin10.com/'); - const $ = cheerio.load(response.data); - let date; - - const item = $('#jin_flash_list .jin-flash-item-container') - .filter((index, ele) => !!$('.right-content div:first-of-type', ele).text() && !$('.is-vip', ele).length) - .map((index, ele) => { - const year = new Date().getFullYear(); - const time = $('.item-time', ele).text(); - const title = $('.right-content div:first-of-type', ele).text(); - const link = $('.right-content .flash-item-share_right a', ele).attr('href'); - - date = $('.jin-flash-date-line span', ele).text().trim() ? $('.jin-flash-date-line span', ele).text().trim() : date; - - const datetime = year + '-' + date.replace('月', '-').replace('日', ` ${time}`); - - return { - title, - link, - description: datetime, - pubDate: new Date(datetime), - }; - }) - .get(); - - ctx.state.data = { - title: '金十数据', - link: 'https://www.jin10.com/', - item, - }; -}; diff --git a/lib/v2/jin10/index.js b/lib/v2/jin10/index.js new file mode 100644 index 000000000..d997f6482 --- /dev/null +++ b/lib/v2/jin10/index.js @@ -0,0 +1,57 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); +const timezone = require('@/utils/timezone'); +const { art } = require('@/utils/render'); +const path = require('path'); +const config = require('@/config').value; + +module.exports = async (ctx) => { + const { important = false } = ctx.params; + const data = await ctx.cache.tryGet( + 'jin10:index', + async () => { + const { data: response } = await got('https://flash-api.jin10.com/get_flash_list', { + headers: { + 'x-app-id': 'bVBF4FyRTn5NJF5n', + 'x-version': '1.0.0', + }, + searchParams: { + channel: '-8200', + vip: '1', + }, + }); + return response.data; + }, + config.cache.routeExpire, + false + ); + + const item = data.map((item) => { + const titleMatch = item.data.content.match(/【(.*?)】/); + let title; + let content = item.data.content; + if (titleMatch) { + title = titleMatch[1]; + content = content.replace(titleMatch[0], ''); + } else { + title = item.data.content; + } + + return { + title, + description: art(path.join(__dirname, 'templates/description.art'), { + content, + pic: item.data.pic, + }), + pubDate: timezone(parseDate(item.time), 8), + guid: `jin10:index:${item.id}`, + important: item.important, + }; + }); + + ctx.state.data = { + title: '金十数据', + link: 'https://www.jin10.com/', + item: important ? item.filter((item) => item.important) : item, + }; +}; diff --git a/lib/v2/jin10/maintainer.js b/lib/v2/jin10/maintainer.js new file mode 100644 index 000000000..b58660764 --- /dev/null +++ b/lib/v2/jin10/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:important?': ['laampui'], +}; diff --git a/lib/v2/jin10/radar.js b/lib/v2/jin10/radar.js new file mode 100644 index 000000000..b01aff3f7 --- /dev/null +++ b/lib/v2/jin10/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'jin10.com': { + _name: '金十数据', + '.': [ + { + title: '市场快讯', + docs: 'https://docs.rsshub.app/finance.html#jin-shi-shu-ju', + source: ['/'], + target: '/jin10', + }, + ], + }, +}; diff --git a/lib/v2/jin10/router.js b/lib/v2/jin10/router.js new file mode 100644 index 000000000..450c0f751 --- /dev/null +++ b/lib/v2/jin10/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:important?', require('./index')); +}; diff --git a/lib/v2/jin10/templates/description.art b/lib/v2/jin10/templates/description.art new file mode 100644 index 000000000..c9b454388 --- /dev/null +++ b/lib/v2/jin10/templates/description.art @@ -0,0 +1,2 @@ +{{@ content }} +{{ if pic }}
{{ /if }}