mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-13 16:49:31 +08:00
@@ -1,31 +1,52 @@
|
|||||||
const got = require('@/utils/got');
|
const got = require('@/utils/got');
|
||||||
const cheerio = require('cheerio');
|
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) => {
|
module.exports = async (ctx) => {
|
||||||
const response = await got({
|
const response = await got({
|
||||||
method: 'get',
|
method: 'get',
|
||||||
url: `${url}/corporate/institute/research.htm`,
|
url,
|
||||||
});
|
});
|
||||||
|
|
||||||
const title = 'All Reports';
|
const title = 'All Reports';
|
||||||
const $ = cheerio.load(response.data);
|
const $ = cheerio.load(response.data);
|
||||||
|
|
||||||
const items = $('.globalphilsect')
|
const items = $('.item a')
|
||||||
.map((index, item) => {
|
.map(async (i, item) => {
|
||||||
item = $(item);
|
const link = item.attribs.href;
|
||||||
return {
|
return parseDetails(link, ctx);
|
||||||
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(),
|
|
||||||
};
|
|
||||||
})
|
})
|
||||||
.get();
|
.get();
|
||||||
ctx.state.data = {
|
ctx.state.data = {
|
||||||
title: `${title} - JPMorgan Chase Institute`,
|
title: `${title} - JPMorgan Chase Institute`,
|
||||||
link: url,
|
link: url,
|
||||||
description: `${title} - JPMorgan Chase Institute`,
|
description: `${title} - JPMorgan Chase Institute`,
|
||||||
item: items,
|
item: await Promise.all(items),
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user