Add 财新周刊 (#456)

代码格式format了,但是当时报docs/install/README.md和doc/joinus/README.md两个文件没有做format,有点懵,不知道这次能不能过
This commit is contained in:
不蠢会死的某翠 2018-08-13 10:45:56 +08:00 committed by DIYgod
parent 1378073903
commit d18fb9a983
4 changed files with 80 additions and 0 deletions

View File

@ -108,6 +108,8 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
- 专栏文章
- 央视新闻
- 专题
- 财新网
- 财新周刊
- Disqus
- 评论
- Twitter

View File

@ -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
### 评论

View File

@ -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'));

59
routes/caixin/weekly.js Normal file
View File

@ -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,
})),
};
};