diff --git a/README.md b/README.md index 4ac5c8051..95a0b8f06 100644 --- a/README.md +++ b/README.md @@ -108,6 +108,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇 - 专栏文章 - 央视新闻 - 专题 +- 财新网 + - 财新周刊 - Disqus - 评论 - Twitter diff --git a/docs/README.md b/docs/README.md index 62a4762dd..a19ce04ab 100644 --- a/docs/README.md +++ b/docs/README.md @@ -945,6 +945,22 @@ key: 产品密钥 | ----- | ----- | ----- | ---- | ------- | ---- | ---- | | china | world | video | tech | society | law | ent | +## 财新网 + +> 网站部分内容需要付费订阅,RSS 仅做更新提醒,不含付费内容。 + +### 财新周刊 + +举例: [https://rsshub.app/caixin/weekly/coverstory](https://rsshub.app/caixin/weekly/coverstory) + +路由: `/caixin/weekly/:category` + +参数:category,分类名 + +| 封面报道 | 开卷 | 社论 | 时事 | 编辑寄语 | 经济 | 金融 | 商业 | 环境与科技 | 民生 | 副刊 | +| ---------- | ----- | --------- | --------------- | ----------- | ------- | ------- | -------- | ---------------------- | ------- | ------ | +| coverstory | first | editorial | current_affairs | editor_desk | economy | finance | business | environment_technology | cwcivil | column | + ## Disqus ### 评论 diff --git a/router.js b/router.js index a94510a47..898616edc 100755 --- a/router.js +++ b/router.js @@ -332,6 +332,9 @@ router.get('/reimu/tag/:tag', require('./routes/reimu/tag')); // 央视新闻 router.get('/cctv/:category', require('./routes/cctv/category')); +// 财新 +router.get('/caixin/weekly/:category', require('./routes/caixin/weekly')); + // 草榴社区 router.get('/t66y/:id', require('./routes/t66y/index')); diff --git a/routes/caixin/weekly.js b/routes/caixin/weekly.js new file mode 100644 index 000000000..cf599b26a --- /dev/null +++ b/routes/caixin/weekly.js @@ -0,0 +1,59 @@ +const axios = require('../../utils/axios'); +const cheerio = require('cheerio'); +const config = require('../../config'); + +module.exports = async (ctx) => { + const category = ctx.params.category; + const url = `http://weekly.caixin.com/${category}`; + + const response = await axios({ + method: 'get', + url: url, + headers: { + 'User-Agent': config.ua, + Referer: url, + }, + }); + + const $ = cheerio.load(response.data); + const list = $('.stitXtuwen_list dl dd'); + const items = []; + + for (let i = 0; i < list.length; i++) { + const item = { + title: $(list[i]) + .children('h4') + .children() + .text(), + desc: $(list[i]) + .children('p') + .text(), + pubDate: new Date( + $(list[i]) + .children('span') + .text() + .replace('年', '-') + .replace('月', '-') + .replace('日', '') + ).toUTCString(), + url: $(list[i]) + .children('h4') + .children() + .attr('href'), + }; + items.push(item); + } + + ctx.state.data = { + title: '财新周刊', + link: url, + description: '财新周刊 - 提供财经新闻及资讯服务', + item: items.map((item) => ({ + title: item.title, + description: item.desc, + guid: item.title, + link: item.url, + pubDate: item.pubDate, + })), + }; +};