add 惠誉评级板块 (#1457)

This commit is contained in:
Chenyang Shi
2019-01-28 17:47:06 +08:00
committed by DIYgod
parent b595c4eb72
commit 5c2813e43e
3 changed files with 41 additions and 0 deletions

View File

@@ -2824,6 +2824,10 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看
<route name="最新政策" author="SettingDust" example="/gov/zhengce/zuixin" path="/gov/zhengce/zuixin"/> <route name="最新政策" author="SettingDust" example="/gov/zhengce/zuixin" path="/gov/zhengce/zuixin"/>
### 惠誉评级
<route name="板块信息" author="LogicJake" example="/fitchratings/site/economics" path="/fitchratings/site/:type" :paramsDesc="['板块名称在网址site后面']"/>
### 移动支付网 ### 移动支付网
<route name="新闻" author="LogicJake" example="/mpaypass/news" path="/mpaypass/news"/> <route name="新闻" author="LogicJake" example="/mpaypass/news" path="/mpaypass/news"/>

View File

@@ -1006,6 +1006,10 @@ router.get('/gov/zhengce/zuixin', require('./routes/gov/zhengce/zuixin'));
// 小黑盒 // 小黑盒
router.get('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user')); router.get('/xiaoheihe/user/:id', require('./routes/xiaoheihe/user'));
// 惠誉评级
router.get('/fitchratings/site/:type', require('./routes/fitchratings/site'));
// 移动支付 // 移动支付
router.get('/mpaypass/news', require('./routes/mpaypass/news')); router.get('/mpaypass/news', require('./routes/mpaypass/news'));
module.exports = router; module.exports = router;

View File

@@ -0,0 +1,33 @@
const axios = require('../../utils/axios');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const type = ctx.params.type;
const link = `https://www.fitchratings.com/site/${type}`;
const listData = await axios.get(link);
const $list = cheerio.load(listData.data);
ctx.state.data = {
title: `${type} - 惠誉评级`,
link,
item: await Promise.all(
$list('div.card-text-container')
.slice(0, 10)
.map(async (_, el) => {
const $el = $list(el);
const $a = $el.find('h4 a');
const href = $a.attr('href');
const title = $a.text();
const description = $el.find('div p').text();
return {
title: title,
description,
link: href,
};
})
.get()
),
};
};