Files
RSSHub/lib/routes/fitchratings/site.js
T
2019-06-03 18:03:05 +08:00

34 lines
1000 B
JavaScript

const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const type = ctx.params.type;
const link = `https://www.fitchratings.com/site/${type}`;
const listData = await got.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()
),
};
};