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:
parent
cba88e1aab
commit
2783eed12c
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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}`,
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Reference in New Issue