Files
RSSHub/lib/routes/lala/rss.ts
T
Tony a5e2e295dc refactor: fix all get to toArray (#19000)
* refactor: fix all get

* fix(utils/common-config): charset case compare

* Revert "fix(utils/common-config): charset case compare"

This reverts commit 3c1880f2fad53ad2cafddcee7741390fd46fa3d2.

* fix: nga

* fix: notateslaapp

* fix: ps

* fix: xjtu

* fix: enforce error on restricted syntax for get calls

* fix: eslint

* fix: more eslint
2025-05-04 05:24:53 +08:00

49 lines
1.3 KiB
TypeScript

import { Route } from '@/types';
import got from '@/utils/got';
import { load } from 'cheerio';
export const route: Route = {
path: '/',
categories: ['blog'],
example: '/lala',
radar: [
{
source: ['lala.im/'],
},
],
name: '最新发布',
maintainers: ['cnkmmk'],
handler,
url: 'lala.im/',
};
async function handler() {
const currentUrl = 'https://lala.im';
const response = await got(`${currentUrl}/feed`);
const $ = load(response.data, { xmlMode: true });
const titleMain = $('channel > title').text();
const descriptionMain = $('channel > description').text();
const items = $('channel > item')
.toArray()
.map((item) => {
const $item = $(item);
const link = $item.find('link').text();
const title = $item.find('title').text();
const description = $item.find('description').text();
const pubDate = $item.find('pubDate').text();
return {
link,
pubDate, // no need to normalize because it's from a valid RSS feed
title,
description,
};
});
return {
title: titleMain,
description: descriptionMain,
link: currentUrl,
item: items,
};
}