mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-18 13:36:36 +08:00
fix(route): fix timezone and refactor to v2 (#11806)
* fix(route): fix timezone and refactor to v2 * refactor: use api ---------
This commit is contained in:
@@ -316,7 +316,9 @@ TokenInsight 官方亦有提供 RSS,可参考 <https://api.tokeninsight.com/re
|
|||||||
|
|
||||||
## 金十数据
|
## 金十数据
|
||||||
|
|
||||||
<Route author="laampui" example="/jinshi/index" path="/jinshi/index" />
|
### 市场快讯
|
||||||
|
|
||||||
|
<Route author="laampui" example="/jin10" path="/jin10/:important?" :paramsDesc="['只看重要,任意值开启,留空关闭']" radar="1"/>
|
||||||
|
|
||||||
## 老虎社区
|
## 老虎社区
|
||||||
|
|
||||||
|
|||||||
@@ -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('/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'));
|
router.get('/gov/moa/sjzxfb', lazyloadRouteHandler('./routes/gov/moa/sjzxfb'));
|
||||||
|
|||||||
@@ -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,
|
|
||||||
};
|
|
||||||
};
|
|
||||||
57
lib/v2/jin10/index.js
Normal file
57
lib/v2/jin10/index.js
Normal file
@@ -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,
|
||||||
|
};
|
||||||
|
};
|
||||||
3
lib/v2/jin10/maintainer.js
Normal file
3
lib/v2/jin10/maintainer.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = {
|
||||||
|
'/:important?': ['laampui'],
|
||||||
|
};
|
||||||
13
lib/v2/jin10/radar.js
Normal file
13
lib/v2/jin10/radar.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
module.exports = {
|
||||||
|
'jin10.com': {
|
||||||
|
_name: '金十数据',
|
||||||
|
'.': [
|
||||||
|
{
|
||||||
|
title: '市场快讯',
|
||||||
|
docs: 'https://docs.rsshub.app/finance.html#jin-shi-shu-ju',
|
||||||
|
source: ['/'],
|
||||||
|
target: '/jin10',
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
};
|
||||||
3
lib/v2/jin10/router.js
Normal file
3
lib/v2/jin10/router.js
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
module.exports = function (router) {
|
||||||
|
router.get('/:important?', require('./index'));
|
||||||
|
};
|
||||||
2
lib/v2/jin10/templates/description.art
Normal file
2
lib/v2/jin10/templates/description.art
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
{{@ content }}
|
||||||
|
{{ if pic }}<br><img src="{{ pic }}">{{ /if }}
|
||||||
Reference in New Issue
Block a user