Files
RSSHub/lib/routes/leiphone/utils.ts
T
Tony 6dba3aa744 style: fix eslint issues (#20862)
* style: fix n/no-deprecated-api

* style: fix no-useless-escape

* style: fix default-case

* style: fix unicorn/prefer-string-slice

* feat!: remove informedainews

the site is gone
2026-01-13 03:25:37 +08:00

40 lines
1.1 KiB
TypeScript

import { load } from 'cheerio';
import got from '@/utils/got';
import { parseDate } from '@/utils/parse-date';
const ProcessFeed = async (list, cache) => {
const host = 'https://www.leiphone.com';
const items = await Promise.all(
list.map(async (e) => {
const link = new URL(e, host).href;
const single = await cache.tryGet(link, async () => {
const response = await got.get(link);
const $ = load(response.data);
let description = '';
if ($('.top-img').html() !== null) {
description += $('.top-img').html();
}
return {
title: $('.headTit').text(),
description: description + $('.article-lead').text() + $('.lph-article-comView').html(),
pubDate: parseDate($('.time').text(), 8),
author: $('.aut > a').text(),
link,
};
});
return single;
})
);
return items;
};
export default { ProcessFeed };