mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-08-31 01:01:11 +08:00
feat(route): add Finology (#12993)
* feat(route): add Finology * Update radar.js * Update docs/en/finance.md * Update lib/v2/finology/bullets.js * Update lib/v2/finology/mostViewed.js * Update lib/v2/finology/bullets.js * Update docs/en/finance.md * Update lib/v2/finology/tag.js * Update lib/v2/finology/mostViewed.js * Update lib/v2/finology/tag.js * add the suggested changes * use promise.allSettled * clean up * docs: add spoiler ---------
This commit is contained in:
@@ -37,6 +37,85 @@ pageClass: routes
|
||||
|
||||
<RouteEn author="HenryQW" example="/cfd/div_gbp" path="/cfd/div_gbp" />
|
||||
|
||||
## Finology Insider
|
||||
|
||||
### Bullets
|
||||
|
||||
<RouteEn author="Rjnishant530" example="/finology/bullets" path="/finology/bullets" radar="1"/>
|
||||
|
||||
### Category
|
||||
|
||||
<RouteEn author="Rjnishant530" example="/finology/success-stories" path="/finology/:category" :paramDesc="['Refer Table below or find in URL']" radar="1">
|
||||
|
||||
::: details Category
|
||||
|
||||
| Category | Link |
|
||||
|---------------------|-----------------------|
|
||||
| **Business** | business |
|
||||
| Big Shots | entrepreneurship |
|
||||
| Startups | startups-india |
|
||||
| Brand Games | success-stories |
|
||||
| Juicy Scams | juicy-scams |
|
||||
| **Finance** | finance |
|
||||
| Macro Moves | economy |
|
||||
| News Platter | market-news |
|
||||
| Tax Club | tax |
|
||||
| Your Money | your-money |
|
||||
| **Invest** | investing |
|
||||
| Stock Market | stock-market |
|
||||
| Financial Ratios | stock-ratios |
|
||||
| Investor's Psychology | behavioral-finance |
|
||||
| Mutual Funds | mutual-fund |
|
||||
|
||||
:::
|
||||
|
||||
</RouteEn>
|
||||
|
||||
### Most Viewed
|
||||
|
||||
<RouteEn author="Rjnishant530" example="/finology/most-viewed/monthly" path="/finology/most-viewed/:time" :paramDesc="['Accepts : `alltime` or `monthly` only']" radar="1"/>
|
||||
|
||||
### Trending Topic
|
||||
|
||||
<RouteEn author="Rjnishant530" example="/finology/tag/startups" path="/tag/:topic" :paramDesc="['Refer Table below or find in URL']" radar="1">
|
||||
|
||||
::: details Topic
|
||||
|
||||
| Topic | Link |
|
||||
|---------------------|-----------------------|
|
||||
| Investment Decisions | investment-decisions |
|
||||
| Investing 101 | investing-101 |
|
||||
| Stock Markets | stock-markets |
|
||||
| business news india | business-news-india |
|
||||
| Company Analysis | company-analysis |
|
||||
| Business and brand tales | business-and-brand-tales |
|
||||
| Featured | featured |
|
||||
| Fundamental Analysis | fundamental-analysis |
|
||||
| Business Story | business-story |
|
||||
| All Biz | all-biz |
|
||||
| Stock Analysis | stock-analysis |
|
||||
| Automobile Industry | automobile-industry |
|
||||
| Indian Economy | indian-economy |
|
||||
| Govt's Words | govt%27s-words |
|
||||
| Behavioral Finance | behavioral-finance |
|
||||
| Global Economy | global-economy |
|
||||
| Startups | startups |
|
||||
| GST | gst |
|
||||
| Product Review | product-review |
|
||||
| My Pocket | my-pocket |
|
||||
| Business Games | business-games |
|
||||
| Business Models | business-models |
|
||||
| Indian Indices | indian-indices |
|
||||
| Banking System | banking-system |
|
||||
| Debt | debt |
|
||||
| World News | world-news |
|
||||
| Technology | technology |
|
||||
| Regulatory Bodies | regulatory-bodies |
|
||||
|
||||
:::
|
||||
|
||||
</RouteEn>
|
||||
|
||||
## finviz
|
||||
|
||||
### News
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://insider.finology.in/bullets';
|
||||
|
||||
const { data: response } = await got(baseUrl);
|
||||
const $ = cheerio.load(response);
|
||||
|
||||
const listItems = $('ul.timeline li.m-pb2')
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const time = item.find('div.timeline-info span').text().split(', ')[1];
|
||||
const a = item.find('a.bullet_share_div');
|
||||
const description = item.find('div.bullet-desc').html();
|
||||
return {
|
||||
title: a.attr('data-bullettitle'),
|
||||
link: a.attr('data-bulleturl'),
|
||||
pubDate: parseDate(time, 'DD MMMM'),
|
||||
description,
|
||||
};
|
||||
});
|
||||
|
||||
ctx.state.data = {
|
||||
title: 'Finology Insider Bullets',
|
||||
link: baseUrl,
|
||||
item: listItems,
|
||||
description: 'Your daily dose of crisp, spicy financial news in 80 words.',
|
||||
logo: 'https://assets.finology.in/insider/images/favicon/apple-touch-icon.png',
|
||||
icon: 'https://assets.finology.in/insider/images/favicon/favicon-32x32.png',
|
||||
language: 'en-us',
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = {
|
||||
'/bullets': ['Rjnishant530'],
|
||||
'/:category': ['Rjnishant530'],
|
||||
'/most-viewed/:time': ['Rjnishant530'],
|
||||
'/tag/:topic': ['Rjnishant530'],
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
const logger = require('@/utils/logger');
|
||||
const { getItems } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const baseUrl = 'https://insider.finology.in/most-viewed';
|
||||
let selector;
|
||||
let title;
|
||||
const { time } = ctx.params;
|
||||
if (time === 'alltime') {
|
||||
title = 'All Time';
|
||||
selector = 'div.w100.pb2.bg-color.flex.flex-col.align-center.pt6 div.w23.br0625.shadow.position-r.bg-white.m-w100.card.t-w45';
|
||||
} else if (time === 'monthly') {
|
||||
title = 'Monthly';
|
||||
selector = 'div.w100.pb2.bg-color.flex.flex-col.align-center:not(.pt6) div.w23.br0625.shadow.position-r.bg-white.m-w100.card.t-w45';
|
||||
} else {
|
||||
logger.error('Invalid Time');
|
||||
}
|
||||
|
||||
const extra = {
|
||||
date: false,
|
||||
selector,
|
||||
};
|
||||
const listItems = await getItems(ctx, baseUrl, extra);
|
||||
ctx.state.data = {
|
||||
title: `Most Viewed ${title} - Finology Insider`,
|
||||
link: baseUrl,
|
||||
item: listItems,
|
||||
description: "A lot of Insider's readers seem to be reading these articles. Take a look and find out why.",
|
||||
logo: 'https://assets.finology.in/insider/images/favicon/apple-touch-icon.png',
|
||||
icon: 'https://assets.finology.in/insider/images/favicon/favicon-32x32.png',
|
||||
language: 'en-us',
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,31 @@
|
||||
module.exports = {
|
||||
'finology.in': {
|
||||
_name: 'Finology Insider',
|
||||
insider: [
|
||||
{
|
||||
title: 'Bullets',
|
||||
docs: 'https://docs.rsshub.app/en/finance.html#finology-insider',
|
||||
source: ['/bullets'],
|
||||
target: '/finology/bullets',
|
||||
},
|
||||
{
|
||||
title: 'Category',
|
||||
docs: 'https://docs.rsshub.app/en/finance.html#finology-insider',
|
||||
source: '/:category',
|
||||
target: '/finology/:category',
|
||||
},
|
||||
{
|
||||
title: 'Most Viewed',
|
||||
docs: 'https://docs.rsshub.app/en/finance.html#finology-insider',
|
||||
source: '/most-viewed',
|
||||
target: '/finology/most-viewed/monthly',
|
||||
},
|
||||
{
|
||||
title: 'Trending Topic',
|
||||
docs: 'https://docs.rsshub.app/en/finance.html#finology-insider',
|
||||
source: ['/tag/:topic'],
|
||||
target: '/finology/tag/:topic',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
@@ -0,0 +1,6 @@
|
||||
module.exports = (router) => {
|
||||
router.get('/bullets', require('./bullets'));
|
||||
router.get('/:category', require('./tag'));
|
||||
router.get('/most-viewed/:time', require('./mostViewed'));
|
||||
router.get('/tag/:topic', require('./tag'));
|
||||
};
|
||||
@@ -0,0 +1,33 @@
|
||||
const logger = require('@/utils/logger');
|
||||
const { getItems } = require('./utils');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { topic, category } = ctx.params;
|
||||
const baseUrl = 'https://insider.finology.in';
|
||||
let route;
|
||||
let number;
|
||||
if (topic) {
|
||||
route = `/tag/${topic}`;
|
||||
number = 2;
|
||||
} else if (category) {
|
||||
route = `/${category}`;
|
||||
number = 6;
|
||||
} else {
|
||||
logger.error('Invalid URL');
|
||||
}
|
||||
const extra = {
|
||||
date: true,
|
||||
topicName: '',
|
||||
selector: `div.w100.pb${number}.bg-color.flex.flex-col.align-center div.w23.br0625.shadow.position-r.bg-white.m-w100.card.t-w45`,
|
||||
};
|
||||
const listItems = await getItems(ctx, `${baseUrl}${route}`, extra);
|
||||
ctx.state.data = {
|
||||
title: `${extra.topicName} - Finology Insider`,
|
||||
link: `${baseUrl}${route}`,
|
||||
item: listItems,
|
||||
description: number === 2 ? `Everything that Insider has to offer about ${extra.topicName} for you to read and learn.` : `Articles for your research and knowledge under ${extra.topicName}`,
|
||||
logo: 'https://assets.finology.in/insider/images/favicon/apple-touch-icon.png',
|
||||
icon: 'https://assets.finology.in/insider/images/favicon/favicon-32x32.png',
|
||||
language: 'en-us',
|
||||
};
|
||||
};
|
||||
@@ -0,0 +1,58 @@
|
||||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
|
||||
const getItems = async (ctx, url, extra) => {
|
||||
const mainUrl = 'https://insider.finology.in';
|
||||
const { data: response } = await got(url);
|
||||
const $ = cheerio.load(response);
|
||||
const listItems = $(extra.selector)
|
||||
.toArray()
|
||||
.map((item) => {
|
||||
item = $(item);
|
||||
const title = item.find('p.text-m-height').text();
|
||||
const link = item.find('a').attr('href');
|
||||
const pubDate = extra.date ? parseDate(item.find('div.text-light p').first().text(), 'DD-MMM-YYYY') : '';
|
||||
const itunes_item_image = item.find('img').attr('src');
|
||||
const category = item.find('p.pt025').text();
|
||||
return {
|
||||
title,
|
||||
link: `${mainUrl}${link}`,
|
||||
pubDate,
|
||||
itunes_item_image,
|
||||
category,
|
||||
};
|
||||
});
|
||||
|
||||
const items = (
|
||||
await Promise.allSettled(
|
||||
listItems.map((item) =>
|
||||
ctx.cache.tryGet(item.link, async () => {
|
||||
const { data: response } = await got(item.link);
|
||||
const $ = cheerio.load(response);
|
||||
const div = $('div.w60.flex.flex-wrap-badge');
|
||||
item.author = div.find('div a p').text();
|
||||
item.updated = div.find('p:contains("Updated on") span').text();
|
||||
item.description = $('div#main-wrapper div#insiderhead')
|
||||
.find('div.flex.flex-col.w100.align-center')
|
||||
.children('div.m-position-r')
|
||||
.remove()
|
||||
.end()
|
||||
.find('a[href="https://quest.finology.in/"]')
|
||||
.remove()
|
||||
.end()
|
||||
.find('div.blur-wall-wrap')
|
||||
.remove()
|
||||
.end()
|
||||
.html();
|
||||
return item;
|
||||
})
|
||||
)
|
||||
)
|
||||
).map((v, index) => (v.status === 'fulfilled' ? v.value : { ...listItems[index], description: `Website did not load within Timeout Limits. <a href="${listItems[index].link}">Check with Website if the page is slow</a>` }));
|
||||
extra.topicName = $('h1.font-heading.fs1875')?.text();
|
||||
|
||||
return items;
|
||||
};
|
||||
|
||||
module.exports = { getItems };
|
||||
Reference in New Issue
Block a user