mirror of
https://github.com/DIYgod/RSSHub.git
synced 2026-09-24 23:12:34 +08:00
feat(route): bloomberg by author (#11615)
* Extract asyncPoolAll to utils * Add bloomberg news by author route * docs: add docs and radar
This commit is contained in:
@@ -27,6 +27,10 @@ pageClass: routes
|
||||
|
||||
</RouteEn>
|
||||
|
||||
### Authors
|
||||
|
||||
<RouteEn author="josh" example="/bloomberg/authors/ARbTQlRLRjE/matthew-s-levine" path="/bloomberg/authors/:id/:slug" :paramsDesc="['Author ID, can be found in URL', 'Author Slug, can be found in URL']" anticrawler="1" radar="1"/>
|
||||
|
||||
## CFD
|
||||
|
||||
### Indices Dividend Adjustment (GBP)
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
const { asyncPoolAll, parseArticle } = require('./utils');
|
||||
const parser = require('@/utils/rss-parser');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { id, slug } = ctx.params;
|
||||
const feed = await parser.parseURL(`https://www.bloomberg.com/authors/${id}/${slug}.rss`);
|
||||
const item = await asyncPoolAll(1, feed.items, (item) => parseArticle(item, ctx));
|
||||
ctx.state.data = {
|
||||
title: `Bloomberg - ${feed.title.split(' - ', 2)[0]}`,
|
||||
link: feed.link,
|
||||
language: feed.language,
|
||||
item,
|
||||
};
|
||||
};
|
||||
@@ -1,5 +1,4 @@
|
||||
const { rootUrl, parseNewsList, parseArticle } = require('./utils');
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
const { rootUrl, asyncPoolAll, parseNewsList, parseArticle } = require('./utils');
|
||||
const site_title_mapping = {
|
||||
'/': 'News',
|
||||
bpol: 'Politics',
|
||||
@@ -15,14 +14,6 @@ const site_title_mapping = {
|
||||
citylab: 'CityLab',
|
||||
};
|
||||
|
||||
const asyncPoolAll = async (...args) => {
|
||||
const results = [];
|
||||
for await (const result of asyncPool(...args)) {
|
||||
results.push(result);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const { site } = ctx.params;
|
||||
const currentUrl = site ? `${rootUrl}/${site}/sitemap_news.xml` : `${rootUrl}/sitemap_news.xml`;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
module.exports = {
|
||||
'/authors/:id/:slug': ['josh'],
|
||||
'/:site?': ['bigfei'],
|
||||
'/': ['bigfei'],
|
||||
};
|
||||
|
||||
@@ -1,13 +1,19 @@
|
||||
module.exports = {
|
||||
'bloomberg.com': {
|
||||
_name: 'bloomberg',
|
||||
_name: 'Bloomberg',
|
||||
www: [
|
||||
{
|
||||
title: 'Bloomberg',
|
||||
docs: 'https://docs.rsshub.app/finance.html##bloomberg-news',
|
||||
title: 'News',
|
||||
docs: 'https://docs.rsshub.app/finance.html#bloomberg-news',
|
||||
source: ['/:site', '/'],
|
||||
target: '/bloomberg/:site?',
|
||||
},
|
||||
{
|
||||
title: 'Authors',
|
||||
docs: 'https://docs.rsshub.app/finance.html#bloomberg',
|
||||
source: ['/*/authors/:id/:slug', '/authors/:id/:slug'],
|
||||
target: '/bloomberg/authors/:id/:slug',
|
||||
},
|
||||
],
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
module.exports = function (router) {
|
||||
router.get('/authors/:id/:slug', require('./authors'));
|
||||
router.get('/:site', require('./index'));
|
||||
router.get('/', require('./index'));
|
||||
};
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
const cheerio = require('cheerio');
|
||||
const path = require('path');
|
||||
const asyncPool = require('tiny-async-pool');
|
||||
|
||||
const { parseDate } = require('@/utils/parse-date');
|
||||
const got = require('@/utils/got');
|
||||
@@ -388,8 +389,17 @@ const processBody = async (body_html, story_json) => {
|
||||
return $.html();
|
||||
};
|
||||
|
||||
const asyncPoolAll = async (...args) => {
|
||||
const results = [];
|
||||
for await (const result of asyncPool(...args)) {
|
||||
results.push(result);
|
||||
}
|
||||
return results;
|
||||
};
|
||||
|
||||
module.exports = {
|
||||
rootUrl,
|
||||
asyncPoolAll,
|
||||
parseNewsList,
|
||||
parseArticle,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user