forked from chengxuanying/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add feed source CCTV (央视新闻) (DIYgod#152)
- Loading branch information
1 parent
6bd9045
commit f9888a6
Showing
3 changed files
with
48 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -86,6 +86,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 | |
- 独家号 | ||
- 极客时间 | ||
- 专栏文章 | ||
- 央视新闻 | ||
- 专题 | ||
- Disqus | ||
- 评论 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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() | ||
})), | ||
}; | ||
}; |