From 25d9917d5f65f6c08e598351e7dcfcd3b4af5d0a Mon Sep 17 00:00:00 2001 From: lidashuang Date: Wed, 29 Nov 2023 21:41:32 +0800 Subject: [PATCH] fix(egsea): pubDate Invalid Date (#13914) * fix(egsea): pubDate Invalid Date the https://rsshub.app/egsea/flash response error pubDate Invalid Date * refactor: migrate to v2 --------- --- lib/router.js | 2 +- lib/routes/egsea/flash.js | 40 -------------------------------------- lib/v2/egsea/flash.js | 30 ++++++++++++++++++++++++++++ lib/v2/egsea/maintainer.js | 3 +++ lib/v2/egsea/radar.js | 13 +++++++++++++ lib/v2/egsea/router.js | 3 +++ 6 files changed, 50 insertions(+), 41 deletions(-) delete mode 100644 lib/routes/egsea/flash.js create mode 100644 lib/v2/egsea/flash.js create mode 100644 lib/v2/egsea/maintainer.js create mode 100644 lib/v2/egsea/radar.js create mode 100644 lib/v2/egsea/router.js diff --git a/lib/router.js b/lib/router.js index 58e8410d2..562aba65c 100644 --- a/lib/router.js +++ b/lib/router.js @@ -171,7 +171,7 @@ router.get('/wikipedia/mainland', lazyloadRouteHandler('./routes/wikipedia/mainl router.get('/un/scveto', lazyloadRouteHandler('./routes/un/scveto')); // e 公司 -router.get('/egsea/flash', lazyloadRouteHandler('./routes/egsea/flash')); +// router.get('/egsea/flash', lazyloadRouteHandler('./routes/egsea/flash')); // 选股宝 router.get('/xuangubao/subject/:subject_id', lazyloadRouteHandler('./routes/xuangubao/subject')); diff --git a/lib/routes/egsea/flash.js b/lib/routes/egsea/flash.js deleted file mode 100644 index 2124728a3..000000000 --- a/lib/routes/egsea/flash.js +++ /dev/null @@ -1,40 +0,0 @@ -const got = require('@/utils/got'); - -module.exports = async (ctx) => { - const response = await got({ - method: 'get', - url: `https://www.egsea.com/news/flash-list?per-page=30`, - headers: { - Referer: `https://www..com/news/flash`, - }, - }); - - const newsflashes = response.data.data; - - let newsflashesList = []; - for (let i = 0; i < newsflashes.length; i++) { - newsflashesList = newsflashesList.concat(newsflashes[i]); - } - - const out = newsflashesList.map((item) => { - const pubDate = item.pageTime; - const link = 'https://www.egsea.com' + item.url; - const title = item.title; - const description = item.content; - - const single = { - title, - link, - pubDate, - description, - }; - - return single; - }); - - ctx.state.data = { - title: `快讯 - e 公司`, - link: `https://www.egsea.com/news/flash`, - item: out, - }; -}; diff --git a/lib/v2/egsea/flash.js b/lib/v2/egsea/flash.js new file mode 100644 index 000000000..0e7960279 --- /dev/null +++ b/lib/v2/egsea/flash.js @@ -0,0 +1,30 @@ +const got = require('@/utils/got'); +const { parseDate } = require('@/utils/parse-date'); + +module.exports = async (ctx) => { + const response = await got({ + method: 'get', + url: 'https://www.egsea.com/news/flash-list?per-page=30', + }); + + const out = response.data.data.map((item) => { + const pubDate = parseDate(item.pageTime, 'X'); + const link = 'https://www.egsea.com' + item.url; + const title = item.title; + const description = item.content; + + return { + title, + link, + pubDate, + description, + category: item.tags.map((tag) => tag.name), + }; + }); + + ctx.state.data = { + title: '快讯 - e 公司', + link: 'https://www.egsea.com/news/flash', + item: out, + }; +}; diff --git a/lib/v2/egsea/maintainer.js b/lib/v2/egsea/maintainer.js new file mode 100644 index 000000000..7a7bca3ef --- /dev/null +++ b/lib/v2/egsea/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/flash': ['hillerliao'], +}; diff --git a/lib/v2/egsea/radar.js b/lib/v2/egsea/radar.js new file mode 100644 index 000000000..c06cfbd69 --- /dev/null +++ b/lib/v2/egsea/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'egsea.com': { + _name: 'e 公司', + '.': [ + { + title: '快讯', + docs: 'https://docs.rsshub.app/routes/new-media#e-gong-si', + source: ['/news/flash'], + target: '/egsea/flash', + }, + ], + }, +}; diff --git a/lib/v2/egsea/router.js b/lib/v2/egsea/router.js new file mode 100644 index 000000000..6676deadd --- /dev/null +++ b/lib/v2/egsea/router.js @@ -0,0 +1,3 @@ +module.exports = (router) => { + router.get('/flash', require('./flash')); +};