fix(route/apnews): Prevent fetching fulltext by default to alleviate 403 error. (#16706)

* fix(route/apnews): Prevent fetching fulltext by default to alleviate 403 error.

* .

* .
This commit is contained in:
Andvari
2024-09-15 01:31:02 +08:00
committed by GitHub
parent cba88e1aab
commit 2783eed12c
3 changed files with 4 additions and 4 deletions
+1 -1
View File
@@ -38,7 +38,7 @@ async function handler(ctx) {
const url = `${HOME_PAGE}/${rss}.rss`;
const res = await parser.parseURL(url);
const items = await Promise.all(res.items.map((item) => fetchArticle(item)));
const items = ctx.req.query('mode') === 'fulltext' ? await Promise.all(res.items.map((item) => fetchArticle(item))) : res;
return {
...res,
+1 -1
View File
@@ -82,7 +82,7 @@ async function handler(ctx) {
.sort((a, b) => (a.pubDate && b.pubDate ? b.pubDate - a.pubDate : b.lastmod - a.lastmod))
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit'), 10) : 20);
const items = await asyncPoolAll(20, list, (item) => fetchArticle(item));
const items = ctx.req.query('mode') === 'fulltext' ? await asyncPoolAll(20, list, (item) => fetchArticle(item)) : list;
return {
title: `AP News sitemap:${route}`,
+2 -2
View File
@@ -42,14 +42,14 @@ async function handler(ctx) {
const items = await Promise.all(
$(':is(.PagePromo-content, .PageListStandardE-leadPromo-info) bsp-custom-headline')
.get()
.toArray()
.slice(0, ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : Infinity)
.map((e) => ({
title: $(e).find('span.PagePromoContentIcons-text').text(),
link: $(e).find('a').attr('href'),
}))
.filter((e) => typeof e.link === 'string')
.map((item) => fetchArticle(item))
.map((item) => (ctx.req.query('mode') === 'fulltext' ? fetchArticle(item) : item))
);
return {