feat(route): add cherrytimes (#18609)

* feat(route): add cherrytimes

* fix lint errors

* optimize

* more lint errors

* fetch first page only
This commit is contained in:
CanonNi 2025-03-18 15:35:39 +08:00 committed by GitHub
parent be047080cc
commit cee538dc75
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 39 additions and 0 deletions

View File

@ -0,0 +1,33 @@
import { Route } from '@/types';
import ofetch from '@/utils/ofetch';
import { load } from 'cheerio';
export const route: Route = {
path: '/market',
categories: ['new-media'],
example: '/cherrytimes/market',
name: 'Market',
maintainers: ['canonnizq'],
handler: async () => {
const response = await ofetch("https://cherrytimes.it/en/tag/markets?page=1");
const $ = load(response);
const items = $('div.post-container').toArray().map((item) => {
const element = $(item);
const a = element.find('a').eq(1);
return {
title: a.text(),
link: a.attr('href'),
description: element.find('p.excerpt').text(),
category: element.find('a').last().text(),
};
});
return {
title: 'Cherry Times - Market',
link: 'https://cherrytimes.it/en/tag/markets',
item: items,
};
},
};

View File

@ -0,0 +1,6 @@
import type { Namespace } from '@/types';
export const namespace: Namespace = {
name: 'Cherry Times',
url: 'cherrytimes.it',
};