mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): add 中国共产党新闻网 24 小时滚动新闻 (#6931)
* feat: add 中国共产党新闻网 24 小时滚动新闻 * fix typo * fix typo * fix router.js * fix router.js
This commit is contained in:
@@ -716,6 +716,10 @@ category 对应的关键词有
|
||||
|
||||
<Route author="LogicJake" example="/people/xjpjh" path="/people/xjpjh/:keyword?/:year?" :paramsDesc="['关键词,默认不填','年份,默认 all']"/>
|
||||
|
||||
### 中国共产党新闻网 24 小时滚动新闻
|
||||
|
||||
<Route author="nczitzk" example="/people/cpc/24h" path="/people/cpc/24h"/>
|
||||
|
||||
## 人民日报社 国际金融报
|
||||
|
||||
### 栏目
|
||||
|
||||
@@ -1557,6 +1557,7 @@ router.get('/banyuetan/:name', require('./routes/banyuetan'));
|
||||
router.get('/people/opinion/:id', require('./routes/people/opinion'));
|
||||
router.get('/people/env/:id', require('./routes/people/env'));
|
||||
router.get('/people/xjpjh/:keyword?/:year?', require('./routes/people/xjpjh'));
|
||||
router.get('/people/cpc/24h', require('./routes/people/cpc/24h'));
|
||||
|
||||
// 北极星电力网
|
||||
router.get('/bjx/huanbao', require('./routes/bjx/huanbao'));
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const iconv = require('iconv-lite');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const rootUrl = 'http://cpc.people.com.cn';
|
||||
const currentUrl = `${rootUrl}/GB/87228/index.html`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: currentUrl,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
|
||||
const $ = cheerio.load(iconv.decode(response.data, 'gbk'));
|
||||
|
||||
const list = $('.fl ul li a')
|
||||
.slice(0, 10)
|
||||
.map((_, item) => {
|
||||
item = $(item);
|
||||
const link = item.attr('href');
|
||||
|
||||
return {
|
||||
title: item.text(),
|
||||
link: `${link.indexOf('http') < 0 ? rootUrl : ''}${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,
|
||||
responseType: 'buffer',
|
||||
});
|
||||
const content = cheerio.load(iconv.decode(detailResponse.data, 'gbk'));
|
||||
|
||||
item.description = content('.show_text').html();
|
||||
item.pubDate = new Date(content('meta[name="publishdate"]').attr('content')).toUTCString();
|
||||
|
||||
return item;
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
ctx.state.data = {
|
||||
title: $('title').text(),
|
||||
link: currentUrl,
|
||||
item: items,
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user