Files
RSSHub/lib/routes/fitchratings/site.js
T
Sukka d82847f541 style/chore(eslint): enforce new rules (#8040)
* style: prefer object shorthand syntax
* refactor: prefer Array#map over Array#forEach
* style: prefer arrow callback
* chore(eslint): update rules
* style: auto fix by eslint
2021-08-17 22:23:23 +08:00

34 lines
987 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((_, 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,
description,
link: href,
};
})
.get()
),
};
};