Skip to content

Commit

Permalink
fix: route/bloomburg
Browse files Browse the repository at this point in the history
unknown author name
  • Loading branch information
pseudoyu committed Dec 5, 2024
1 parent c731e6e commit 9d1d667
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions lib/routes/bloomberg/authors.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
import { Route, ViewType } from '@/types';
import { load } from 'cheerio';
import got from '@/utils/got';
import ofetch from '@/utils/ofetch';
import rssParser from '@/utils/rss-parser';
import { asyncPoolAll, parseArticle } from './utils';

const parseAuthorNewsList = async (slug) => {
const baseURL = `https://www.bloomberg.com/authors/${slug}`;
const apiUrl = `https://www.bloomberg.com/lineup/api/lazy_load_author_stories?slug=${slug}&authorType=default&page=1`;
const resp = await got(apiUrl);
const resp = await ofetch(apiUrl);
// Likely rate limited
if (!resp.data.html) {
if (!resp.html) {
return [];
}
const $ = load(resp.data.html);
const $ = load(resp.html);
const articles = $('article.story-list-story');
return articles
.map((index, item) => {
Expand Down Expand Up @@ -49,7 +49,7 @@ export const route: Route = {
},
],
name: 'Authors',
maintainers: ['josh'],
maintainers: ['josh', 'pseudoyu'],
handler,
};

Expand All @@ -67,7 +67,7 @@ async function handler(ctx) {
}

const item = await asyncPoolAll(1, list, (item) => parseArticle(item));
const authorName = item.find((i) => i.author)?.author ?? 'Unknown';
const authorName = item.find((i) => i.author)?.author ?? slug;

return {
title: `Bloomberg - ${authorName}`,
Expand Down

0 comments on commit 9d1d667

Please sign in to comment.