mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-12 16:20:27 +08:00
@@ -1,31 +1,52 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const dateParser = require('@/utils/dateParser');
|
||||
|
||||
const base = 'https://institute.jpmorganchase.com';
|
||||
const url = `${base}/institute/research`;
|
||||
|
||||
const parseDetails = async (link, ctx) => {
|
||||
const fullLink = `${base}${link}`;
|
||||
return ctx.cache.tryGet(fullLink, async () => {
|
||||
const response = await got({
|
||||
url: fullLink,
|
||||
});
|
||||
const $ = cheerio.load(response.data);
|
||||
const authors = [];
|
||||
$('.author-name').each((i, elem) => {
|
||||
authors.push($(elem).text());
|
||||
});
|
||||
|
||||
return {
|
||||
category: $('.eyebrow').text(),
|
||||
author: authors.filter((e) => e).join(', '),
|
||||
title: $('title').text() + ' | ' + $('.copy-wrap p').text(),
|
||||
description: $('.jpmc-wrapper').html(),
|
||||
link: fullLink,
|
||||
pubDate: dateParser($('.date-field').text(), 'MMMM YYYY'),
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
const url = 'https://www.jpmorganchase.com';
|
||||
module.exports = async (ctx) => {
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: `${url}/corporate/institute/research.htm`,
|
||||
url,
|
||||
});
|
||||
|
||||
const title = 'All Reports';
|
||||
const $ = cheerio.load(response.data);
|
||||
|
||||
const items = $('.globalphilsect')
|
||||
.map((index, item) => {
|
||||
item = $(item);
|
||||
return {
|
||||
title: item.find('.chaseanalytics-track-link').text(),
|
||||
link: `${url}${item.find('.chaseanalytics-track-link').attr('href')}`,
|
||||
description: item.find('.lead-in + p').text(),
|
||||
pubDate: item.find('.lead-in').text(),
|
||||
};
|
||||
const items = $('.item a')
|
||||
.map(async (i, item) => {
|
||||
const link = item.attribs.href;
|
||||
return parseDetails(link, ctx);
|
||||
})
|
||||
.get();
|
||||
ctx.state.data = {
|
||||
title: `${title} - JPMorgan Chase Institute`,
|
||||
link: url,
|
||||
description: `${title} - JPMorgan Chase Institute`,
|
||||
item: items,
|
||||
item: await Promise.all(items),
|
||||
};
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user