fix: route/bloomburg

unknown author name
This commit is contained in:
pseudoyu 2024-12-05 10:38:08 +08:00
parent c731e6e301
commit 9d1d6673e6
No known key found for this signature in database
1 changed files with 6 additions and 6 deletions

View File

@ -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) => {
@ -49,7 +49,7 @@ export const route: Route = {
},
],
name: 'Authors',
maintainers: ['josh'],
maintainers: ['josh', 'pseudoyu'],
handler,
};
@ -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}`,