fix(route): ezone.hk (#8354)

* fix(route): ezone.hk

* add index.js

* fix index.js
This commit is contained in:
Ethan Shen 2022-02-02 03:22:35 +08:00 committed by GitHub
parent 573c38933b
commit e7e2810b29
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 33 additions and 6 deletions

View File

@ -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'));

View File

@ -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(/<span>(\d{2}-\d{2}-\d{4} \d{2}:\d{2})<\/span>/)[1];
content('a[data-href]').each(function () {
content(this).after(`<img src="${content(this).attr('data-href')}">`);
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;
})

View File

@ -0,0 +1,3 @@
module.exports = {
'/:category?': ['nczitzk'],
};

13
lib/v2/ezone/radar.js Normal file
View File

@ -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?',
},
],
},
};

3
lib/v2/ezone/router.js Normal file
View File

@ -0,0 +1,3 @@
module.exports = function (router) {
router.get('/:category?', require('./index'));
};