add feed source CCTV (央视新闻) (#152)

This commit is contained in:
不蠢会死的某翠
2018-05-17 10:44:24 +08:00
committed by DIYgod
parent 6bd9045e7b
commit f9888a6fb7
3 changed files with 48 additions and 0 deletions
+2
View File
@@ -86,6 +86,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 独家号
- 极客时间
- 专栏文章
- 央视新闻
- 专题
- Disqus
- 评论
- Twitter
+14
View File
@@ -651,6 +651,20 @@ key: 产品密钥
参数: cid,专栏 id,可从[全部专栏](https://time.geekbang.org/paid-content)进入专栏介绍页,在 URL 中找到
## 央视新闻
### 专题
举例: [https://rsshub.app/cctv/world](https://rsshub.app/cctv/world)
路由: `/cctv/:category`
参数:category,分类名
| 国内 | 国际 | 视频 | 科技 | 社会 | 法律 | 娱乐 |
| ----- | ----- | ----- | ---- | ------- | ---- | ---- |
| china | world | video | tech | society | law | ent |
## Disqus
### 评论
+32
View File
@@ -0,0 +1,32 @@
const axios = require('axios');
const config = require('../../config');
module.exports = async (ctx) => {
const category = ctx.params.category;
const url = `http://news.cctv.com/${category}/data/index.json`
const response = await axios({
method: 'get',
url: url,
headers: {
'User-Agent': config.ua,
'Referer': url,
}
});
const data = response.data;
const list = data.rollData;
const article_item = [];
ctx.state.data = {
title: `央视新闻 ${category}`,
link: `http://news.cctv.com/${category}`,
description: `央视新闻 ${category}`,
item: list.map((item) => ({
title: item.title,
description: item.description,
link: item.url,
pubDate: new Date(item.dateTime).toUTCString()
})),
};
};