feat: add route for 新闻联播文字版 (#3582)

This commit is contained in:
Luyu Huang
2019-12-17 11:49:53 +08:00
committed by DIYgod
parent b03c03fab8
commit bb7192911b
4 changed files with 54 additions and 0 deletions

View File

@@ -926,4 +926,16 @@
}, },
], ],
}, },
'govopendata.com': {
_name: '新闻联播文字版',
cn: [
{
title: '新闻联播文字版',
docs: 'https://docs.rsshub.app/traditional-media.html#xin-wen-lian-bo-wen-zi-ban',
source: '/xinwenlianbo',
target: '/xinwenlianbo/index',
},
],
},
}); });

View File

@@ -359,6 +359,12 @@ category 对应的关键词有
<Route author="xyqfer" example="/sina/rollnews" path="/sina/rollnews" /> <Route author="xyqfer" example="/sina/rollnews" path="/sina/rollnews" />
## 新闻联播文字版
### 新闻联播文字版
<Route author="luyuhuang" example="/xinwenlianbo/index" path="/xinwenlianbo/index" radar="1"/>
## 央视新闻 ## 央视新闻
### 新闻联播 ### 新闻联播

View File

@@ -2035,4 +2035,7 @@ router.get('/mastodon/timeline/:site/:only_media?', require('./routes/mastodon/t
// Kernel Aliyun // Kernel Aliyun
router.get('/aliyun-kernel/index', require('./routes/aliyun-kernel/index')); router.get('/aliyun-kernel/index', require('./routes/aliyun-kernel/index'));
// xinwenlianbo
router.get('/xinwenlianbo/index', require('./routes/xinwenlianbo/index'));
module.exports = router; module.exports = router;

View File

@@ -0,0 +1,33 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
const root_url = 'https://cn.govopendata.com/xinwenlianbo/';
module.exports = async (ctx) => {
const response = await got({
method: 'get',
url: root_url,
});
const $ = cheerio.load(response.data);
const list = $('table.table.table-bordered > tbody > tr > td')
.slice(0, 10)
.map((_, item) => {
item = $(item);
const a = item.find('a');
const title = a.text();
return {
title: title,
link: a.attr('href'),
description: item.find('ul').html(),
pubDate: new Date(/(\d{4}-\d+-\d+)/.exec(title)[1] + ' 19:00 GMT+8').toUTCString(),
};
})
.get();
ctx.state.data = {
title: '新闻联播 文字版',
link: root_url,
item: list,
};
};