diff --git a/README.md b/README.md index a34f1e2ef628cb..4a674fb68354c2 100644 --- a/README.md +++ b/README.md @@ -86,6 +86,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 独家号 - 极客时间 - 专栏文章 +- 央视新闻 + - 专题 - Disqus - 评论 - Twitter diff --git a/docs/README.md b/docs/README.md index a7ecb2797b1ed2..2da1a502af632c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -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 ### 评论 diff --git a/routes/cctv/category.js b/routes/cctv/category.js new file mode 100644 index 00000000000000..c75f75a204e3e6 --- /dev/null +++ b/routes/cctv/category.js @@ -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() + })), + }; +};