From 5c2813e43ebef8fd8f8b8814a066a8bfcdf5bf99 Mon Sep 17 00:00:00 2001 From: Chenyang Shi Date: Mon, 28 Jan 2019 17:47:06 +0800 Subject: [PATCH] =?UTF-8?q?add=20=E6=83=A0=E8=AA=89=E8=AF=84=E7=BA=A7?= =?UTF-8?q?=E6=9D=BF=E5=9D=97=20(#1457)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/README.md | 4 ++++ lib/router.js | 4 ++++ lib/routes/fitchratings/site.js | 33 +++++++++++++++++++++++++++++++++ 3 files changed, 41 insertions(+) create mode 100644 lib/routes/fitchratings/site.js diff --git a/docs/README.md b/docs/README.md index 51423a97f4..16c5e38dfd 100644 --- a/docs/README.md +++ b/docs/README.md @@ -2824,6 +2824,10 @@ board 和 build 可在[这里](http://api.ineal.me/tss/status)查看 +### 惠誉评级 + + + ### 移动支付网 diff --git a/lib/router.js b/lib/router.js index f0b64c60c5..ebc923bf38 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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('/fitchratings/site/:type', require('./routes/fitchratings/site')); + // 移动支付 router.get('/mpaypass/news', require('./routes/mpaypass/news')); + module.exports = router; diff --git a/lib/routes/fitchratings/site.js b/lib/routes/fitchratings/site.js new file mode 100644 index 0000000000..abeebdba56 --- /dev/null +++ b/lib/routes/fitchratings/site.js @@ -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() + ), + }; +};