From 9d1d6673e61c39d7c2e600ee632364f7848ad124 Mon Sep 17 00:00:00 2001 From: pseudoyu Date: Thu, 5 Dec 2024 10:38:08 +0800 Subject: [PATCH] fix: route/bloomburg unknown author name --- lib/routes/bloomberg/authors.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/lib/routes/bloomberg/authors.ts b/lib/routes/bloomberg/authors.ts index 6ce5d2689b15ca..83b6eed8586aa7 100644 --- a/lib/routes/bloomberg/authors.ts +++ b/lib/routes/bloomberg/authors.ts @@ -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}`,