diff --git a/lib/router.js b/lib/router.js index 9db46d78c..6fa6dd0d3 100644 --- a/lib/router.js +++ b/lib/router.js @@ -4031,7 +4031,7 @@ router.get('/ccg/:category?', lazyloadRouteHandler('./routes/ccg/index')); router.get('/eagle/changelog/:language?', lazyloadRouteHandler('./routes/eagle/changelog')); // ezone.hk -router.get('/ezone/:category?', lazyloadRouteHandler('./routes/ezone/index')); +// router.get('/ezone/:category?', lazyloadRouteHandler('./routes/ezone/index')); // 中国橡胶网 router.get('/cria/news/:id?', lazyloadRouteHandler('./routes/cria/news')); diff --git a/lib/routes/ezone/index.js b/lib/v2/ezone/index.js similarity index 68% rename from lib/routes/ezone/index.js rename to lib/v2/ezone/index.js index 142fe72a7..174f555cf 100644 --- a/lib/routes/ezone/index.js +++ b/lib/v2/ezone/index.js @@ -1,11 +1,13 @@ const got = require('@/utils/got'); const cheerio = require('cheerio'); +const timezone = require('@/utils/timezone'); +const { parseDate } = require('@/utils/parse-date'); module.exports = async (ctx) => { - const category = ctx.params.category || ''; + const category = ctx.params.category; const rootUrl = 'https://ezone.ulifestyle.com.hk'; - const currentUrl = `${rootUrl}/${category || '/getLastestPageRight/latestNews'}`; + const currentUrl = `${rootUrl}/${category ?? '/getLastestPageRight/latestNews'}`; const response = await got({ method: 'get', @@ -17,7 +19,6 @@ module.exports = async (ctx) => { if (category) { list = $('.item-grid') - .slice(0, 10) .map((_, item) => { item = $(item); return { @@ -29,7 +30,7 @@ module.exports = async (ctx) => { list = response.data[0][1].items.map((item) => ({ title: item.headlines.items[0].name, link: `${rootUrl}/article/${item.standardDocumentId}`, - pubDate: new Date(item.publishDateStr).toUTCString(), + pubDate: timezone(parseDate(item.publishDateStr), +8), })); } @@ -43,9 +44,16 @@ module.exports = async (ctx) => { const content = cheerio.load(detailResponse.data); const pubDate = detailResponse.data.match(/(\d{2}-\d{2}-\d{4} \d{2}:\d{2})<\/span>/)[1]; + content('a[data-href]').each(function () { + content(this).after(``); + content(this).remove(); + }); + + content('.gallery-remarks, .overlay-text-v2, .ulvideo').remove(); + item.title = content('h2').eq(0).text(); item.description = content('.content').html(); - item.pubDate = item.pubDate || new Date(`${pubDate.substr(6, 4)}-${pubDate.substr(0, 5)} ${pubDate.substr(11, 5)}`).toUTCString(); + item.pubDate = item.pubDate ?? timezone(parseDate(`${pubDate.substr(6, 4)}-${pubDate.substr(0, 5)} ${pubDate.substr(11, 5)}`), +8); return item; }) diff --git a/lib/v2/ezone/maintainer.js b/lib/v2/ezone/maintainer.js new file mode 100644 index 000000000..81eb78d73 --- /dev/null +++ b/lib/v2/ezone/maintainer.js @@ -0,0 +1,3 @@ +module.exports = { + '/:category?': ['nczitzk'], +}; diff --git a/lib/v2/ezone/radar.js b/lib/v2/ezone/radar.js new file mode 100644 index 000000000..c228665b4 --- /dev/null +++ b/lib/v2/ezone/radar.js @@ -0,0 +1,13 @@ +module.exports = { + 'ezone.hk': { + _name: 'ezone.hk', + '.': [ + { + title: '分类', + docs: 'https://docs.rsshub.app/new-media.html#ezone-hk-fen-lei', + source: ['/:category', '/'], + target: '/ezone/:category?', + }, + ], + }, +}; diff --git a/lib/v2/ezone/router.js b/lib/v2/ezone/router.js new file mode 100644 index 000000000..cf781366f --- /dev/null +++ b/lib/v2/ezone/router.js @@ -0,0 +1,3 @@ +module.exports = function (router) { + router.get('/:category?', require('./index')); +};