Files
RSSHub/lib/routes/cna/utils.ts
T
Chih-Hsuan Yen 5ae169a201 feat(route/cna): support headlines (#21053)
* feat(route/cna): declare headlines as supported

https://www.cna.com.tw/list/headlines.aspx works the same as other
categories (aall, aipl, ...) - the same HTML structure and API

* fix(route/cna): ignore youtube links during full-text extraction

Sometimes a youtube link instead of a news page is used directly as a
news item (ex: 晚間影音新聞 during 6~7pm UTC+8 on weekdays). That
may result in HTTP 429. Full-text extraction returns nothing, anyway.

* fix(route/cna): note about where the API is from
2026-02-04 02:28:25 +08:00

29 lines
772 B
TypeScript

import { load } from 'cheerio';
import got from '@/utils/got';
export async function getFullText(item) {
if (item.link.startsWith('https://www.youtube.com/')) {
return item;
}
const detailResponse = await got({
method: 'get',
url: item.link,
});
const content = load(detailResponse.data);
content('div.SubscriptionInner').remove();
content('.gmailNews').remove();
const topImage = content('.fullPic').html();
item.description = (topImage === null ? '' : topImage) + content('.paragraph').eq(0).html();
item.category = [
...content("meta[property='article:tag']")
.toArray()
.map((e) => e.attribs.content),
content('.active > a').text(),
];
return item;
}