mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat: add 证券时报网快讯 (#5965)
This commit is contained in:
@@ -160,6 +160,16 @@ pageClass: routes
|
||||
|
||||
</Route>
|
||||
|
||||
### 快讯
|
||||
|
||||
<Route author="nczitzk" example="/stcn/kuaixun" path="/stcn/kuaixun/:id?" :paramsDesc="['分类 id,见下表,默认为快讯']">
|
||||
|
||||
| 快讯 | e 公司 | 研报 | 时事 | 财经 |
|
||||
| ---- | ------ | ---- | ---- | ---- |
|
||||
| | egs | yb | ss | cj |
|
||||
|
||||
</Route>
|
||||
|
||||
## 中国人民银行
|
||||
|
||||
### 沟通交流
|
||||
|
||||
@@ -3372,6 +3372,7 @@ router.get('/allnow/column/:id', require('./routes/allnow/column'));
|
||||
// 证券时报网
|
||||
router.get('/stcn/news/:id?', require('./routes/stcn/news'));
|
||||
router.get('/stcn/data/:id?', require('./routes/stcn/data'));
|
||||
router.get('/stcn/kuaixun/:id?', require('./routes/stcn/kuaixun'));
|
||||
|
||||
// dev.to
|
||||
router.get('/dev.to/top/:period', require('./routes/dev.to/top'));
|
||||
|
||||
@@ -0,0 +1,92 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
const rootUrl = 'https://kuaixun.stcn.com';
|
||||
|
||||
const config = {
|
||||
'': {
|
||||
link: rootUrl,
|
||||
title: '快讯',
|
||||
},
|
||||
egs: {
|
||||
link: `${rootUrl}/egs/`,
|
||||
title: 'e公司',
|
||||
},
|
||||
yb: {
|
||||
link: `${rootUrl}/yb/`,
|
||||
title: '研报',
|
||||
},
|
||||
ss: {
|
||||
link: `${rootUrl}/ss/`,
|
||||
title: '时事',
|
||||
},
|
||||
cj: {
|
||||
link: `${rootUrl}/cj/`,
|
||||
title: '财经',
|
||||
},
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
ctx.params.id = ctx.params.id || '';
|
||||
|
||||
const cfg = config[ctx.params.id];
|
||||
|
||||
const currentUrl = cfg.link;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
});
|
||||
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const list = $('#news_list2 li a')
|
||||
.slice(0, 20)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
let link = item.attr('href');
|
||||
if (link.indexOf('.') === 0) {
|
||||
link = `${currentUrl}${link.replace('.', '')}`;
|
||||
}
|
||||
return {
|
||||
link,
|
||||
};
|
||||
})
|
||||
.get();
|
||||
|
||||
const items = await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const detailResponse = await got({
|
||||
method: 'get',
|
||||
url: item.link,
|
||||
});
|
||||
const content = cheerio.load(detailResponse.data);
|
||||
|
||||
let info = content('div.info');
|
||||
|
||||
if (info.html() === null) {
|
||||
info = content('h2 span');
|
||||
info.find('i').remove();
|
||||
} else {
|
||||
info.find('span').remove();
|
||||
}
|
||||
item.pubDate = new Date(info.text().split('来源')[0].trim()).toUTCString();
|
||||
|
||||
const title = content('h2');
|
||||
title.find('span').remove();
|
||||
|
||||
item.title = title.text().replace('为你推荐', '');
|
||||
item.description = content('#ctrlfscont').html() || content('.text').html();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: '证券时报网 - ' + cfg.title,
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user