Skip to content

Commit

Permalink
add feed source CCTV (央视新闻) (DIYgod#152)
Browse files Browse the repository at this point in the history
  • Loading branch information
idealclover authored and DIYgod committed May 17, 2018
1 parent 6bd9045 commit f9888a6
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 独家号
- 极客时间
- 专栏文章
- 央视新闻
- 专题
- Disqus
- 评论
- Twitter
Expand Down
14 changes: 14 additions & 0 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

### 评论
Expand Down
32 changes: 32 additions & 0 deletions routes/cctv/category.js
Original file line number Diff line number Diff line change
@@ -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()
})),
};
};

0 comments on commit f9888a6

Please sign in to comment.