feat(route): caijing (#11439)
This commit is contained in:
parent
f9619615c2
commit
21115de374
|
|
@ -208,6 +208,12 @@ TokenInsight 官方亦有提供 RSS,可参考 <https://api.tokeninsight.com/re
|
|||
|
||||
</Route>
|
||||
|
||||
## 财经网
|
||||
|
||||
### 滚动新闻
|
||||
|
||||
<Route author="TonyRL" example="/caijing/roll" path="/caijing/roll" rardr="1" rssbud="1"/>
|
||||
|
||||
## 财联社
|
||||
|
||||
### 电报
|
||||
|
|
|
|||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = {
|
||||
'/roll': ['TonyRL'],
|
||||
};
|
||||
|
|
@ -0,0 +1,13 @@
|
|||
module.exports = {
|
||||
'caijing.com.cn': {
|
||||
_name: '财经网',
|
||||
roll: [
|
||||
{
|
||||
title: '滚动新闻',
|
||||
docs: 'https://docs.rsshub.app/finance.html#cai-jing-wang',
|
||||
source: ['/index1.html', '/'],
|
||||
target: '/caijing/roll',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
|
@ -0,0 +1,46 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const timezone = require('@/utils/timezone');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://roll.caijing.com.cn';
|
||||
const response = await got(`${baseUrl}/ajax_lists.php`, {
|
||||
searchParams: {
|
||||
modelid: 0,
|
||||
time: Math.random(),
|
||||
},
|
||||
});
|
||||
|
||||
const list = response.data.map((item) => ({
|
||||
title: item.title,
|
||||
link: item.url.replace('http://', 'https://'),
|
||||
pubDate: timezone(parseDate(item.published, 'MM-DD HH:mm'), +8),
|
||||
category: item.cat,
|
||||
}));
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const response = await got(item.link);
|
||||
const $ = cheerio.load(response.data);
|
||||
item.author = $('.editor').text().trim() || $('#editor_baidu').text().trim().replace(/[()]/g, '');
|
||||
item.description = $('.article-content').html();
|
||||
item.category = [
|
||||
item.category,
|
||||
...$('.news_keywords span')
|
||||
.toArray()
|
||||
.map((e) => $(e).text()),
|
||||
];
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '滚动新闻-财经网',
|
||||
image: 'https://www.caijing.com.cn/favicon.ico',
|
||||
link: response.url,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
|
|
@ -0,0 +1,3 @@
|
|||
module.exports = (router) => {
|
||||
router.get('/roll', require('./roll'));
|
||||
};
|
||||
Loading…
Reference in New Issue